0
votes

With the following assembly:

mov $2, %rax
push %rcx
call func

The 'stack' section in gdb looks like this:

─── Stack ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[0] from 0x0000000000400109 in func
[1] from 0x00000000004000be in _start

And it doesn't matter whether I add or remove the push %rcx instruction. Why does gdb only show the 'function address stack', and not show any modifications to the stack when manually pushed? That is, both push %rcx and call func change the stack register rsp but only the latter actually changes what gdb shows in the "stack" section.

Could someone please explain the reason for this?

1
That's some custom gdb modification and it prints the call stack, otherwise known as backtrace. It only shows the nested function calls. To look at the actual stack do something like x/8x $rsp - Jester
@Jester: Yes, but how does it figure out which qwords on the stack are from call and which are from push, for hand-written asm without debug info? I'd guess it might look for possible return addresses, i.e. values that point into the text section? Or maybe the OP isn't showing us a complete enough full picture. - Peter Cordes

1 Answers

0
votes

The 'stack' section in gdb looks like this:

The 'stack' here stands for 'call stack', not 'stack memory'.