| manpages.info - online man pages | ![]() |
|||
|
strip (1) Table of Contents
Namestrip - remove symbols
Synopsisstrip [ option ] name ...
Descriptionstrip removes or modifies the symbol table attached to the output of the assembler and link editor. This is useful to save space after a program has been debugged and to limit dynamically bound symbols.
strip no longer removes relocation entries under any condition. Instead, it updates the external relocation entries (and indirect symbol table entries) to reflect the resulting symbol table. strip prints an error message for those symbols not in the resulting symbol table that are needed by an external relocation entry or an indirect symbol table. The link editor ld(1) is the only program that can strip relocation entries and know if it is safe to do so.
When strip is used with no options on an executable file, it checks that file to see if it uses the dynamic link editor. If it does, the effect of the strip command is the same as using the -u and -r options. If the file does not use the dynamic link editor, the effect of strip without any options is the same as using the -s option of ld(1) . The options -S, -x, and -X have the same effect as the ld(1) options. The options to strip(1) can be combined to trim the symbol table to just what is desired.
You should trim the symbol table of files used with dynamic linking so that only those symbols intended to be external interfaces are saved. Files used with dynamic linking include executables, objects that are loaded (usually bundles), and dynamic shared libraries. Only global symbols are used by the dynamic linking process. You should strip all non-global symbols.
When an executable is built with all its dependent dynamic shared
libraries, it is typically stripped with:
% strip -u -r executable
If the executable loads objects, however, the global symbols that the objects reference from the executable also must not be stripped. In this case, you should list the global symbols that the executable wants to allow the objects to reference in a file, and those global symbols are then saved when the executable is stripped. For example: % strip -u -r -s interface_symbols executable where the file interface_symbols would contain only those global symbols from the executable that the executable wants the loaded objects to have access to.
For objects that will be loaded into an executable, you should trim the
symbol table to limit the global symbols the executable will see. This
would be done with:
For dynamic shared libraries, the maximum level of stripping is usually -x (to remove all non-global symbols).
Stripping Files for Use with Runtime Loaded Code
Trimming the symbol table for programs that load code at runtime allows
you to control the interface that the executable wants to provide to
the objects that it will load; it will not have to publish symbols that
are not part of its interface. For example, an executable that wishes
to allow only a subset of its global symbols but all of the statically
linked shared library's globals to be used would be stripped with:
% strip -s interface_symbols -A executable
where the file interface_symbols would contain only those symbols from
the executable that it wishes the code loaded at runtime to have access
to. Another example is an object that is made up of a number of other
objects that will be loaded into an executable would built and then
stripped with:
OptionsThe first set of options indicate symbols that are to be save in the resulting output file.
These options specify symbols to be removed from the resulting output file.
And the last options:
See Also
LimitationsNot every layout of a Mach-O file can be stripped by this program. But all layouts produced by the Apple compiler system can be stripped.
|