Using GNU Binary Utilities229
common.o:
00000000 T msg
U printf
ftp.o:
00000000 T main
U msg
U printf
[root@boota make]#
For each symbol, nm displays three properties of the symbol.
1.
Value
2.
Type
3.
Name
The
value
of the symbol is displayed in hexadecimal by default.
Type
is a character, either
uppercase or lowercase. The uppercase character shows that the symbol is global and the lower-
case character shows that the symbol is local. The following line shows that the symbol value is
00000000, its type is T which shows that the symbol is in code section and its name is
msg
.
00000000 T msg
Type U in the above output of
nm
command shows that the symbol is undefined and no
value is displayed. Note that function
msg
is defined in
common.o
but undefined in the
ftp.o
member of the archive. This is because of the fact that the function was defined in
common.c
file and it is used in
ftp.c
file.
Usually, the list of symbols is very long in executable files. Consider the following simple
file that displays the string “Hello world”.
#include
main()
{
printf ("Hello world\n");
}
Let us compile this file to create an executable
a.out
file. A list of symbols in the
a.out
executable file is shown below:
[root@boota]# nm -s a.out
08049540 . _DYNAMIC
0804951c . _GLOBAL_OFFSET_TABLE_
080484e4 R _IO_stdin_used
08049510 . __CTOR_END__
0804950c . __CTOR_LIST__
08049518 . __DTOR_END__
08049514 . __DTOR_LIST__