Example 2 Using the nm command
•Display which object files have undefined references for the symbol leap: nm
•Display which object files have a definition for the text symbol leap:
nm
•To view the symbols defined in an object file, use the nm command. The following
$ nm
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 |
|
| |
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:
To view this | Use the option |
|
|
Archive headers from an archive library. | |
|
|
String table(s). | |
|
|
The .note section which contains the compilation unit dictionary and linker footprint. This | |
option has the same effect as elfdump |
|
|
|
The compilation unit dictionary of the .note section. | |
|
|
The 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. |
|
|
|
File header. | |
|
|
Global symbols from an archive. | |
|
|
Section headers. | |
|
|
The | +interp |
and microloader). Only shared bound executables have this string. To change the setting, |
|
use the ld+interp command. |
|
|
|
The 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. |
|
|
|
The CTTI section headers according to the directory member relationship. | |
|
|
58 Linker Tools for