1 llvm-strip - object stripping tool
2 ==================================
4 .. program:: llvm-strip
9 :program:`llvm-strip` [*options*] *inputs...*
14 :program:`llvm-strip` is a tool to strip sections and symbols from object files.
15 If no other stripping or remove options are specified, :option:`--strip-all`
18 By default, the input files are modified in-place. If "-" is specified for the
19 input file, the input is read from the program's standard input stream.
21 If the input is an archive, any requested operations will be applied to each
22 archive member individually.
24 The tool is still in active development, but in most scenarios it works as a
25 drop-in replacement for GNU's :program:`strip`.
27 GENERIC AND CROSS-PLATFORM OPTIONS
28 ----------------------------------
30 The following options are either agnostic of the file format, or apply to
31 multiple file formats.
33 .. option:: --disable-deterministic-archives, -U
35 Use real values for UIDs, GIDs and timestamps when updating archive member
38 .. option:: --discard-all, -x
40 Remove most local symbols from the output. Different file formats may limit
41 this to a subset of the local symbols. For example, file and section symbols in
42 ELF objects will not be discarded. Additionally, remove all debug sections.
44 .. option:: --enable-deterministic-archives, -D
46 Enable deterministic mode when stripping archives, i.e. use 0 for archive member
47 header UIDs, GIDs and timestamp fields. On by default.
49 .. option:: --help, -h
51 Print a summary of command line options.
53 .. option:: --no-strip-all
55 Disable :option:`--strip-all`.
59 Write output to <file>. Multiple input files cannot be used in combination
62 .. option:: --only-keep-debug
64 Produce a debug file as the output that only preserves contents of sections
65 useful for debugging purposes.
67 For ELF objects, this removes the contents of `SHF_ALLOC` sections that are not
68 `SHT_NOTE` by making them `SHT_NOBITS` and shrinking the program headers where
73 If specified, symbol and section names specified by other switches are treated
74 as extended POSIX regular expression patterns.
76 .. option:: --remove-section <section>, -R
78 Remove the specified section from the output. Can be specified multiple times
79 to remove multiple sections simultaneously.
81 .. option:: --strip-all-gnu
83 Remove all symbols, debug sections and relocations from the output. This option
84 is equivalent to GNU :program:`strip`'s ``--strip-all`` switch.
86 .. option:: --strip-all, -s
88 For ELF objects, remove from the output all symbols and non-alloc sections not
89 within segments, except for .gnu.warning, .ARM.attribute sections and the
92 For COFF objects, remove all symbols, debug sections, and relocations from the
95 .. option:: --strip-debug, -d, -g, -S
97 Remove all debug sections from the output.
99 .. option:: --strip-symbol <symbol>, -N
101 Remove all symbols named ``<symbol>`` from the output. Can be specified
102 multiple times to remove multiple symbols.
104 .. option:: --strip-unneeded
106 Remove from the output all local or undefined symbols that are not required by
107 relocations. Also remove all debug sections.
109 .. option:: --version, -V
111 Display the version of the :program:`llvm-strip` executable.
113 .. option:: --wildcard, -w
115 Allow wildcard syntax for symbol-related flags. On by default for
116 section-related flags. Incompatible with --regex.
118 Wildcard syntax allows the following special symbols:
120 ====================== ========================= ==================
121 Character Meaning Equivalent
122 ====================== ========================= ==================
123 ``*`` Any number of characters ``.*``
124 ``?`` Any single character ``.``
125 ``\`` Escape the next character ``\``
126 ``[a-z]`` Character class ``[a-z]``
127 ``[!a-z]``, ``[^a-z]`` Negated character class ``[^a-z]``
128 ====================== ========================= ==================
130 Additionally, starting a wildcard with '!' will prevent a match, even if
131 another flag matches. For example ``-w -N '*' -N '!x'`` will strip all symbols
134 The order of wildcards does not matter. For example, ``-w -N '*' -N '!x'`` is
135 the same as ``-w -N '!x' -N '*'``.
139 Read command-line options and commands from response file `<FILE>`.
144 The following options are implemented only for ELF objects. If used with other
145 objects, :program:`llvm-strip` will either emit an error or silently ignore
148 .. option:: --allow-broken-links
150 Allow :program:`llvm-strip` to remove sections even if it would leave invalid
151 section references. Any invalid sh_link fields will be set to zero.
153 .. option:: --discard-locals, -X
155 Remove local symbols starting with ".L" from the output.
157 .. option:: --keep-file-symbols
159 Keep symbols of type `STT_FILE`, even if they would otherwise be stripped.
161 .. option:: --keep-section <section>
163 When removing sections from the output, do not remove sections named
164 ``<section>``. Can be specified multiple times to keep multiple sections.
166 .. option:: --keep-symbol <symbol>, -K
168 When removing symbols from the output, do not remove symbols named
169 ``<symbol>``. Can be specified multiple times to keep multiple symbols.
171 .. option:: --preserve-dates, -p
173 Preserve access and modification timestamps in the output.
175 .. option:: --strip-sections
177 Remove from the output all section headers and all section data not within
178 segments. Note that many tools will not be able to use an object without
183 Remove Swift symbols.
188 :program:`llvm-strip` exits with a non-zero exit code if there is an error.
189 Otherwise, it exits with code 0.
194 To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy%2Fstrip>.
199 :manpage:`llvm-objcopy(1)`