HP-UX Linker and Libraries User's Guide

Example 2 Using the nm command
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 $0 } }'
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
0000000000 u
0000000000 r .HP.opt_annot
0000000000 r .IA_64.unwind_info
0000000000 r .text
0000000000 a func.c
0000000000 T sum_n //Global definitions of sum_n.
$ nm -p main.o
0000000000 U $global$ //Other symbols created from compiling.
0000000000 u
0000000000 r .HP.opt_annot
0000000000 r .IA_64.unwind_info
0000000000 r .data
0000000000 r .sdata
0000000000 r .text
0000000000 a main.c
0000000000 T main //Global definition of main.
0000000000 U printf
0000000000 U scanf
0000000000 U sum_n
Viewing the Contents of an Object File with elfdump(1)
The elfdump(1) command displays information contained in ELF format object files, archives,
and shared libraries. Use the following options to select the information you want to display:
Use the optionTo view this
-aArchive headers from an archive library.
-cString table(s).
-dThe .note section which contains the compilation unit dictionary and linker footprint. This
option has the same effect as elfdump -dc-dl.
-dcThe compilation unit dictionary of the .note section.
-dcThe linker footprint of the .note section. The linker footprint has information on the linker
used to generate the file as well as the link time.
-fFile header.
-gGlobal symbols from an archive.
-hSection headers.
+interpThe run-time interpreter path name for a.out (usually the location of the dynamic loader
and microloader). Only shared bound executables have this string. To change the setting,
use the ld+interp command.
-jThe object dictionary for one or more executable files, if the source file was compiled with
the +objdebug option. The object dictionary entry contains the name of the object file that
contributed to a particular section, the relative offset within the section, size of the object
file's contribution, and attributes of the entry.
-kThe CTTI section headers according to the directory member relationship.
58 Linker Tools for Itanium-Based Systems