blob: 41529bf08cc14e40083ba466f69c08f169671bd3 [file] [log] [blame]
Michael Pozulp4fe911d2019-08-09 19:10:55 +00001llvm-strip - object stripping tool
2==================================
3
4.. program:: llvm-strip
5
6SYNOPSIS
7--------
8
9:program:`llvm-strip` [*options*] *inputs...*
10
11DESCRIPTION
12-----------
13
14:program:`llvm-strip` is a tool to strip sections and symbols from object files.
15If no other stripping or remove options are specified, :option:`--strip-all`
James Henderson1b103862019-09-24 13:41:39 +000016will be enabled.
Michael Pozulp4fe911d2019-08-09 19:10:55 +000017
James Henderson1b103862019-09-24 13:41:39 +000018By default, the input files are modified in-place. If "-" is specified for the
19input file, the input is read from the program's standard input stream.
Michael Pozulp4fe911d2019-08-09 19:10:55 +000020
21If the input is an archive, any requested operations will be applied to each
22archive member individually.
23
24The tool is still in active development, but in most scenarios it works as a
25drop-in replacement for GNU's :program:`strip`.
26
27GENERIC AND CROSS-PLATFORM OPTIONS
28----------------------------------
29
30The following options are either agnostic of the file format, or apply to
31multiple file formats.
32
33.. option:: --disable-deterministic-archives, -U
34
35 Use real values for UIDs, GIDs and timestamps when updating archive member
36 headers.
37
38.. option:: --discard-all, -x
39
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.
43
44.. option:: --enable-deterministic-archives, -D
45
46 Enable deterministic mode when stripping archives, i.e. use 0 for archive member
47 header UIDs, GIDs and timestamp fields. On by default.
48
49.. option:: --help, -h
50
51 Print a summary of command line options.
52
53.. option:: --no-strip-all
54
James Henderson4dd9b2f2019-09-25 13:09:12 +000055 Disable :option:`--strip-all`.
Michael Pozulp4fe911d2019-08-09 19:10:55 +000056
57.. option:: -o <file>
58
59 Write output to <file>. Multiple input files cannot be used in combination
60 with -o.
61
62.. option:: --regex
63
64 If specified, symbol and section names specified by other switches are treated
65 as extended POSIX regular expression patterns.
66
67.. option:: --remove-section <section>, -R
68
69 Remove the specified section from the output. Can be specified multiple times
70 to remove multiple sections simultaneously.
71
72.. option:: --strip-all-gnu
73
74 Remove all symbols, debug sections and relocations from the output. This option
75 is equivalent to GNU :program:`strip`'s ``--strip-all`` switch.
76
77.. option:: --strip-all, -S
78
79 For ELF objects, remove from the output all symbols and non-alloc sections not
80 within segments, except for .gnu.warning sections and the section name table.
81
82 For COFF objects, remove all symbols, debug sections, and relocations from the
83 output.
84
85.. option:: --strip-debug, -g
86
James Henderson4dd9b2f2019-09-25 13:09:12 +000087 Remove all debug sections from the output.
Michael Pozulp4fe911d2019-08-09 19:10:55 +000088
89.. option:: --strip-symbol <symbol>, -N
90
91 Remove all symbols named ``<symbol>`` from the output. Can be specified
92 multiple times to remove multiple symbols.
93
94.. option:: --strip-unneeded
95
James Henderson818e5c92019-09-13 13:26:52 +000096 Remove from the output all local or undefined symbols that are not required by
97 relocations. Also remove all debug sections.
Michael Pozulp4fe911d2019-08-09 19:10:55 +000098
99.. option:: --version, -V
100
James Henderson778a5e52019-09-17 11:43:42 +0000101 Display the version of the :program:`llvm-strip` executable.
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000102
Michael Pozulpc45fd0c2019-09-14 01:14:43 +0000103.. option:: @<FILE>
104
James Henderson778a5e52019-09-17 11:43:42 +0000105 Read command-line options and commands from response file `<FILE>`.
Michael Pozulpc45fd0c2019-09-14 01:14:43 +0000106
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000107COFF-SPECIFIC OPTIONS
108---------------------
109
110The following options are implemented only for COFF objects. If used with other
111objects, :program:`llvm-strip` will either emit an error or silently ignore
112them.
113
114.. option:: --only-keep-debug
115
116 Remove the contents of non-debug sections from the output, but keep the section
117 headers.
118
119ELF-SPECIFIC OPTIONS
120--------------------
121
122The following options are implemented only for ELF objects. If used with other
123objects, :program:`llvm-strip` will either emit an error or silently ignore
124them.
125
126.. option:: --allow-broken-links
127
James Henderson1b103862019-09-24 13:41:39 +0000128 Allow :program:`llvm-strip` to remove sections even if it would leave invalid
129 section references. Any invalid sh_link fields will be set to zero.
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000130
131.. option:: --discard-locals, -X
132
133 Remove local symbols starting with ".L" from the output.
134
135.. option:: --keep-file-symbols
136
137 Keep symbols of type `STT_FILE`, even if they would otherwise be stripped.
138
Michael Pozulp3de98132019-08-09 19:41:13 +0000139.. option:: --keep-section <section>
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000140
141 When removing sections from the output, do not remove sections named
142 ``<section>``. Can be specified multiple times to keep multiple sections.
143
144.. option:: --keep-symbol <symbol>, -K
145
James Henderson4dd9b2f2019-09-25 13:09:12 +0000146 When removing symbols from the output, do not remove symbols named
147 ``<symbol>``. Can be specified multiple times to keep multiple symbols.
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000148
149.. option:: --preserve-dates, -p
150
James Henderson4dd9b2f2019-09-25 13:09:12 +0000151 Preserve access and modification timestamps in the output.
152
153.. option:: --strip-sections
154
155 Remove from the output all section headers and all section data not within
156 segments. Note that many tools will not be able to use an object without
157 section headers.
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000158
Michael Pozulp4fe911d2019-08-09 19:10:55 +0000159EXIT STATUS
160-----------
161
162:program:`llvm-strip` exits with a non-zero exit code if there is an error.
163Otherwise, it exits with code 0.
164
165BUGS
166----
167
168To report bugs, please visit <http://llvm.org/bugs/>.
169
170SEE ALSO
171--------
172
173:manpage:`llvm-objcopy(1)`