1STRIP(1)                     GNU Development Tools                    STRIP(1)
2
3
4

NAME

6       strip - discard symbols and other data from object files
7

SYNOPSIS

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             [-o file] [-p|--preserve-dates]
24             [-D|--enable-deterministic-archives]
25             [-U|--disable-deterministic-archives]
26             [--keep-section-symbols]
27             [--keep-file-symbols]
28             [--only-keep-debug]
29             [-v |--verbose] [-V|--version]
30             [--help] [--info]
31             objfile...
32

DESCRIPTION

34       GNU strip discards all symbols from object files objfile.  The list of
35       object files may include archives.  At least one object file must be
36       given.
37
38       strip modifies the files named in its argument, rather than writing
39       modified copies under different names.
40

OPTIONS

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

SEE ALSO

287       the Info entries for binutils.
288
290       Copyright (c) 1991-2022 Free Software Foundation, Inc.
291
292       Permission is granted to copy, distribute and/or modify this document
293       under the terms of the GNU Free Documentation License, Version 1.3 or
294       any later version published by the Free Software Foundation; with no
295       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
296       Texts.  A copy of the license is included in the section entitled "GNU
297       Free Documentation License".
298
299
300
301binutils-2.38                     2022-12-30                          STRIP(1)
Impressum