Next: Finding dynamically linked libraries, Previous: Identifying files, Up: Examining compiled files
As described earlier in the discussion of debugging, executables and object files can contain a symbol table (see 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.