1STRIP(1) GNU Development Tools STRIP(1)
2
3
4
6 strip - discard symbols and other data from object files
7
9 strip [-F bfdname |--target=bfdname]
10 [-I bfdname |--input-target=bfdname]
11 [-O bfdname |--output-target=bfdname]
12 [-s|--strip-all]
13 [-S|-g|-d|--strip-debug]
14 [--strip-dwo]
15 [-K symbolname|--keep-symbol=symbolname]
16 [-M|--merge-notes][--no-merge-notes]
17 [-N symbolname |--strip-symbol=symbolname]
18 [-w|--wildcard]
19 [-x|--discard-all] [-X |--discard-locals]
20 [-R sectionname |--remove-section=sectionname]
21 [--keep-section=sectionpattern]
22 [--remove-relocations=sectionpattern]
23 [--strip-section-headers]
24 [-o file] [-p|--preserve-dates]
25 [-D|--enable-deterministic-archives]
26 [-U|--disable-deterministic-archives]
27 [--keep-section-symbols]
28 [--keep-file-symbols]
29 [--only-keep-debug]
30 [-v |--verbose] [-V|--version]
31 [--help] [--info]
32 objfile...
33
35 GNU strip discards all symbols from object files objfile. The list of
36 object files may include archives. At least one object file must be
37 given.
38
39 strip modifies the files named in its argument, rather than writing
40 modified copies under different names.
41
43 -F bfdname
44 --target=bfdname
45 Treat the original objfile as a file with the object code format
46 bfdname, and rewrite it in the same format.
47
48 --help
49 Show a summary of the options to strip and exit.
50
51 --info
52 Display a list showing all architectures and object formats
53 available.
54
55 -I bfdname
56 --input-target=bfdname
57 Treat the original objfile as a file with the object code format
58 bfdname.
59
60 -O bfdname
61 --output-target=bfdname
62 Replace objfile with a file in the output format bfdname.
63
64 -R sectionname
65 --remove-section=sectionname
66 Remove any section named sectionname from the output file, in
67 addition to whatever sections would otherwise be removed. This
68 option may be given more than once. Note that using this option
69 inappropriately may make the output file unusable. The wildcard
70 character * may be given at the end of sectionname. If so, then
71 any section starting with sectionname will be removed.
72
73 If the first character of sectionpattern is the exclamation point
74 (!) then matching sections will not be removed even if an earlier
75 use of --remove-section on the same command line would otherwise
76 remove it. For example:
77
78 --remove-section=.text.* --remove-section=!.text.foo
79
80 will remove all sections matching the pattern '.text.*', but will
81 not remove the section '.text.foo'.
82
83 --keep-section=sectionpattern
84 When removing sections from the output file, keep sections that
85 match sectionpattern.
86
87 --remove-relocations=sectionpattern
88 Remove relocations from the output file for any section matching
89 sectionpattern. This option may be given more than once. Note
90 that using this option inappropriately may make the output file
91 unusable. Wildcard characters are accepted in sectionpattern. For
92 example:
93
94 --remove-relocations=.text.*
95
96 will remove the relocations for all sections matching the patter
97 '.text.*'.
98
99 If the first character of sectionpattern is the exclamation point
100 (!) then matching sections will not have their relocation removed
101 even if an earlier use of --remove-relocations on the same command
102 line would otherwise cause the relocations to be removed. For
103 example:
104
105 --remove-relocations=.text.* --remove-relocations=!.text.foo
106
107 will remove all relocations for sections matching the pattern
108 '.text.*', but will not remove relocations for the section
109 '.text.foo'.
110
111 --strip-section-headers
112 Strip section headers. This option is specific to ELF files.
113 Implies --strip-all and --merge-notes.
114
115 -s
116 --strip-all
117 Remove all symbols.
118
119 -g
120 -S
121 -d
122 --strip-debug
123 Remove debugging symbols only.
124
125 --strip-dwo
126 Remove the contents of all DWARF .dwo sections, leaving the
127 remaining debugging sections and all symbols intact. See the
128 description of this option in the objcopy section for more
129 information.
130
131 --strip-unneeded
132 Remove all symbols that are not needed for relocation processing in
133 addition to debugging symbols and sections stripped by
134 --strip-debug.
135
136 -K symbolname
137 --keep-symbol=symbolname
138 When stripping symbols, keep symbol symbolname even if it would
139 normally be stripped. This option may be given more than once.
140
141 -M
142 --merge-notes
143 --no-merge-notes
144 For ELF files, attempt (or do not attempt) to reduce the size of
145 any SHT_NOTE type sections by removing duplicate notes. The
146 default is to attempt this reduction unless stripping debug or DWO
147 information.
148
149 -N symbolname
150 --strip-symbol=symbolname
151 Remove symbol symbolname from the source file. This option may be
152 given more than once, and may be combined with strip options other
153 than -K.
154
155 -o file
156 Put the stripped output in file, rather than replacing the existing
157 file. When this argument is used, only one objfile argument may be
158 specified.
159
160 -p
161 --preserve-dates
162 Preserve the access and modification dates of the file.
163
164 -D
165 --enable-deterministic-archives
166 Operate in deterministic mode. When copying archive members and
167 writing the archive index, use zero for UIDs, GIDs, timestamps, and
168 use consistent file modes for all files.
169
170 If binutils was configured with --enable-deterministic-archives,
171 then this mode is on by default. It can be disabled with the -U
172 option, below.
173
174 -U
175 --disable-deterministic-archives
176 Do not operate in deterministic mode. This is the inverse of the
177 -D option, above: when copying archive members and writing the
178 archive index, use their actual UID, GID, timestamp, and file mode
179 values.
180
181 This is the default unless binutils was configured with
182 --enable-deterministic-archives.
183
184 -w
185 --wildcard
186 Permit regular expressions in symbolnames used in other command
187 line options. The question mark (?), asterisk (*), backslash (\)
188 and square brackets ([]) operators can be used anywhere in the
189 symbol name. If the first character of the symbol name is the
190 exclamation point (!) then the sense of the switch is reversed for
191 that symbol. For example:
192
193 -w -K !foo -K fo*
194
195 would cause strip to only keep symbols that start with the letters
196 "fo", but to discard the symbol "foo".
197
198 -x
199 --discard-all
200 Remove non-global symbols.
201
202 -X
203 --discard-locals
204 Remove compiler-generated local symbols. (These usually start with
205 L or ..)
206
207 --keep-section-symbols
208 When stripping a file, perhaps with --strip-debug or
209 --strip-unneeded, retain any symbols specifying section names,
210 which would otherwise get stripped.
211
212 --keep-file-symbols
213 When stripping a file, perhaps with --strip-debug or
214 --strip-unneeded, retain any symbols specifying source file names,
215 which would otherwise get stripped.
216
217 --only-keep-debug
218 Strip a file, emptying the contents of any sections that would not
219 be stripped by --strip-debug and leaving the debugging sections
220 intact. In ELF files, this preserves all the note sections in the
221 output as well.
222
223 Note - the section headers of the stripped sections are preserved,
224 including their sizes, but the contents of the section are
225 discarded. The section headers are preserved so that other tools
226 can match up the debuginfo file with the real executable, even if
227 that executable has been relocated to a different address space.
228
229 The intention is that this option will be used in conjunction with
230 --add-gnu-debuglink to create a two part executable. One a
231 stripped binary which will occupy less space in RAM and in a
232 distribution and the second a debugging information file which is
233 only needed if debugging abilities are required. The suggested
234 procedure to create these files is as follows:
235
236 1.<Link the executable as normal. Assuming that it is called>
237 "foo" then...
238
239 1.<Run "objcopy --only-keep-debug foo foo.dbg" to>
240 create a file containing the debugging info.
241
242 1.<Run "objcopy --strip-debug foo" to create a>
243 stripped executable.
244
245 1.<Run "objcopy --add-gnu-debuglink=foo.dbg foo">
246 to add a link to the debugging info into the stripped
247 executable.
248
249 Note---the choice of ".dbg" as an extension for the debug info file
250 is arbitrary. Also the "--only-keep-debug" step is optional. You
251 could instead do this:
252
253 1.<Link the executable as normal.>
254 1.<Copy "foo" to "foo.full">
255 1.<Run "strip --strip-debug foo">
256 1.<Run "objcopy --add-gnu-debuglink=foo.full foo">
257
258 i.e., the file pointed to by the --add-gnu-debuglink can be the
259 full executable. It does not have to be a file created by the
260 --only-keep-debug switch.
261
262 Note---this switch is only intended for use on fully linked files.
263 It does not make sense to use it on object files where the
264 debugging information may be incomplete. Besides the gnu_debuglink
265 feature currently only supports the presence of one filename
266 containing debugging information, not multiple filenames on a one-
267 per-object-file basis.
268
269 -V
270 --version
271 Show the version number for strip.
272
273 -v
274 --verbose
275 Verbose output: list all object files modified. In the case of
276 archives, strip -v lists all members of the archive.
277
278 @file
279 Read command-line options from file. The options read are inserted
280 in place of the original @file option. If file does not exist, or
281 cannot be read, then the option will be treated literally, and not
282 removed.
283
284 Options in file are separated by whitespace. A whitespace
285 character may be included in an option by surrounding the entire
286 option in either single or double quotes. Any character (including
287 a backslash) may be included by prefixing the character to be
288 included with a backslash. The file may itself contain additional
289 @file options; any such options will be processed recursively.
290
292 the Info entries for binutils.
293
295 Copyright (c) 1991-2023 Free Software Foundation, Inc.
296
297 Permission is granted to copy, distribute and/or modify this document
298 under the terms of the GNU Free Documentation License, Version 1.3 or
299 any later version published by the Free Software Foundation; with no
300 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
301 Texts. A copy of the license is included in the section entitled "GNU
302 Free Documentation License".
303
304
305
306binutils-2.41 2023-08-16 STRIP(1)