Debian Codegraph @

upstream/fedora-44/man1/strip.1

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