Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( Due: Jan. 3 1 ) This warm - up homework helps you understand what is really inside of a running program and what the

(Due: Jan. 31)
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 xvfz cis345s/pub/hw1.tar.gz
to uncompress and extract the files (i.e. lbcount.c, map.c ) to your working directory. Next, use the following commands to compile and build the needed executable files:
gcc lbcount.c-g-o lbcount
gcc map.c-g-o map
Load up your Ibcount executable in gdb, set a breakpoint at the second if statement, and start running your program with the single input file lbcount. 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 1 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[0])
What is the value of bCnt? ICnt?
What is the address of the function main?
Try info frame. Explain what you see.
Next, type objdump -x-d lbcount to look the executable file lbcount. 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 hw1 report.pdf.
8. What direction is the heap growing in?
9. Is there any extra space between the two malloc()ed memory addresses? Show your calculations i 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions