I am trying to understand the working of a simple asm code, my task is to build the stack or the list of values pointed by rsp
throughout execution.
In gdb, after setting a breakpoint @ main I use x/10xg $rsp
to display 10 - memory addr from rsp. But since the results are shown in 2x32-bit form, rather than 1x64, I am unable to understand what values rsp
is taking.
My goal here is to make the entire stack of the program to see what goes where and to understand the order of execution of the program.
What I am confused about is:
-Why doesn't x
has specifier to show results in 1x64 bit form?
-How do I achieve my goal of making the stack of the program?
Here's my asm :
0x0000555555555170 <+0>: endbr64
0x0000555555555174 <+4>: push rbp
0x0000555555555175 <+5>: mov rbp,rsp
=> 0x0000555555555178 <+8>: mov eax,0x0
0x000055555555517d <+13>: call 0x55555555515c <func>
0x0000555555555182 <+18>: pop rbp
0x0000555555555183 <+19>: ret
and the output of x/10xg $rsp
when ip
is at line 4
is :
0x7fffffffdd30: 0x0000000000000000 0x00007ffff7dd80b3
0x7fffffffdd40: 0x00007ffff7ffc620 0x00007fffffffde28
0x7fffffffdd50: 0x0000000100000000 0x0000555555555170
0x7fffffffdd60: 0x0000555555555190 0x1706e24ed60a5880
0x7fffffffdd70: 0x0000555555555040 0x00007fffffffde20
Shouldn't the value of rsp
be the address of the next instruction, which is 0x0000555555555178
?
I can see something similar to the mem addr of the code in higher addr of the stack but since it is split to 2 x 32 bit form i am unable to easily understand the value of the stack
Also, am i approaching it the correct way? I am really confused here, sorry if my question sounds stupid.
gdb version:
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
This is what i am trying to achieve.