Detect GCC compile-time flags of a binary(检测二进制文件的 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.
这篇关于检测二进制文件的 GCC 编译时标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检测二进制文件的 GCC 编译时标志


基础教程推荐
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01