0

让我们以我从单个函数中获得的以下示例为例:

first_function:
    pushq   %rbp
    movq    %rsp, %rbp
    movq $2, -8(%rbp)
    movq $4, -16(%rbp)
    ...
    pop %rbp
    ret

如果我们查看 之前的堆栈...,它会给我们:

>>> x/4g $rbp-16

0x7fffffffe410: 0x0000000000000004  0x0000000000000002
0x7fffffffe420: 0x0000000000000000  0x00000000004000bd

或者对我来说,一种更简单的可视化方法是:

+----------------+--------------------+---------------------------+
| 0x7fffffffe420 | 0x00000000004000bd | # function return address |
+----------------+--------------------+---------------------------+
| 0x7fffffffe418 | 0x0000000000000000 | # from push %rbp          |
+----------------+--------------------+---------------------------+
| 0x7fffffffe410 | 0x0000000000000002 | # from mov $2, -8(%rbp)   |
+----------------+--------------------+---------------------------+
| 0x7fffffffe408 | 0x0000000000000004 | # from mov $4, -16(%rbp)  |
+----------------+--------------------+--------------------------

那么我的问题是子函数调用(例如,如果我在该...部分中调用另一个函数调用)可能会破坏我在上面添加的所有两个变量(24)吗?

4

0 回答 0