Using GNU Binary Utilities231
common.o:
00000000 T msg /root/make/common.c:6
U printf /root/make/common.c:7
ftp.o:
00000000 T main /root/make/ftp.c:7
U msg /root/make/ftp.c:12
U printf /root/make/ftp.c:11
[root@boota make]#
7.7.3.2Listing Debug Symbols
When you compile a program with a debug option, many symbols are inserted in the files
that are used for debugging purposes. Using the –
a
option with the
nm
command also shows the
debug symbols.
Please see the manual pages of the
nm
command for a detail description of all options.
7.7.4Using the strip Utility
The
strip
command is used to remove symbols from an object or library file. This is use-
ful to reduce the size of the shipped product as these symbols are not required in enduser execut-
able code. Using the command, you can also remove symbols partially. For example, you can
remove only debug symbols, local symbols or all symbols with the help of command line options.
At least one object file must be provided at the command line. Note that the
strip
utility
modifies the object files; it does not create new files. To get an idea of the difference in size of
object file before and after using the
strip
command, let us take the example of a C file that
prints the “Hello world” string only. The size of the executable
a.out
file with symbols on my
computer is 13640 bytes. After using the following command, the size is reduced to 3208 bytes.
strip a.out
This is a considerable reduction in size. However, in some time-sensitive and embedded sys-
tems, stripping files may cause timing problems and code may behave differently in some cases.
7.7.5Using the objcopy Utility
The basic function of the
objcopy
utility is to copy one object file to another. This func-
tionality can be used to change the format of an object file. A common use is to create S-record
or binary files from ordinary object files. S-record or binary files can be used to burn ROM in
embedded systems. The following command converts the
ftp
file (which is a statically linked
file) to an S-record file
ftp.S
, which may be downloaded to a ROM/PROM using the EPROM
programmer.
objcopy -O srec ftp ftp.S
You can see types of both input and output files by using the
file
command as follows.
The output file is of type S-record.
Next Page >>
<< Previous Page
Back to the Table of Contents