Detect GCC compile-time flags of a binary

前端 未结 4 2038
谎友^
谎友^ 2020-11-30 08:42

Is there a way to find out what gcc flags a particular binary was compiled with?

4条回答
  •  醉话见心
    2020-11-30 09:25

    A quick look at the GCC documentation doesn't turn anything up.

    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).


    (Added much later): Turns out GCC has this feature in 4.3 if asked for when you compile the code:

    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.

提交回复
热议问题