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-file-symbols]
27             [--only-keep-debug]
28             [-v |--verbose] [-V|--version]
29             [--help] [--info]
30             objfile...
31

DESCRIPTION

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

OPTIONS

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

SEE ALSO

279       the Info entries for binutils.
280
282       Copyright (c) 1991-2020 Free Software Foundation, Inc.
283
284       Permission is granted to copy, distribute and/or modify this document
285       under the terms of the GNU Free Documentation License, Version 1.3 or
286       any later version published by the Free Software Foundation; with no
287       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
288       Texts.  A copy of the license is included in the section entitled "GNU
289       Free Documentation License".
290
291
292
293binutils-2.34                     2021-01-28                          STRIP(1)
Impressum