Debian Codegraph @

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