Find Symbols In Object Files

28 Feb 2013

To list symbols in .so .a .o or an executable files, you can use nm or objdump -t to list the contents of the symbol table.

The basic syntax of nm and objdump commands is:

# do not show debugging symbols
$ nm yourlib.a

# show debugging symbols with nm
$ nm -a yourlib.a

# objdump -t will also display debugging symbols 
# if the program is compiled with -g flag
$ objdump -t yourlib.a

# show debugging symbols and sort symbols by address
# then feed it into c++filt to demangle all those symbols
$ nm -an a.out | c++filt

According to the second reference link below, command line tool readelf is more suitable for displaying symbols for ELF format (which is a common format for executables, object code, shared libraries and core dumps on UNIX/LINUX systems) files. Do check this tool out as well.

Try these commands with some a.out file of c/c++ programs and read their man pages.

ADDENDUM And if you want to demangle symbols, try use c++filt. Read man c++filt.