576 lines
14 KiB
HTML
576 lines
14 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of STRIP</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>STRIP</H1>
|
|
Section: GNU Development Tools (1)<BR>Updated: 2021-01-21<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
strip - discard symbols and other data from object files
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
strip [<B>-F</B> <I>bfdname</I> |<B>--target=</B><I>bfdname</I>]
|
|
<BR> [<B>-I</B> <I>bfdname</I> |<B>--input-target=</B><I>bfdname</I>]
|
|
<BR> [<B>-O</B> <I>bfdname</I> |<B>--output-target=</B><I>bfdname</I>]
|
|
<BR> [<B>-s</B>|<B>--strip-all</B>]
|
|
<BR> [<B>-S</B>|<B>-g</B>|<B>-d</B>|<B>--strip-debug</B>]
|
|
<BR> [<B>--strip-dwo</B>]
|
|
<BR> [<B>-K</B> <I>symbolname</I>|<B>--keep-symbol=</B><I>symbolname</I>]
|
|
<BR> [<B>-M</B>|<B>--merge-notes</B>][<B>--no-merge-notes</B>]
|
|
<BR> [<B>-N</B> <I>symbolname</I> |<B>--strip-symbol=</B><I>symbolname</I>]
|
|
<BR> [<B>-w</B>|<B>--wildcard</B>]
|
|
<BR> [<B>-x</B>|<B>--discard-all</B>] [<B>-X</B> |<B>--discard-locals</B>]
|
|
<BR> [<B>-R</B> <I>sectionname</I> |<B>--remove-section=</B><I>sectionname</I>]
|
|
<BR> [<B>--keep-section=</B><I>sectionpattern</I>]
|
|
<BR> [<B>--remove-relocations=</B><I>sectionpattern</I>]
|
|
<BR> [<B>-o</B> <I>file</I>] [<B>-p</B>|<B>--preserve-dates</B>]
|
|
<BR> [<B>-D</B>|<B>--enable-deterministic-archives</B>]
|
|
<BR> [<B>-U</B>|<B>--disable-deterministic-archives</B>]
|
|
<BR> [<B>--keep-file-symbols</B>]
|
|
<BR> [<B>--only-keep-debug</B>]
|
|
<BR> [<B>-v</B> |<B>--verbose</B>] [<B>-V</B>|<B>--version</B>]
|
|
<BR> [<B>--help</B>] [<B>--info</B>]
|
|
<BR> <I>objfile</I>...
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">GNU</FONT> <B>strip</B> discards all symbols from object files
|
|
<I>objfile</I>. The list of object files may include archives.
|
|
At least one object file must be given.
|
|
<P>
|
|
|
|
<B>strip</B> modifies the files named in its argument,
|
|
rather than writing modified copies under different names.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-F</B> <I>bfdname</I><DD>
|
|
|
|
|
|
|
|
<DT id="2"><B>--target=</B><I>bfdname</I><DD>
|
|
|
|
|
|
|
|
Treat the original <I>objfile</I> as a file with the object
|
|
code format <I>bfdname</I>, and rewrite it in the same format.
|
|
<DT id="3"><B>--help</B><DD>
|
|
|
|
|
|
Show a summary of the options to <B>strip</B> and exit.
|
|
<DT id="4"><B>--info</B><DD>
|
|
|
|
|
|
Display a list showing all architectures and object formats available.
|
|
<DT id="5"><B>-I</B> <I>bfdname</I><DD>
|
|
|
|
|
|
|
|
<DT id="6"><B>--input-target=</B><I>bfdname</I><DD>
|
|
|
|
|
|
|
|
Treat the original <I>objfile</I> as a file with the object
|
|
code format <I>bfdname</I>.
|
|
<DT id="7"><B>-O</B> <I>bfdname</I><DD>
|
|
|
|
|
|
|
|
<DT id="8"><B>--output-target=</B><I>bfdname</I><DD>
|
|
|
|
|
|
|
|
Replace <I>objfile</I> with a file in the output format <I>bfdname</I>.
|
|
<DT id="9"><B>-R</B> <I>sectionname</I><DD>
|
|
|
|
|
|
|
|
<DT id="10"><B>--remove-section=</B><I>sectionname</I><DD>
|
|
|
|
|
|
|
|
Remove any section named <I>sectionname</I> from the output file, in
|
|
addition to whatever sections would otherwise be removed. This
|
|
option may be given more than once. Note that using this option
|
|
inappropriately may make the output file unusable. The wildcard
|
|
character <B>*</B> may be given at the end of <I>sectionname</I>. If
|
|
so, then any section starting with <I>sectionname</I> will be removed.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If the first character of <I>sectionpattern</I> is the exclamation
|
|
point (!) then matching sections will not be removed even if an
|
|
earlier use of <B>--remove-section</B> on the same command line
|
|
would otherwise remove it. For example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
--remove-section=.text.* --remove-section=!.text.foo
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
will remove all sections matching the pattern '.text.*', but will not
|
|
remove the section '.text.foo'.
|
|
<DT id="11"><B>--keep-section=</B><I>sectionpattern</I><DD>
|
|
|
|
|
|
When removing sections from the output file, keep sections that match
|
|
<I>sectionpattern</I>.
|
|
<DT id="12"><B>--remove-relocations=</B><I>sectionpattern</I><DD>
|
|
|
|
|
|
Remove relocations from the output file for any section matching
|
|
<I>sectionpattern</I>. This option may be given more than once. Note
|
|
that using this option inappropriately may make the output file
|
|
unusable. Wildcard characters are accepted in <I>sectionpattern</I>.
|
|
For example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
--remove-relocations=.text.*
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
will remove the relocations for all sections matching the patter
|
|
'.text.*'.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If the first character of <I>sectionpattern</I> is the exclamation
|
|
point (!) then matching sections will not have their relocation
|
|
removed even if an earlier use of <B>--remove-relocations</B> on the
|
|
same command line would otherwise cause the relocations to be removed.
|
|
For example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
--remove-relocations=.text.* --remove-relocations=!.text.foo
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
will remove all relocations for sections matching the pattern
|
|
'.text.*', but will not remove relocations for the section
|
|
'.text.foo'.
|
|
<DT id="13"><B>-s</B><DD>
|
|
|
|
|
|
|
|
<DT id="14"><B>--strip-all</B><DD>
|
|
|
|
|
|
|
|
Remove all symbols.
|
|
<DT id="15"><B>-g</B><DD>
|
|
|
|
|
|
|
|
<DT id="16"><B>-S</B><DD>
|
|
|
|
|
|
<DT id="17"><B>-d</B><DD>
|
|
|
|
|
|
<DT id="18"><B>--strip-debug</B><DD>
|
|
|
|
|
|
|
|
Remove debugging symbols only.
|
|
<DT id="19"><B>--strip-dwo</B><DD>
|
|
|
|
|
|
Remove the contents of all <FONT SIZE="-1">DWARF</FONT> .dwo sections, leaving the
|
|
remaining debugging sections and all symbols intact.
|
|
See the description of this option in the <B>objcopy</B> section
|
|
for more information.
|
|
<DT id="20"><B>--strip-unneeded</B><DD>
|
|
|
|
|
|
Remove all symbols that are not needed for relocation processing.
|
|
<DT id="21"><B>-K</B> <I>symbolname</I><DD>
|
|
|
|
|
|
|
|
<DT id="22"><B>--keep-symbol=</B><I>symbolname</I><DD>
|
|
|
|
|
|
|
|
When stripping symbols, keep symbol <I>symbolname</I> even if it would
|
|
normally be stripped. This option may be given more than once.
|
|
<DT id="23"><B>-M</B><DD>
|
|
|
|
|
|
|
|
<DT id="24"><B>--merge-notes</B><DD>
|
|
|
|
|
|
<DT id="25"><B>--no-merge-notes</B><DD>
|
|
|
|
|
|
|
|
For <FONT SIZE="-1">ELF</FONT> files, attempt (or do not attempt) to reduce the size of any
|
|
<FONT SIZE="-1">SHT_NOTE</FONT> type sections by removing duplicate notes. The default is to
|
|
attempt this reduction unless stripping debug or <FONT SIZE="-1">DWO</FONT> information.
|
|
<DT id="26"><B>-N</B> <I>symbolname</I><DD>
|
|
|
|
|
|
|
|
<DT id="27"><B>--strip-symbol=</B><I>symbolname</I><DD>
|
|
|
|
|
|
|
|
Remove symbol <I>symbolname</I> from the source file. This option may be
|
|
given more than once, and may be combined with strip options other than
|
|
<B>-K</B>.
|
|
<DT id="28"><B>-o</B> <I>file</I><DD>
|
|
|
|
|
|
Put the stripped output in <I>file</I>, rather than replacing the
|
|
existing file. When this argument is used, only one <I>objfile</I>
|
|
argument may be specified.
|
|
<DT id="29"><B>-p</B><DD>
|
|
|
|
|
|
|
|
<DT id="30"><B>--preserve-dates</B><DD>
|
|
|
|
|
|
|
|
Preserve the access and modification dates of the file.
|
|
<DT id="31"><B>-D</B><DD>
|
|
|
|
|
|
|
|
<DT id="32"><B>--enable-deterministic-archives</B><DD>
|
|
|
|
|
|
|
|
Operate in <I>deterministic</I> mode. When copying archive members
|
|
and writing the archive index, use zero for UIDs, GIDs, timestamps,
|
|
and use consistent file modes for all files.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If <I>binutils</I> was configured with
|
|
<B>--enable-deterministic-archives</B>, then this mode is on by default.
|
|
It can be disabled with the <B>-U</B> option, below.
|
|
<DT id="33"><B>-U</B><DD>
|
|
|
|
|
|
|
|
<DT id="34"><B>--disable-deterministic-archives</B><DD>
|
|
|
|
|
|
|
|
Do <I>not</I> operate in <I>deterministic</I> mode. This is the
|
|
inverse of the <B>-D</B> option, above: when copying archive members
|
|
and writing the archive index, use their actual <FONT SIZE="-1">UID, GID,</FONT> timestamp,
|
|
and file mode values.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is the default unless <I>binutils</I> was configured with
|
|
<B>--enable-deterministic-archives</B>.
|
|
<DT id="35"><B>-w</B><DD>
|
|
|
|
|
|
|
|
<DT id="36"><B>--wildcard</B><DD>
|
|
|
|
|
|
|
|
Permit regular expressions in <I>symbolname</I>s used in other command
|
|
line options. The question mark (?), asterisk (*), backslash (\) and
|
|
square brackets ([]) operators can be used anywhere in the symbol
|
|
name. If the first character of the symbol name is the exclamation
|
|
point (!) then the sense of the switch is reversed for that symbol.
|
|
For example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
-w -K !foo -K fo*
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
would cause strip to only keep symbols that start with the letters
|
|
``fo'', but to discard the symbol ``foo''.
|
|
<DT id="37"><B>-x</B><DD>
|
|
|
|
|
|
|
|
<DT id="38"><B>--discard-all</B><DD>
|
|
|
|
|
|
|
|
Remove non-global symbols.
|
|
<DT id="39"><B>-X</B><DD>
|
|
|
|
|
|
|
|
<DT id="40"><B>--discard-locals</B><DD>
|
|
|
|
|
|
|
|
Remove compiler-generated local symbols.
|
|
(These usually start with <B>L</B> or <B>.</B>.)
|
|
<DT id="41"><B>--keep-file-symbols</B><DD>
|
|
|
|
|
|
When stripping a file, perhaps with <B>--strip-debug</B> or
|
|
<B>--strip-unneeded</B>, retain any symbols specifying source file names,
|
|
which would otherwise get stripped.
|
|
<DT id="42"><B>--only-keep-debug</B><DD>
|
|
|
|
|
|
Strip a file, emptying the contents of any sections that would not be
|
|
stripped by <B>--strip-debug</B> and leaving the debugging sections
|
|
intact. In <FONT SIZE="-1">ELF</FONT> files, this preserves all the note sections in the
|
|
output as well.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note - the section headers of the stripped sections are preserved,
|
|
including their sizes, but the contents of the section are discarded.
|
|
The section headers are preserved so that other tools can match up the
|
|
debuginfo file with the real executable, even if that executable has
|
|
been relocated to a different address space.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The intention is that this option will be used in conjunction with
|
|
<B>--add-gnu-debuglink</B> to create a two part executable. One a
|
|
stripped binary which will occupy less space in <FONT SIZE="-1">RAM</FONT> and in a
|
|
distribution and the second a debugging information file which is only
|
|
needed if debugging abilities are required. The suggested procedure
|
|
to create these files is as follows:
|
|
<DL COMPACT><DT id="43"><DD>
|
|
<DL COMPACT>
|
|
<DT id="44">1.<Link the executable as normal. Assuming that it is called><DD>
|
|
|
|
|
|
<TT>"foo"</TT> then...
|
|
<DT id="45">1.<Run "objcopy --only-keep-debug foo foo.dbg" to><DD>
|
|
|
|
|
|
|
|
|
|
create a file containing the debugging info.
|
|
<DT id="46">1.<Run "objcopy --strip-debug foo" to create a><DD>
|
|
|
|
|
|
|
|
|
|
stripped executable.
|
|
<DT id="47">1.<Run "objcopy --add-gnu-debuglink=foo.dbg foo"><DD>
|
|
|
|
|
|
|
|
|
|
to add a link to the debugging info into the stripped executable.
|
|
</DL>
|
|
</DL>
|
|
|
|
<DL COMPACT><DT id="48"><DD>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note---the choice of <TT>".dbg"</TT> as an extension for the debug info
|
|
file is arbitrary. Also the <TT>"--only-keep-debug"</TT> step is
|
|
optional. You could instead do this:
|
|
<DL COMPACT>
|
|
<DT id="49">1.<Link the executable as normal.><DD>
|
|
|
|
|
|
|
|
<DT id="50">1.<Copy "foo" to "foo.full"><DD>
|
|
|
|
|
|
|
|
|
|
<DT id="51">1.<Run "strip --strip-debug foo"><DD>
|
|
|
|
|
|
|
|
|
|
<DT id="52">1.<Run "objcopy --add-gnu-debuglink=foo.full foo"><DD>
|
|
|
|
|
|
|
|
|
|
</DL>
|
|
</DL>
|
|
|
|
<DL COMPACT><DT id="53"><DD>
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
i.e., the file pointed to by the <B>--add-gnu-debuglink</B> can be the
|
|
full executable. It does not have to be a file created by the
|
|
<B>--only-keep-debug</B> switch.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note---this switch is only intended for use on fully linked files. It
|
|
does not make sense to use it on object files where the debugging
|
|
information may be incomplete. Besides the gnu_debuglink feature
|
|
currently only supports the presence of one filename containing
|
|
debugging information, not multiple filenames on a one-per-object-file
|
|
basis.
|
|
</DL>
|
|
|
|
<DT id="54"><B>-V</B><DD>
|
|
|
|
|
|
|
|
<DT id="55"><B>--version</B><DD>
|
|
|
|
|
|
|
|
Show the version number for <B>strip</B>.
|
|
<DT id="56"><B>-v</B><DD>
|
|
|
|
|
|
|
|
<DT id="57"><B>--verbose</B><DD>
|
|
|
|
|
|
|
|
Verbose output: list all object files modified. In the case of
|
|
archives, <B>strip -v</B> lists all members of the archive.
|
|
<DT id="58"><B>@</B><I>file</I><DD>
|
|
|
|
|
|
Read command-line options from <I>file</I>. The options read are
|
|
inserted in place of the original @<I>file</I> option. If <I>file</I>
|
|
does not exist, or cannot be read, then the option will be treated
|
|
literally, and not removed.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Options in <I>file</I> are separated by whitespace. A whitespace
|
|
character may be included in an option by surrounding the entire
|
|
option in either single or double quotes. Any character (including a
|
|
backslash) may be included by prefixing the character to be included
|
|
with a backslash. The <I>file</I> may itself contain additional
|
|
@<I>file</I> options; any such options will be processed recursively.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
the Info entries for <I>binutils</I>.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (c) 1991-2020 Free Software Foundation, Inc.
|
|
<P>
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the <FONT SIZE="-1">GNU</FONT> Free Documentation License, Version 1.3
|
|
or any later version published by the Free Software Foundation;
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
Back-Cover Texts. A copy of the license is included in the
|
|
section entitled ``<FONT SIZE="-1">GNU</FONT> Free Documentation License''.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="59"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="60"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="61"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="62"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="63"><A HREF="#lbAF">SEE ALSO</A><DD>
|
|
<DT id="64"><A HREF="#lbAG">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:27 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|