How can I inspect a static library to see if the debug symbols are being exported?

Spilly picture Spilly · Dec 20, 2012 · Viewed 16.9k times · Source

I have a static library I'm building in debug mode, but when I step into it I still get disassembly. I want to know how to use nm or another tool to ensure that the debug symbols are not being stripped.

Answer

alk picture alk · Dec 20, 2012

You might use nm's option --debug-syms, to let nm also list debugger symbols (if any) for the object packed into a library.

For debugger symbols the second column indicates N.

Example (assumes the object example.o to be in the library)

nm --debug-syms libexample.a

Output (excerpt):

example.o:
0000000000000000 b .bss
0000000000000000 n .comment
0000000000000000 d .data
0000000000000000 N .debug_abbrev    
0000000000000000 N .debug_aranges
0000000000000000 N .debug_info
0000000000000000 N .debug_line
0000000000000000 N .debug_loc
0000000000000000 N .debug_pubnames
0000000000000000 N .debug_str
0000000000000000 r .eh_frame
0000000000000000 n .note.GNU-stack
0000000000000000 r .rodata
0000000000000000 t .text
...

For more on this please see man nm.