1

在 wikibookx86 Disassembly中,写到有时存在不设置标准堆栈帧的子例程。一种这样的情况是当我们在 C 中声明一个静态函数时。以下几行已经写在书中。

When an optimizing compiler sees a static function that is only referenced by calls (no references through function pointers), it "knows" that external functions cannot possibly interface with the static function (the compiler controls all access to the function), so the compiler doesn't bother making it standard.

我对上述陈述有以下疑问:

  1. 外部函数是否可以使用函数指针引用静态函数?如果是,如何?为什么允许?(我问这个是因为据我所知,静态函数具有本地范围,并且不能被任何外部函数访问)?
  2. 非标准堆栈帧是什么意思?非标准堆栈帧与标准堆栈帧有何不同?欢迎使用汇编代码进行解释:)

编辑:另一个我想回答的问题:为什么上述情况下的编译器设置非标准堆栈框架而不是标准堆栈框架?

4

1 回答 1

1
  1. 当然,只要它是同一翻译单元中的另一个函数,它获取指向静态函数的指针并将其提供给不同翻译单元中的代码。毕竟,函数在某处。制作它static可以防止其他对象找到它,但不会阻止它们被交给它。
  2. 例如,没有参数推送或弹出,或者返回值存储在编译器喜欢的任何地方。基本上,介于标准调用约定和内联函数体之间。尽管内联函数体是最有可能的结果。
于 2014-11-10T15:37:37.790 回答