llvm-strip - object stripping toolΒΆ
SYNOPSISΒΆ
llvm-strip [options] inputsβ¦
DESCRIPTIONΒΆ
llvm-strip is a tool to strip sections and symbols from object files.
If no other stripping or remove options are specified, --strip-all
will be enabled.
By default, the input files are modified in-place. If β-β is specified for the input file, the input is read from the programβs standard input stream.
If the input is an archive, any requested operations will be applied to each archive member individually.
The tool is still in active development, but in most scenarios it works as a drop-in replacement for GNUβs strip.
GENERIC AND CROSS-PLATFORM OPTIONSΒΆ
The following options are either agnostic of the file format, or apply to multiple file formats.
- --disable-deterministic-archives, -UΒΆ
Use real values for UIDs, GIDs and timestamps when updating archive member headers.
- --discard-all, -xΒΆ
Remove most local symbols not referenced by relocations from the output. Different file formats may limit this to a subset of the local symbols. For example, file and section symbols in ELF objects will not be discarded. Additionally, remove all debug sections.
- --enable-deterministic-archives, -DΒΆ
Enable deterministic mode when stripping archives, i.e. use 0 for archive member header UIDs, GIDs and timestamp fields. On by default.
- --help, -hΒΆ
Print a summary of command line options.
- --no-strip-allΒΆ
Disable
--strip-all
.
- -o <file>ΒΆ
Write output to <file>. Multiple input files cannot be used in combination with -o.
- --only-keep-debugΒΆ
Produce a debug file as the output that only preserves contents of sections useful for debugging purposes.
For ELF objects, this removes the contents of SHF_ALLOC sections that are not SHT_NOTE by making them SHT_NOBITS and shrinking the program headers where possible.
- --regexΒΆ
If specified, symbol and section names specified by other switches are treated as extended POSIX regular expression patterns.
- --remove-section <section>, -RΒΆ
Remove the specified section from the output. Can be specified multiple times to remove multiple sections simultaneously.
- --strip-all-gnuΒΆ
Remove all symbols, debug sections and relocations from the output. This option is equivalent to GNU stripβs
--strip-all
switch.
- --strip-all, -sΒΆ
For ELF objects, remove from the output all symbols and non-alloc sections not within segments, except for .gnu.warning, .ARM.attribute sections and the section name table.
For COFF objects, remove all symbols, debug sections, and relocations from the output.
- --strip-debug, -d, -g, -SΒΆ
Remove all debug sections from the output.
- --strip-symbol <symbol>, -NΒΆ
Remove all symbols named
<symbol>
from the output. Can be specified multiple times to remove multiple symbols.
- --strip-unneededΒΆ
Remove from the output all local or undefined symbols that are not required by relocations. Also remove all debug sections.
- --version, -VΒΆ
Display the version of the llvm-strip executable.
- --wildcard, -wΒΆ
Allow wildcard syntax for symbol-related flags. On by default for section-related flags. Incompatible with βregex.
Wildcard syntax allows the following special symbols:
Character
Meaning
Equivalent
*
Any number of characters
.*
?
Any single character
.
\
Escape the next character
\
[a-z]
Character class
[a-z]
[!a-z]
,[^a-z]
Negated character class
[^a-z]
Additionally, starting a wildcard with β!β will prevent a match, even if another flag matches. For example
-w -N '*' -N '!x'
will strip all symbols except forx
.The order of wildcards does not matter. For example,
-w -N '*' -N '!x'
is the same as-w -N '!x' -N '*'
.
- @<FILE>ΒΆ
Read command-line options and commands from response file <FILE>.
ELF-SPECIFIC OPTIONSΒΆ
The following options are implemented only for ELF objects. If used with other objects, llvm-strip will either emit an error or silently ignore them.
- --allow-broken-linksΒΆ
Allow llvm-strip to remove sections even if it would leave invalid section references. Any invalid sh_link fields will be set to zero.
- --discard-locals, -XΒΆ
Remove local symbols starting with β.Lβ not referenced by relocations from the output.
- --keep-file-symbolsΒΆ
Keep symbols of type STT_FILE, even if they would otherwise be stripped.
- --keep-section <section>ΒΆ
When removing sections from the output, do not remove sections named
<section>
. Can be specified multiple times to keep multiple sections.
- --keep-symbol <symbol>, -KΒΆ
When removing symbols from the output, do not remove symbols named
<symbol>
. Can be specified multiple times to keep multiple symbols.
- --preserve-dates, -pΒΆ
Preserve access and modification timestamps in the output.
- --strip-sectionsΒΆ
Remove from the output all section headers and all section data not within segments. Note that many tools will not be able to use an object without section headers.
- -TΒΆ
Remove Swift symbols.
EXIT STATUSΒΆ
llvm-strip exits with a non-zero exit code if there is an error. Otherwise, it exits with code 0.
BUGSΒΆ
To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy%2Fstrip>.