Chapter 3 89
Linker Tasks
Using Linker commands
Stripping Symbol Table Information from the
Output File with -s and -x
The a.out file created by the linker contains symbol table, relocation,
and (if debug options were specified) information used by the debugger.
Such information can be used by other commands that work on a.out
files, but is not actually necessary to make the file run. ld provides two
command line options for removing such information and, thus, reducing
the size of executables:
-s Strips all such information from the file. The
executable becomes smaller, but difficult or impossible
to use with a symbolic debugger. You can get much the
same results by running the strip command on an
executable (see strip(1)). In some cases, however, -s
rearranges the file to save more space than strip.
-x Strips only local symbols from the symbol table. It
reduces executable file size with only a minimal affect
on commands that work with executables. However,
using this option may still make the file unusable by a
symbolic debugger.
These options can reduce the size of executables dramatically. Note, also,
that these options can also be used when generating shared libraries
without affecting shareability.