Let's take the following example I have from a single function:
first_function:
pushq %rbp
movq %rsp, %rbp
movq $2, -8(%rbp)
movq $4, -16(%rbp)
...
pop %rbp
ret
If we look at the stack before the ...
, it gives us:
>>> x/4g $rbp-16
0x7fffffffe410: 0x0000000000000004 0x0000000000000002
0x7fffffffe420: 0x0000000000000000 0x00000000004000bd
Or for me, an easier way to visualize it is:
+----------------+--------------------+---------------------------+
| 0x7fffffffe420 | 0x00000000004000bd | # function return address |
+----------------+--------------------+---------------------------+
| 0x7fffffffe418 | 0x0000000000000000 | # from push %rbp |
+----------------+--------------------+---------------------------+
| 0x7fffffffe410 | 0x0000000000000002 | # from mov $2, -8(%rbp) |
+----------------+--------------------+---------------------------+
| 0x7fffffffe408 | 0x0000000000000004 | # from mov $4, -16(%rbp) |
+----------------+--------------------+--------------------------
My question then is wouldn't a sub-function call (for example, if I called another function call in the ...
section) possibly clobber all the two variables I've added above (2
, and 4
)?