Some low level debugging tools in linux.

nm : just lists symbols from obj file
================
-n sort symbols numerically by address
-D shows dynamic symbols only

Symbol type:
If lowercase, the symbol is local;
if uppercase, the symbol is global (external).
A - symbol's value is absolute, will not be changed by further linking.
B - symbol is in the uninitialized data section (known as BSS).
C - symbol is common. Common symbols are uninitialized data.
D - symbol is in the initialized data section.
N - symbol is a debugging symbol.
R - symbol is in a read only data section.
T - symbol is in the text(code) section.
U - symbol is undefined.

objdump : shows details of obj files
================
-d disassembly
-S mix source code when disassembles
-x display section/program headers
-r display relocation entries
-w more than 80 character wide display

readelf : displays information about contents of ELF format files
================
-a Equivalent to: -h -l -S -s -r -d -V -A -I
-e Equivalent to: -h -l -S

-h Display the ELF file header
-l Display the program headers
-S Display the section headers

-s Display the symbol table
--dyn-syms Display the dynamic symbol table

-r Display the relocations (if present)
-d Display the dynamic section (if present)

-W more than 80 character wide display

good examples:
================
# gcc -c -o test test.c
# readelf -esr test > a.txt

# gcc -g -c -o test test.c
# objdump -drS test > b.txt

No comments: