是否有一个gcc标志初始化局部变量的存储? [英] Is there a gcc flag to initialise local variable storage?
问题描述
在IBM AIX XLC
编译器提供了产生code初始化局部变量存储一个标志:
initauto =< HH>
Initialialize自动存储到< HH取代。 < HH>是
十六进制值。这会产生额外的code和
应仅用于错误判定。
我觉得MSVC编译器类似的调试版本,但我的记忆可能是在这一点上朦胧的。
是否有GCC等的选项?
确定,最好的答案我可以提供。
<一个href=\"http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html\">http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html不作为说不。没有任何东西注入叠擦code到输出文档。
尽可能接近我可以猜测,仅此可能的工作方式,是注入一些 memset的
般code(也许那样简单几 MOV
操作,但尽管如此)插入在其中创建一个自动可变每个嵌入词汇帧的开头。由于靠近我可以告诉 - 我的据的从GCC的内部的专家,但是 - 似乎有什么的文件的,会做这样<。 / p>
在进一步在此之后,GCC内幕(http://gcc.gnu.org/onlinedocs/gccint.pdf)的361页的PDF gccint.pdf定义了GCC名入境帧指针调整呼叫步骤一个功能是序言
。 (我真的不知道/了解这是否适用于其他词法作用域在函数内,但是。)因为要在一台机器发生定义(MD)的文件,任何这样的选择将的显得的有用于CPU架构中定义。我在他们的在线ViewCVS戳在<一个href=\"http://gcc.gnu.org/viewcvs/trunk/gcc/config/i386/\">http://gcc.gnu.org/viewcvs/trunk/gcc/config/i386/发现(至少一个)序言
拷贝各地i386.md的11893线,打搜索换了,功能扩展了几跳后,不似乎有什么东西发出有条件code类的。
但是,这下GCC's罩的东西还挺整齐...
The IBM AIX xlc
compiler offers a flag that generates code to initialise local variable storage:
initauto=<hh>
Initialialize automatic storage to <hh>. <hh> is a
hexadecimal value. This generates extra code and
should only be used for error determination.
I think the MSVC compiler does something similar for debug builds, but my memory may be hazy on this point.
Is there an equivalent option for GCC?
OK, Best answer I can offer.
http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html says "no," by omission. There's no documentation of anything to inject stack-wiping code into the output.
As near as I could guess, the only way this could work, is to inject some memset
-like code (perhaps as simple as a few mov
operations, but nonetheless) into the beginning of each embedded lexical frame in which an automatic variable is created. As near as I can tell -- and I am far from an expert on the internals of GCC, but -- there seems to be nothing documented that would do so.
In further following this, the PDF gccint.pdf of GCC Internals (http://gcc.gnu.org/onlinedocs/gccint.pdf) on page 361 defines that the GCC name for the frame pointer adjustment call step on entry to a function is prologue
. (I don't really know/understand whether this applies to other lexical scopes within a function, however.) Since that should occur in a Machine Definition (md) file, any such option would seem to have to be defined for a CPU architecture. I poked at their online ViewCVS at http://gcc.gnu.org/viewcvs/trunk/gcc/config/i386/ and found (at least one) copy of prologue
around line 11,893 of i386.md, which after playing search-for-the-function-expansion a few hops, doesn't seem to have anything to emit conditional code like that.
But this under-GCC's-hood stuff is kinda neat...
这篇关于是否有一个gcc标志初始化局部变量的存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!