Home arrow Journal arrow List symbols from C/C++ object files
List symbols from C/C++ object files PDF
Wednesday, 16 May 2012
If you've created an object file when compiled a C/C++ source code, you can see the symbols from that object file with nm command.

Creating object file (instead of binary file)

  gcc -c test.c

Then to look for symbols we run:

  nm test.o

We'll get (for our short C example):

# nm test.o
0000000000000000 T main
                 U sleep


A usefull option for nm is -C parameter which decode low level symbol names into user level names. Basically if your C++ Object Oriented code is compiled using -C you will see classes instead of low level useless symbols (at least for the programmer).

To decode symbols we can also make use of c++filt:

  nm test | grep OurClass | c++filt

(an example will be added soon)

Last Updated ( Wednesday, 16 May 2012 )
 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?