Question: This warm - up homework helps you understand what is really inside of a running program and what the operating system needs to deal with.

This warm-up homework helps you understand what is really inside of a running program and what the operating system needs to deal with. Login to one of the workstations in our Linux lab. Type
tar xviz
~cis345s/pub/hw1.tar.gz
to uncompress and extract the files (i.e. Ibcount.c, map.c) to your working directory. Next, use the following commands to compile and build the needed executable files:
goc Ibcount. c -g -o Ibcount
gcc map. C -g -o map
Load up your 1bcount executable in gdb, set a breakpoint at the second if statement, and start running your program with the single input file 1bcount. c. When the execution stops at the breakpoint, type continue three times. Take a screenshot of the terminal window and put it in your report file hw1 report. pdf. Think about the following questions and put your answers in your report.
1. What is the value of argv? (hint: print argv)
2. What is pointed to by argv? ?(hint: print argv[0])
3. What is the value of bCnt?1Cnt?
4. What is the address of the function main?
5. Try info frame. Explain what you see.
Next, type objdump -x -d 1bcount to look the executable file 1bcount. You will see that your program has several segments, names of functions and variables in your program correspond to labels with addresses or values. And the guts of everything is chunks of stuff within segments. In the objdump output these segments are under the section heading. There is actually a slight nuance between these two terms which you can read more about online. While you are looking through the objdump, try and think about the following questions and put the answers in the file hw1_report. pdf.
6. What segment/section contains main (the function) and what is the address of main? (The last few hex digits should be the same as what you saw in gdb)
7. Do you see the stack segment anywhere? What about the heap? Explain.
Now, you are ready to run the executable map. Think about the following questions and put the answers in hwl report. paf.
8. What direction is the heap growing in?
9. Is there any extra space between the two malloc)ed memory addresses? Show your calculations in detail.
10. What direction is the stack growing in?
11. How large is the stack frame for each recursive call? Show your calculations in detail.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!