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.
To check if there's debug info inside the kernel object, you can add the following at the end of the objdump command: | grep debug . If this string is found, you know the kernel object contains debug information. If not, then it's a "clean" kernel object.
We can use the readelf command with the -s flag to view exported symbols: $ readelf -s lib.so Symbol table '.
If we want to see the contents of our library, we can use the ar option -t . We can also see the symbols in our library, using the command nm , which lists each symbol's symbol value, symbol type, and symbol name from object files.
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
.
You can use the file command, available for many OSes, including Windows via Cygwin.
If it says 'not stripped' it means it has the debug info present.
As a side note, for static libs use ar to extract the .o
files & use file
on them directly.
You can use strip -S libXX.a
to check if your static library size has been reduce. The static library size will not change if it's not include debugging symbols.
It is works on Mac OS to check static library generated by Xcode.
Linux and Unix strip command
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