检测二进制文件的 GCC 编译时标志

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
STL BigInt class implementation(STL BigInt 类实现)
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)