- publishing free software manuals
An Introduction to GCC - for the GNU compilers gcc and g++
by Brian J. Gough, foreword by Richard M. Stallman
Paperback (6"x9"), 144 pages
ISBN 0954161793
RRP £12.95 ($19.95)

"An excellent introduction... fills a much-needed niche in the marketplace" --- Association of C and C++ Users book review (Issue 16-4, August 2004) Get a printed copy>>>

12.2 Examining the symbol table

As described earlier in the discussion of debugging, executables and object files can contain a symbol table (see section 5 Compiling for debugging). This table stores the location of functions and variables by name, and can be displayed with the nm command:

$ nm a.out
08048334 t Letext
08049498 ? _DYNAMIC
08049570 ? _GLOBAL_OFFSET_TABLE_
........
080483f0 T main
08049590 b object.11
0804948c d p.3
         U printf@GLIBC_2.0

Among the contents of the symbol table, the output shows that the start of the main function has the hexadecimal offset 080483f0. Most of the symbols are for internal use by the compiler and operating system. A ‘T’ in the second column indicates a function that is defined in the object file, while a ‘U’ indicates a function which is undefined (and should be resolved by linking against another object file). A complete explanation of the output of nm can be found in the GNU Binutils manual.

The most common use of the nm command is to check whether a library contains the definition of a specific function, by looking for a ‘T’ entry in the second column against the function name.

ISBN 0954161793An Introduction to GCC - for the GNU compilers gcc and g++See the print edition