I have some compiled libraries on x86 Linux and I want to quickly determine whether they were compiled with debugging symbols.
+5
A:
nm -a <lib>
will print all symbols from library, including debug ones.
So you can compare the outputs of nm <lib>
and nm -a <lib>
- if they differ, your lib contains some debug symbols.
qrdl
2010-01-04 13:56:24
nm is certainly the wrong tool for this question on Linux.
Employed Russian
2010-01-05 04:16:56
@Employed Russian Can you please elaborate on this? Why do you think it is a wrong tool? It does the job, and does it on Linux as well.
qrdl
2010-01-05 08:27:22
+3
A:
If you're running on Linux, use 'objdump --debugging'. There should be an entry for each object file in the library. For object files without debugging symbols, you'll see something like:
objdump --debugging libvoidincr.a
In archive libvoidincr.a:
voidincr.o: file format elf64-x86-64
If there are debugging symbols, the output will be much more verbose.
Matt McClellan
2010-01-04 14:02:08
There are also `obdjump -W lib` and `readelf -w lib`. The latter one is more configurable - see readelf(1) manpage.
przemoc
2010-01-04 14:16:59
For any binary, (including those compiled with -g) objdump gives me the response of "no recognized debugging information" unless I compile it with -gstabs. This appears to be a recognized bug.
Dan Hook
2010-01-04 14:24:20
Employed Russian: from man objdump(1), the --debugging flag "attempts to parse STABS and IEEE debugging format information stored in the file and print it out using a C like syntax. If neither of these formats are found this option falls back on the -W option to print any DWARF information in the file."
Matt McClellan
2010-01-05 17:13:21