Detect GCC compile-time flags of a binary

Detect GCC compile-time flags of a binary

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

Math Question in C or Objective C


minimal cross-platform gui lib? [closed]
A quick look at the GCC documentation doesn't turn anything up..
Logic error for Gauss elimination
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).

Good tools for creating a C/C++ parser/analyzer [closed]
Is the ANTLR parser generator best for a C++ app with constrained memory?
Decode JPEG to obtain uncompressed data
(Added much later): Turns out GCC has this feature in 4.3 if asked for when you compile the code:.
Programatically getting UID and GID from username in Unix?
A new command-line switch -frecord-gcc-switches ...

What does the registerNatives() method do?
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..


Experimental proof:.
diciu$ gcc -O2 /tmp/tt.c -o /tmp/a.out.o2 diciu$ gcc -O3 /tmp/tt.c -o /tmp/a.out.o3 diciu$ diff /tmp/a.out.o3 /tmp/a.out.o2  diciu$ 
I take that as a no as the binaries are identical..


I'm the one who asked Brian to post this originally.

My question had to do with the samba binary.

I found out that you can run smb -b to get information on how it was built..


I don't think so.

. You can see if it has debug symbols, which means -g was used ;) But I can't think of any way how you could find out which directories have been used to search for include headers for example.. Maybe a better answer is possible if you only target for a specific flag; e.g.

if you only want to know if the flag "..." was set when this binary was compiled or not.

In that case, what flag would this be?.

80 out of 100 based on 40 user ratings 1190 reviews