Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone please explain me how to get those address?? The C function main() i

ID: 3577074 • Letter: C

Question

Can someone please explain me how to get those address??

The C function main() invokes the function cogito(), which invokes ergo() which invokes sum(). Using the gdb debugger, the process is stopped in sum() on a 64 - bit Intel machine. The auto variable x in sum() is at -4(%rbp). The auto variable y in ergo() is at -8(%rbp). The auto variable z in cogito() is at -4(%rbp). The current value in %rbp is 0 Times 8840. The contents of memory location 0 Times 8840 is 0 Times 8950. The contents of memory location 0 Times 8950 is 0 Times 9230. The contents of memory location 0 Times 9230 is 0 Times 9340. What is the address of the auto variable x in sum()? What is the address of the auto variable y in ergo()? What is the address of the auto variable z in cogito()?

Explanation / Answer

a)
-4(%rbp) gives the current stack pointer location...
which is Memory address = [rbp - 4] ====> 0x8840 - 4 ==> 0x883c

--------------------------------------------------------------------------------
b)
Similarly Current memory location of rbp is 0x8950
So address = [rbp - 8] ====> 0x8950 - 8 ==> 0x8948

--------------------------------------------------------------------------
c) Current memory location of rbp is 0x9230
So address = [rbp - 4] ====> 0x9230 - 4 ==> 0x922c