Detect GCC compile-time flags of a binary

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.

Leave a Comment