I'm compiling OpenSSL on Unix-machine. The default compiler is GCC-4.4.7
. I put an alternative compiler GCC-5.2.0
in another folder. I usually will prepend the path of alternative compiler to $PATH
so that gcc
will always use the one in alternative path.
But now I'm uncertain with the library I compiled, is there a way to tell which gcc is used for compiling my library? A workaround on the .o
files is appreciated as well.
The gcc and clang compiler suites will put a version string in the .comment
section of an ELF file. (If you generate an intermediate assembly language file, you can see this string as an .ident
directive).
The GNU linker will merge all the .comment
sections of its input object files into a single section, eliminating any duplicates.
You can read this section by running readelf -p .comment /path/to/your/objectfile
. For example, here is an executable made from two relocatable object files, one compiled with gcc and the other with clang:
$ readelf -p .comment hello
String dump of section '.comment':
[ 0] GCC: (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
[ 2d] clang version 3.8.1-12ubuntu1 (tags/RELEASE_381/final)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With