strip ( mac version)
operate on an executable's symbol table
strip [ option ] name …
Removes or modifies the symbol table attached to the output of the assembler and link editor. Useful to save space
after a program has been debugged and to limit dynamically bound symbols.
Does not remove relocation entries. It updates the external relocation entries (and indirect
symbol table entries) to reflect the resulting symbol table. Displays 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) is the only program that can strip relocation entries.
When used without options on an executable file,
if the file uses the dynamic link editor, the effect is the same as using -u and -r .
If the file does not use the dynamic link editor (e.g. -preload or -static), the symbol table removed.
The -S, -x, and -X have the same effect as the ld options.
options can be combined to trim the symbol table to just what is desired.
Triming the symbol table of files used with dynamic linking retains only those symbols intended to be external interfaces.
Only global symbols are used by the dynamic linking process.
Files used with dynamic linking include executables, objects that are loaded (usually bundles), and dynamic shared libraries.
When an executable is built with all its dependent dynamic shared libraries, it may be stripped using:
% strip -u -r executable
Saving undefined symbols (usually defined in the dynamic shared libraries) and all global symbols defined in the executable
referenced by the dynamic libraries (as marked by the static link editor when the executable was built). This is the maximum level
of striping .
If the executable loads objects, the global symbols that the objects reference from the executable must not be
stripped. In this case, when linking the executable use -exported_symbols_list of the link editor to
limit which symbols can be referenced by the objects. Then only strip local and debug symbols, using:
% strip -x -S executable
For objects that will be loaded into an executable, trim the symbol table to limit the global symbols the executable will have access to.
This would be done with:
% strip -s interface_symbols -u object
.
which would leave only the undefined symbols and symbols listed in the file interface_symbols in the object file. In this case,
the relocation entries and indirect symbol table is updated to reflect the new symbol table.
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 control of 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 needs to allow only a subset of 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 should be available to the code loaded at runtime.
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:
% ld -o relocatable.o -r a.o b.o c.o
% strip -s interface_symbols -u relocatable.o
which would leave only the undefined symbols and symbols listed in the file interface_symbols in the object file. In this case
the relocation entries have been updated to reflect the new symbol table.
OPTIONS
| These indicate symbols that are to be retained
|
|---|
-u | Retain undefined symbols. This is intended for use with relocatable objects to retain symbols referred to by external
relocation entries. Common symbols are also referred to by external relocation entries and this flag does not retain
those symbols.
| -r | Retain all symbols referenced dynamically.
| -s filename
Retain global symbols listed in filename, one per
line. Leading and trailing white space are not part of the symbol name. Lines starting with # are ignored, as are lines with
only white space.
| -R filename
Remove global symbols listed in filename. Using the same format as the -s
Usually used in with options that retain some symbols, -S, -x, etc.
| -i Ignore symbols listed in -s or -R that are not in the files (this is normally an error).
| -d filename
Retain the debugging symbols for each source file name listed in filename.
The file names listed in filename must be one per line with no white space and be
the base name of the source file without any directories. Only with stab
debugging format, not when using the DWARF debugging format.
| -A Retain global Objective C class symbols and absolute symbols (except those with a value of zero).
use of programs that load code at runtime and want the loaded code to use symbols from the shared libraries
only used with NEXTSTEP 3.3 and earlier releases.
| -n Retain all N_SECT global symbols. Intended for use with executable programs in with
-A to remove the symbols needed for static link editing which are not needed for use with runtime loading interfaces where
using -s would be too much trouble
This is only used with NEXTSTEP 3.3 and earlier releases.
|
| symbols to be removed
|
|---|
-S | Remove the debugging symbol table entries (those created by the -g option to cc(1) and other compilers).
| -X | Remove the local symbols whose names begin with `L'. |
| -T The intent of this flag is to remove Swift symbols from the Mach-O symbol table,
i.e. whose names begin with
_$S or _$s when it finds an __objc_imageinfo section with a non-zero swift version.
When used with M-R,/ -s files the Swift symbols will also
be removed from global symbol lists used by dyld.
| -N Remove nlist symbols and the string table in binaries that use the dynamic linker .
Setting $STRIP_NLISTS has the same effect.
| -x | Remove local symbols
| -c | Remove the section contents of a dynamic library creating a stub library output file.
|
- | Remaining arguments are file names
| -D When stripping a static library, set the archive's SYMDEF file's
user id, group id, date, and mode to reasonable defaults. See the libtool
| -o output Write the result to the file output.
| -v Display the arguments passed to other tools run by strip when processing object files.
| -no_uuid Remove any LC_UUID load commands.
| -no_split_info Remove the LC_SEGMENT_SPLIT_INFO load command and its payload.
| -no_atom_info Remove the LC_ATOM_INFO load command and its payload.
| -no_code_signature_warning | Don't warn when the code signature would be invalid in the output.
| -arch arch_type |
Architecture of the file when it is a universal file. (See arch
The ddefault arch_type is "all" to operate on all architectures in the file.
default.
| | | | | | | | | | | | | | | | | | | | | | | |
SEE ALSO
ld(1), libtool(1), cc(1)
EXAMPLES
When creating a stub library the -c and -x are typically used:
strip -x -c libfoo -o libfoo.stripped
LIMITATIONS
Not every layout of a Mach-O file can be stripped by this program.
All layouts produced by the Apple compiler system can be stripped.
linux version