检测二进制文件的 GCC 编译时标志
有没有办法找出编译特定二进制文件时使用的 gcc 标志?
Is there a way to find out what gcc flags a particular binary was compiled with?
推荐答案
快速浏览 GCC 文档并没有发现任何问题.
A quick look at the GCC documentation doesn't turn anything up.
Boost 人员是一些最聪明的 C++ 开发人员,他们resort 命名 约定 因为这通常是不可能的(毕竟,可执行文件可以用任意数量的语言、任意数量的编译器版本创建).
The Boost guys are some of the smartest C++ developers out there, and they resort to naming conventions because this is generally not possible any other way (the executable could have been created in any number of languages, by any number of compiler versions, after all).
(稍后添加):结果是GCC 在 4.3 中有这个功能,如果你在编译代码时被要求:
一个新的命令行开关 -frecord-gcc-switches ... 导致用于调用编译器的命令行被记录到正在创建的目标文件中.此录音的确切格式取决于目标文件和二进制文件格式,但通常采用包含 ASCII 文本的注释部分的形式.
A new command-line switch -frecord-gcc-switches ... causes the command line that was used to invoke the compiler to be recorded into the object file that is being created. The exact format of this recording is target and binary file format dependent, but it usually takes the form of a note section containing ASCII text.
相关文章