4

Assume that you have a static library built with gcc by another person and you want to find out the version number of gcc that was used for compiling. Is there an easy way to extract this information from the library file?

I already tried out readelf, but all the switches I've used so far did not lead to a gcc version number.

ks1322
  • 33,961
  • 14
  • 109
  • 164
sebs
  • 205
  • 3
  • 9
  • possible duplicate of [How to retrieve the GCC version used to compile a given ELF executable?](http://stackoverflow.com/questions/2387040/how-to-retrieve-the-gcc-version-used-to-compile-a-given-elf-executable) – dbrank0 Jul 31 '14 at 08:39

2 Answers2

5

This gets recorded in DW_AT_producer attribute in DWARF debug info. So if you have debug info, try this:

objdump -Wi yourlibrary.a|grep "DW_AT_producer"

I didn't see any official documentation for this attribute, so you might have to check...

dbrank0
  • 9,026
  • 2
  • 37
  • 55
  • Unfortunately this didn't help. When I execute `objdump -Wi` I only get a list of all object files within the static library and the regarding file formats (_file format elf64-x86-64_). – sebs Jul 30 '14 at 14:32
  • Then probably does not contains this (or any) debug information. This is useless then. – dbrank0 Jul 30 '14 at 14:57
  • 1
    btw: this has been asked before: http://stackoverflow.com/questions/2387040/how-to-retrieve-the-gcc-version-used-to-compile-a-given-elf-executable/2393297#2393297 – dbrank0 Jul 31 '14 at 08:40
  • Thanks! I didn't find this thread while searching on stackoverflow. – sebs Jul 31 '14 at 08:53
4

Thanks to @dbrank0 I could retrieve the gcc version information from the static library. The solution that helped is provided here: https://stackoverflow.com/a/9673793/3868995
While readelf -wi <library> only lists the included files of the library, strings -a <library> |grep "GCC: (" made the job in my case. Thanks!

Community
  • 1
  • 1
sebs
  • 205
  • 3
  • 9