User's Manual

Use the optionTo
-rPrefix each output line with the name of the object file or archive file. Equivalent to -A.
-t formatDisplay each numeric value in the specified format. The format can be one of: d Display the
value and size of a symbol in decimal. This is the default for the default format or the -p
format. Equivalent to -d. o Display the value and size of a symbol in octal. Equivalent to -o.
x Display the value and size of a symbol in hexadecimal. This is the default for the -P format.
Equivalent to -x.
-T32-bit mode SOM files only: Truncate every name that would otherwise overflow its column
and place an asterisk as the last character in the displayed name to mark it as truncated. If
-A or -r is also specified, the file prefix is truncated first. By default, nm prints the entire name
of the symbols listed. Because object files can have symbol names with an arbitrary number
of characters, a name that is longer than the width of the column set aside for names overflows
its column, forcing every column after the name to be misaligned.
-uDisplay undefined symbols only.
-UPrint the usage menu.
-vSort symbols by value before they are printed.
-VDisplay the executing version of the nm command on standard error.
-xDisplays the value and size of a symbol in hexadecimal. This is the default for the -P format.
Equivalent to -t x.
Example 12 Viewing Symbols in an Object file with nm(1)
Display which object files have undefined references for the symbol "leap":
$ nm -rup *.o | grep leap
Display which object files have a definition for the text symbol "leap":
$ nm -rP *.o | awk '{ if ($3 == "T" && $2 == "leap" ) { print $1 } }'
To view the symbols defined in an object file, use the nm command. The following 32-bit mode
example shows output from running nm -p on the func.o and main.o object files.
$ nm -p func.o
1073741824 d $THIS_DATA$
1073741824 d $THIS_SHORTDATA$
1073741824 b $THIS_BSS$
1073741824 d $THIS_SHORTBSS$
0000000000 T sum_n //Global definitions of sum_n.
$ nm -p main.o
0000000000 U $global$ //Other symbols created from compiling.
1073741824 d $THIS_DATA$
1073741872 d $THIS_SHORTDATA$
1073741872 b $THIS_BSS$
1073741872 d $THIS_SHORTBSS$
0000000000 T main //Global definition of main.
0000000000 U printf
0000000000 U scanf
0000000000 U sum_n
The first column shows the address of each symbol or reference. The last column shows the
symbol name. The second column denotes the symbol's type: T indicates a global definition.
U indicates an external reference. d indicates a local definition of data. b indicates a local
definition of uninitialized data (bss). Thus, a global definition of sum_n is found in func.o.
An external reference to sum_n is found in main.o. External references to the C printf
and scanf routines are found in main.o. For details on the use of nm, see nm(1).
Viewing the Contents of an Object File with elfdump(1)
NOTE: The elfdump command works on 64-bit executables or shared libraries.
72 Linker Tools for PA-RISC Systems