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 warmup 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
~cisspubhwtar.gz
to uncompress and extract the files ie 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 bcount executable in gdb set a breakpoint at the second if statement, and start running your program with the single input file bcount. 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 hw report. pdf Think about the following questions and put your answers in your report.
What is the value of argv? hint: print argv
What is pointed to by argv? hint: print argv
What is the value of bCntCnt
What is the address of the function main?
Try info frame. Explain what you see.
Next, type objdump x d bcount to look the executable file bcount. 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 hwreport. pdf
What segmentsection 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
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.
What direction is the heap growing in
Is there any extra space between the two malloced memory addresses? Show your calculations in detail.
What direction is the stack growing in
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
