tags:

views:

316

answers:

3

I have some compiled libraries on x86 Linux and I want to quickly determine whether they were compiled with debugging symbols.

+7  A: 

You can use objdump for this.

EDIT: From the man-page:

-W
--dwarf
Displays  the  contents of the DWARF debug sections in the file, if
any are present.
swegi
+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
nm is certainly the wrong tool for this question on Linux.
Employed Russian
@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
+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
There are also `obdjump -W lib` and `readelf -w lib`. The latter one is more configurable - see readelf(1) manpage.
przemoc
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
Dan, on which platform did you try this?
swegi
Ubuntu 8.04 on x86
Dan Hook
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