Debian Codegraph @

upstream/debian-unstable/man1/strip.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "STRIP 1"
58 .TH STRIP 1 2026-03-05 binutils-2.46 "GNU Development Tools"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 strip \- discard symbols and other data from object files
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 strip [\fB\-F\fR \fIbfdname\fR |\fB\-\-target=\fR\fIbfdname\fR]
68 [\fB\-I\fR \fIbfdname\fR |\fB\-\-input\-target=\fR\fIbfdname\fR]
69 [\fB\-O\fR \fIbfdname\fR |\fB\-\-output\-target=\fR\fIbfdname\fR]
70 [\fB\-s\fR|\fB\-\-strip\-all\fR]
71 [\fB\-S\fR|\fB\-g\fR|\fB\-d\fR|\fB\-\-strip\-debug\fR]
72 [\fB\-\-strip\-dwo\fR]
73 [\fB\-K\fR \fIsymbolname\fR|\fB\-\-keep\-symbol=\fR\fIsymbolname\fR]
74 [\fB\-M\fR|\fB\-\-merge\-notes\fR][\fB\-\-no\-merge\-notes\fR]
75 [\fB\-N\fR \fIsymbolname\fR |\fB\-\-strip\-symbol=\fR\fIsymbolname\fR]
76 [\fB\-w\fR|\fB\-\-wildcard\fR]
77 [\fB\-x\fR|\fB\-\-discard\-all\fR] [\fB\-X\fR |\fB\-\-discard\-locals\fR]
78 [\fB\-R\fR \fIsectionname\fR |\fB\-\-remove\-section=\fR\fIsectionname\fR]
79 [\fB\-\-keep\-section=\fR\fIsectionpattern\fR]
80 [\fB\-\-remove\-relocations=\fR\fIsectionpattern\fR]
81 [\fB\-\-strip\-section\-headers\fR]
82 [\fB\-o\fR \fIfile\fR] [\fB\-p\fR|\fB\-\-preserve\-dates\fR]
83 [\fB\-D\fR|\fB\-\-enable\-deterministic\-archives\fR]
84 [\fB\-U\fR|\fB\-\-disable\-deterministic\-archives\fR]
85 [\fB\-\-keep\-section\-symbols\fR]
86 [\fB\-\-keep\-file\-symbols\fR]
87 [\fB\-\-only\-keep\-debug\fR]
88 [\fB\-\-plugin\fR \fIname\fR]
89 [\fB\-v\fR |\fB\-\-verbose\fR] [\fB\-V\fR|\fB\-\-version\fR]
90 [\fB\-\-help\fR] [\fB\-\-info\fR]
91 \fIobjfile\fR...
92 .SH DESCRIPTION
93 .IX Header "DESCRIPTION"
94 GNU \fBstrip\fR discards all symbols from object files
95 \&\fIobjfile\fR. The list of object files may include archives.
96 At least one object file must be given.
97 .PP
98 \&\fBstrip\fR modifies the files named in its argument,
99 rather than writing modified copies under different names.
100 .SH OPTIONS
101 .IX Header "OPTIONS"
102 .IP "\fB\-F\fR \fIbfdname\fR" 4
103 .IX Item "-F bfdname"
104 .PD 0
105 .IP \fB\-\-target=\fR\fIbfdname\fR 4
106 .IX Item "--target=bfdname"
107 .PD
108 Treat the original \fIobjfile\fR as a file with the object
109 code format \fIbfdname\fR, and rewrite it in the same format.
110 .IP \fB\-\-help\fR 4
111 .IX Item "--help"
112 Show a summary of the options to \fBstrip\fR and exit.
113 .IP \fB\-\-info\fR 4
114 .IX Item "--info"
115 Display a list showing all architectures and object formats available.
116 .IP "\fB\-I\fR \fIbfdname\fR" 4
117 .IX Item "-I bfdname"
118 .PD 0
119 .IP \fB\-\-input\-target=\fR\fIbfdname\fR 4
120 .IX Item "--input-target=bfdname"
121 .PD
122 Treat the original \fIobjfile\fR as a file with the object
123 code format \fIbfdname\fR.
124 .IP "\fB\-O\fR \fIbfdname\fR" 4
125 .IX Item "-O bfdname"
126 .PD 0
127 .IP \fB\-\-output\-target=\fR\fIbfdname\fR 4
128 .IX Item "--output-target=bfdname"
129 .PD
130 Replace \fIobjfile\fR with a file in the output format \fIbfdname\fR.
131 .IP "\fB\-R\fR \fIsectionname\fR" 4
132 .IX Item "-R sectionname"
133 .PD 0
134 .IP \fB\-\-remove\-section=\fR\fIsectionname\fR 4
135 .IX Item "--remove-section=sectionname"
136 .PD
137 Remove any section named \fIsectionname\fR from the output file, in
138 addition to whatever sections would otherwise be removed. This
139 option may be given more than once. Note that using this option
140 inappropriately may make the output file unusable. The wildcard
141 character \fB*\fR may be given at the end of \fIsectionname\fR. If
142 so, then any section starting with \fIsectionname\fR will be removed.
143 .Sp
144 If the first character of \fIsectionpattern\fR is the exclamation
145 point (!) then matching sections will not be removed even if an
146 earlier use of \fB\-\-remove\-section\fR on the same command line
147 would otherwise remove it. For example:
148 .Sp
149 .Vb 1
150 \& \-\-remove\-section=.text.* \-\-remove\-section=!.text.foo
151 .Ve
152 .Sp
153 will remove all sections matching the pattern '.text.*', but will not
154 remove the section '.text.foo'.
155 .IP \fB\-\-keep\-section=\fR\fIsectionpattern\fR 4
156 .IX Item "--keep-section=sectionpattern"
157 When removing sections from the output file, keep sections that match
158 \&\fIsectionpattern\fR.
159 .IP \fB\-\-remove\-relocations=\fR\fIsectionpattern\fR 4
160 .IX Item "--remove-relocations=sectionpattern"
161 Remove relocations from the output file for any section matching
162 \&\fIsectionpattern\fR. This option may be given more than once. Note
163 that using this option inappropriately may make the output file
164 unusable. Wildcard characters are accepted in \fIsectionpattern\fR.
165 For example:
166 .Sp
167 .Vb 1
168 \& \-\-remove\-relocations=.text.*
169 .Ve
170 .Sp
171 will remove the relocations for all sections matching the patter
172 \&'.text.*'.
173 .Sp
174 If the first character of \fIsectionpattern\fR is the exclamation
175 point (!) then matching sections will not have their relocation
176 removed even if an earlier use of \fB\-\-remove\-relocations\fR on the
177 same command line would otherwise cause the relocations to be removed.
178 For example:
179 .Sp
180 .Vb 1
181 \& \-\-remove\-relocations=.text.* \-\-remove\-relocations=!.text.foo
182 .Ve
183 .Sp
184 will remove all relocations for sections matching the pattern
185 \&'.text.*', but will not remove relocations for the section
186 \&'.text.foo'.
187 .IP \fB\-\-strip\-section\-headers\fR 4
188 .IX Item "--strip-section-headers"
189 Strip section headers. This option is specific to ELF files. Implies
190 \&\fB\-\-strip\-all\fR and \fB\-\-merge\-notes\fR.
191 .IP \fB\-s\fR 4
192 .IX Item "-s"
193 .PD 0
194 .IP \fB\-\-strip\-all\fR 4
195 .IX Item "--strip-all"
196 .PD
197 Remove all symbols.
198 .IP \fB\-g\fR 4
199 .IX Item "-g"
200 .PD 0
201 .IP \fB\-S\fR 4
202 .IX Item "-S"
203 .IP \fB\-d\fR 4
204 .IX Item "-d"
205 .IP \fB\-\-strip\-debug\fR 4
206 .IX Item "--strip-debug"
207 .PD
208 Remove debugging symbols only.
209 .IP \fB\-\-strip\-dwo\fR 4
210 .IX Item "--strip-dwo"
211 Remove the contents of all DWARF .dwo sections, leaving the
212 remaining debugging sections and all symbols intact.
213 See the description of this option in the \fBobjcopy\fR section
214 for more information.
215 .IP \fB\-\-strip\-unneeded\fR 4
216 .IX Item "--strip-unneeded"
217 Remove all symbols that are not needed for relocation processing in
218 addition to debugging symbols and sections stripped by
219 \&\fB\-\-strip\-debug\fR.
220 .IP "\fB\-K\fR \fIsymbolname\fR" 4
221 .IX Item "-K symbolname"
222 .PD 0
223 .IP \fB\-\-keep\-symbol=\fR\fIsymbolname\fR 4
224 .IX Item "--keep-symbol=symbolname"
225 .PD
226 When stripping symbols, keep symbol \fIsymbolname\fR even if it would
227 normally be stripped. This option may be given more than once.
228 .IP \fB\-M\fR 4
229 .IX Item "-M"
230 .PD 0
231 .IP \fB\-\-merge\-notes\fR 4
232 .IX Item "--merge-notes"
233 .IP \fB\-\-no\-merge\-notes\fR 4
234 .IX Item "--no-merge-notes"
235 .PD
236 For ELF files, attempt (or do not attempt) to reduce the size of any
237 SHT_NOTE type sections by removing duplicate notes. The default is to
238 attempt this reduction unless stripping debug or DWO information.
239 .IP "\fB\-N\fR \fIsymbolname\fR" 4
240 .IX Item "-N symbolname"
241 .PD 0
242 .IP \fB\-\-strip\-symbol=\fR\fIsymbolname\fR 4
243 .IX Item "--strip-symbol=symbolname"
244 .PD
245 Remove symbol \fIsymbolname\fR from the source file. This option may be
246 given more than once, and may be combined with strip options other than
247 \&\fB\-K\fR.
248 .IP "\fB\-o\fR \fIfile\fR" 4
249 .IX Item "-o file"
250 Put the stripped output in \fIfile\fR, rather than replacing the
251 existing file. When this argument is used, only one \fIobjfile\fR
252 argument may be specified.
253 .IP \fB\-p\fR 4
254 .IX Item "-p"
255 .PD 0
256 .IP \fB\-\-preserve\-dates\fR 4
257 .IX Item "--preserve-dates"
258 .PD
259 Preserve the access and modification dates of the file.
260 .IP \fB\-D\fR 4
261 .IX Item "-D"
262 .PD 0
263 .IP \fB\-\-enable\-deterministic\-archives\fR 4
264 .IX Item "--enable-deterministic-archives"
265 .PD
266 Operate in \fIdeterministic\fR mode. When copying archive members
267 and writing the archive index, use zero for UIDs, GIDs, timestamps,
268 and use consistent file modes for all files.
269 .Sp
270 If \fIbinutils\fR was configured with
271 \&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by default.
272 It can be disabled with the \fB\-U\fR option, below.
273 .IP \fB\-U\fR 4
274 .IX Item "-U"
275 .PD 0
276 .IP \fB\-\-disable\-deterministic\-archives\fR 4
277 .IX Item "--disable-deterministic-archives"
278 .PD
279 Do \fInot\fR operate in \fIdeterministic\fR mode. This is the
280 inverse of the \fB\-D\fR option, above: when copying archive members
281 and writing the archive index, use their actual UID, GID, timestamp,
282 and file mode values.
283 .Sp
284 This is the default unless \fIbinutils\fR was configured with
285 \&\fB\-\-enable\-deterministic\-archives\fR.
286 .IP \fB\-w\fR 4
287 .IX Item "-w"
288 .PD 0
289 .IP \fB\-\-wildcard\fR 4
290 .IX Item "--wildcard"
291 .PD
292 Permit regular expressions in \fIsymbolname\fRs used in other command
293 line options. The question mark (?), asterisk (*), backslash (\e) and
294 square brackets ([]) operators can be used anywhere in the symbol
295 name. If the first character of the symbol name is the exclamation
296 point (!) then the sense of the switch is reversed for that symbol.
297 For example:
298 .Sp
299 .Vb 1
300 \& \-w \-K !foo \-K fo*
301 .Ve
302 .Sp
303 would cause strip to only keep symbols that start with the letters
304 "fo", but to discard the symbol "foo".
305 .IP \fB\-x\fR 4
306 .IX Item "-x"
307 .PD 0
308 .IP \fB\-\-discard\-all\fR 4
309 .IX Item "--discard-all"
310 .PD
311 Remove non-global symbols.
312 .IP \fB\-X\fR 4
313 .IX Item "-X"
314 .PD 0
315 .IP \fB\-\-discard\-locals\fR 4
316 .IX Item "--discard-locals"
317 .PD
318 Remove compiler-generated local symbols.
319 (These usually start with \fBL\fR or \fB.\fR.)
320 .IP \fB\-\-keep\-section\-symbols\fR 4
321 .IX Item "--keep-section-symbols"
322 When stripping a file, perhaps with \fB\-\-strip\-debug\fR or
323 \&\fB\-\-strip\-unneeded\fR, retain any symbols specifying section names,
324 which would otherwise get stripped.
325 .IP \fB\-\-keep\-file\-symbols\fR 4
326 .IX Item "--keep-file-symbols"
327 When stripping a file, perhaps with \fB\-\-strip\-debug\fR or
328 \&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names,
329 which would otherwise get stripped.
330 .IP \fB\-\-only\-keep\-debug\fR 4
331 .IX Item "--only-keep-debug"
332 Strip a file, emptying the contents of any sections that would not be
333 stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections
334 intact. In ELF files, this preserves all the note sections in the
335 output as well.
336 .Sp
337 Note \- the section headers of the stripped sections are preserved,
338 including their sizes, but the contents of the section are discarded.
339 The section headers are preserved so that other tools can match up the
340 debuginfo file with the real executable, even if that executable has
341 been relocated to a different address space.
342 .Sp
343 The intention is that this option will be used in conjunction with
344 \&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One a
345 stripped binary which will occupy less space in RAM and in a
346 distribution and the second a debugging information file which is only
347 needed if debugging abilities are required. The suggested procedure
348 to create these files is as follows:
349 .RS 4
350 .IP 1. 4
351 Link the executable as normal. Assuming that it is called \f(CW\*(C`foo\*(C'\fR
352 then...
353 .IP 2. 4
354 Run \f(CW\*(C`objcopy \-\-only\-keep\-debug foo foo.dbg\*(C'\fR to create a file
355 containing the debugging info.
356 .IP 3. 4
357 Run \f(CW\*(C`strip \-\-strip\-debug foo\*(C'\fR to create a stripped executable.
358 .IP 4. 4
359 Run \f(CW\*(C`objcopy \-\-add\-gnu\-debuglink=foo.dbg foo\*(C'\fR to add a link to the
360 debugging info into the stripped executable.
361 .RE
362 .RS 4
363 .Sp
364 Note\-\-\-the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info
365 file is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is
366 optional. You could instead do this:
367 .IP 1. 4
368 Link the executable as normal.
369 .IP 2. 4
370 Copy \f(CW\*(C`foo\*(C'\fR to \f(CW\*(C`foo.full\*(C'\fR.
371 .IP 3. 4
372 Run \f(CW\*(C`strip \-\-strip\-debug foo\*(C'\fR.
373 .IP 4. 4
374 Run \f(CW\*(C`objcopy \-\-add\-gnu\-debuglink=foo.full foo\*(C'\fR.
375 .RE
376 .RS 4
377 .Sp
378 i.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the
379 full executable. It does not have to be a file created by the
380 \&\fB\-\-only\-keep\-debug\fR switch.
381 .Sp
382 Note\-\-\-this switch is only intended for use on fully linked files. It
383 does not make sense to use it on object files where the debugging
384 information may be incomplete. Besides the gnu_debuglink feature
385 currently only supports the presence of one filename containing
386 debugging information, not multiple filenames on a one-per-object-file
387 basis.
388 .RE
389 .IP "\fB\-\-plugin\fR \fIname\fR" 4
390 .IX Item "--plugin name"
391 Load the plugin called \fIname\fR to add support for extra target
392 types. This option is only available if the toolchain has been built
393 with plugin support enabled.
394 .Sp
395 If \fB\-\-plugin\fR is not provided, but plugin support has been
396 enabled then \fBstrip\fR iterates over the files in
397 \&\fI${libdir}/bfd\-plugins\fR in alphabetic order and the first
398 plugin that claims the object in question is used.
399 .Sp
400 Please note that this plugin search directory is \fInot\fR the one
401 used by \fBld\fR's \fB\-plugin\fR option. In order to make
402 \&\fBstrip\fR use the linker plugin it must be copied into the
403 \&\fI${libdir}/bfd\-plugins\fR directory. For GCC based compilations
404 the linker plugin is called \fIliblto_plugin.so.0.0.0\fR. For Clang
405 based compilations it is called \fILLVMgold.so\fR. The GCC plugin
406 is always backwards compatible with earlier versions, so it is
407 sufficient to just copy the newest one.
408 .IP \fB\-V\fR 4
409 .IX Item "-V"
410 .PD 0
411 .IP \fB\-\-version\fR 4
412 .IX Item "--version"
413 .PD
414 Show the version number for \fBstrip\fR.
415 .IP \fB\-v\fR 4
416 .IX Item "-v"
417 .PD 0
418 .IP \fB\-\-verbose\fR 4
419 .IX Item "--verbose"
420 .PD
421 Verbose output: list all object files modified. In the case of
422 archives, \fBstrip \-v\fR lists all members of the archive.
423 .IP \fB@\fR\fIfile\fR 4
424 .IX Item "@file"
425 Read command-line options from \fIfile\fR. The options read are
426 inserted in place of the original @\fIfile\fR option. If \fIfile\fR
427 does not exist, or cannot be read, then the option will be treated
428 literally, and not removed.
429 .Sp
430 Options in \fIfile\fR are separated by whitespace. A whitespace
431 character may be included in an option by surrounding the entire
432 option in either single or double quotes. Any character (including a
433 backslash) may be included by prefixing the character to be included
434 with a backslash. The \fIfile\fR may itself contain additional
435 @\fIfile\fR options; any such options will be processed recursively.
436 .SH "SEE ALSO"
437 .IX Header "SEE ALSO"
438 the Info entries for \fIbinutils\fR.
439 .SH COPYRIGHT
440 .IX Header "COPYRIGHT"
441 Copyright (c) 1991\-2026 Free Software Foundation, Inc.
442 .PP
443 Permission is granted to copy, distribute and/or modify this document
444 under the terms of the GNU Free Documentation License, Version 1.3
445 or any later version published by the Free Software Foundation;
446 with no Invariant Sections, with no Front-Cover Texts, and with no
447 Back-Cover Texts. A copy of the license is included in the
448 section entitled "GNU Free Documentation License".