blob: 4e6002f76296a15887eb428880bd90129f89045d [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1991-2013 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU 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 "GNU Free Documentation License".
-->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Binary Utilities: strip</title>
<meta name="description" content="GNU Binary Utilities: strip">
<meta name="keywords" content="GNU Binary Utilities: strip">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="index.html#Top" rel="up" title="Top">
<link href="c_002b_002bfilt.html#c_002b_002bfilt" rel="next" title="c++filt">
<link href="strings.html#strings" rel="prev" title="strings">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="strip"></a>
<div class="header">
<p>
Next: <a href="c_002b_002bfilt.html#c_002b_002bfilt" accesskey="n" rel="next">c++filt</a>, Previous: <a href="strings.html#strings" accesskey="p" rel="prev">strings</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="strip-1"></a>
<h2 class="chapter">8 strip</h2>
<a name="index-strip"></a>
<a name="index-removing-symbols"></a>
<a name="index-discarding-symbols"></a>
<a name="index-symbols_002c-discarding"></a>
<div class="smallexample">
<pre class="smallexample">strip [<samp>-F</samp> <var>bfdname</var> |<samp>--target=</samp><var>bfdname</var>]
[<samp>-I</samp> <var>bfdname</var> |<samp>--input-target=</samp><var>bfdname</var>]
[<samp>-O</samp> <var>bfdname</var> |<samp>--output-target=</samp><var>bfdname</var>]
[<samp>-s</samp>|<samp>--strip-all</samp>]
[<samp>-S</samp>|<samp>-g</samp>|<samp>-d</samp>|<samp>--strip-debug</samp>]
[<samp>--strip-dwo</samp>]
[<samp>-K</samp> <var>symbolname</var> |<samp>--keep-symbol=</samp><var>symbolname</var>]
[<samp>-N</samp> <var>symbolname</var> |<samp>--strip-symbol=</samp><var>symbolname</var>]
[<samp>-w</samp>|<samp>--wildcard</samp>]
[<samp>-x</samp>|<samp>--discard-all</samp>] [<samp>-X</samp> |<samp>--discard-locals</samp>]
[<samp>-R</samp> <var>sectionname</var> |<samp>--remove-section=</samp><var>sectionname</var>]
[<samp>-o</samp> <var>file</var>] [<samp>-p</samp>|<samp>--preserve-dates</samp>]
[<samp>-D</samp>|<samp>--enable-deterministic-archives</samp>]
[<samp>-U</samp>|<samp>--disable-deterministic-archives</samp>]
[<samp>--keep-file-symbols</samp>]
[<samp>--only-keep-debug</samp>]
[<samp>-v</samp> |<samp>--verbose</samp>] [<samp>-V</samp>|<samp>--version</samp>]
[<samp>--help</samp>] [<samp>--info</samp>]
<var>objfile</var>&hellip;
</pre></div>
<p><small>GNU</small> <code>strip</code> discards all symbols from object files
<var>objfile</var>. The list of object files may include archives.
At least one object file must be given.
</p>
<p><code>strip</code> modifies the files named in its argument,
rather than writing modified copies under different names.
</p>
<dl compact="compact">
<dt><code>-F <var>bfdname</var></code></dt>
<dt><code>--target=<var>bfdname</var></code></dt>
<dd><p>Treat the original <var>objfile</var> as a file with the object
code format <var>bfdname</var>, and rewrite it in the same format.
See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
</p>
</dd>
<dt><code>--help</code></dt>
<dd><p>Show a summary of the options to <code>strip</code> and exit.
</p>
</dd>
<dt><code>--info</code></dt>
<dd><p>Display a list showing all architectures and object formats available.
</p>
</dd>
<dt><code>-I <var>bfdname</var></code></dt>
<dt><code>--input-target=<var>bfdname</var></code></dt>
<dd><p>Treat the original <var>objfile</var> as a file with the object
code format <var>bfdname</var>.
See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
</p>
</dd>
<dt><code>-O <var>bfdname</var></code></dt>
<dt><code>--output-target=<var>bfdname</var></code></dt>
<dd><p>Replace <var>objfile</var> with a file in the output format <var>bfdname</var>.
See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
</p>
</dd>
<dt><code>-R <var>sectionname</var></code></dt>
<dt><code>--remove-section=<var>sectionname</var></code></dt>
<dd><p>Remove any section named <var>sectionname</var> from the output file. This
option may be given more than once. Note that using this option
inappropriately may make the output file unusable. The wildcard
character &lsquo;<samp>*</samp>&rsquo; may be given at the end of <var>sectionname</var>. If
so, then any section starting with <var>sectionname</var> will be removed.
</p>
</dd>
<dt><code>-s</code></dt>
<dt><code>--strip-all</code></dt>
<dd><p>Remove all symbols.
</p>
</dd>
<dt><code>-g</code></dt>
<dt><code>-S</code></dt>
<dt><code>-d</code></dt>
<dt><code>--strip-debug</code></dt>
<dd><p>Remove debugging symbols only.
</p>
</dd>
<dt><code>--strip-dwo</code></dt>
<dd><p>Remove the contents of all DWARF .dwo sections, leaving the
remaining debugging sections and all symbols intact.
See the description of this option in the <code>objcopy</code> section
for more information.
</p>
</dd>
<dt><code>--strip-unneeded</code></dt>
<dd><p>Remove all symbols that are not needed for relocation processing.
</p>
</dd>
<dt><code>-K <var>symbolname</var></code></dt>
<dt><code>--keep-symbol=<var>symbolname</var></code></dt>
<dd><p>When stripping symbols, keep symbol <var>symbolname</var> even if it would
normally be stripped. This option may be given more than once.
</p>
</dd>
<dt><code>-N <var>symbolname</var></code></dt>
<dt><code>--strip-symbol=<var>symbolname</var></code></dt>
<dd><p>Remove symbol <var>symbolname</var> from the source file. This option may be
given more than once, and may be combined with strip options other than
<samp>-K</samp>.
</p>
</dd>
<dt><code>-o <var>file</var></code></dt>
<dd><p>Put the stripped output in <var>file</var>, rather than replacing the
existing file. When this argument is used, only one <var>objfile</var>
argument may be specified.
</p>
</dd>
<dt><code>-p</code></dt>
<dt><code>--preserve-dates</code></dt>
<dd><p>Preserve the access and modification dates of the file.
</p>
</dd>
<dt><code>-D</code></dt>
<dt><code>--enable-deterministic-archives</code></dt>
<dd><a name="index-deterministic-archives-6"></a>
<a name="index-_002d_002denable_002ddeterministic_002darchives-6"></a>
<p>Operate in <em>deterministic</em> 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>
<p>If <samp>binutils</samp> was configured with
<samp>--enable-deterministic-archives</samp>, then this mode is on by default.
It can be disabled with the &lsquo;<samp>-U</samp>&rsquo; option, below.
</p>
</dd>
<dt><code>-U</code></dt>
<dt><code>--disable-deterministic-archives</code></dt>
<dd><a name="index-deterministic-archives-7"></a>
<a name="index-_002d_002denable_002ddeterministic_002darchives-7"></a>
<p>Do <em>not</em> operate in <em>deterministic</em> mode. This is the
inverse of the <samp>-D</samp> option, above: when copying archive members
and writing the archive index, use their actual UID, GID, timestamp,
and file mode values.
</p>
<p>This is the default unless <samp>binutils</samp> was configured with
<samp>--enable-deterministic-archives</samp>.
</p>
</dd>
<dt><code>-w</code></dt>
<dt><code>--wildcard</code></dt>
<dd><p>Permit regular expressions in <var>symbolname</var>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>
<div class="smallexample">
<pre class="smallexample"> -w -K !foo -K fo*
</pre></div>
<p>would cause strip to only keep symbols that start with the letters
&ldquo;fo&rdquo;, but to discard the symbol &ldquo;foo&rdquo;.
</p>
</dd>
<dt><code>-x</code></dt>
<dt><code>--discard-all</code></dt>
<dd><p>Remove non-global symbols.
</p>
</dd>
<dt><code>-X</code></dt>
<dt><code>--discard-locals</code></dt>
<dd><p>Remove compiler-generated local symbols.
(These usually start with &lsquo;<samp>L</samp>&rsquo; or &lsquo;<samp>.</samp>&rsquo;.)
</p>
</dd>
<dt><code>--keep-file-symbols</code></dt>
<dd><p>When stripping a file, perhaps with <samp>--strip-debug</samp> or
<samp>--strip-unneeded</samp>, retain any symbols specifying source file names,
which would otherwise get stripped.
</p>
</dd>
<dt><code>--only-keep-debug</code></dt>
<dd><p>Strip a file, removing contents of any sections that would not be
stripped by <samp>--strip-debug</samp> and leaving the debugging sections
intact. In ELF files, this preserves all note sections in the output.
</p>
<p>The intention is that this option will be used in conjunction with
<samp>--add-gnu-debuglink</samp> to create a two part executable. One a
stripped binary which will occupy less space in RAM 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:
</p>
<ol>
<li> Link the executable as normal. Assuming that is is called
<code>foo</code> then...
</li><li> Run <code>objcopy --only-keep-debug foo foo.dbg</code> to
create a file containing the debugging info.
</li><li> Run <code>objcopy --strip-debug foo</code> to create a
stripped executable.
</li><li> Run <code>objcopy --add-gnu-debuglink=foo.dbg foo</code>
to add a link to the debugging info into the stripped executable.
</li></ol>
<p>Note&mdash;the choice of <code>.dbg</code> as an extension for the debug info
file is arbitrary. Also the <code>--only-keep-debug</code> step is
optional. You could instead do this:
</p>
<ol>
<li> Link the executable as normal.
</li><li> Copy <code>foo</code> to <code>foo.full</code>
</li><li> Run <code>strip --strip-debug foo</code>
</li><li> Run <code>objcopy --add-gnu-debuglink=foo.full foo</code>
</li></ol>
<p>i.e., the file pointed to by the <samp>--add-gnu-debuglink</samp> can be the
full executable. It does not have to be a file created by the
<samp>--only-keep-debug</samp> switch.
</p>
<p>Note&mdash;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.
</p>
</dd>
<dt><code>-V</code></dt>
<dt><code>--version</code></dt>
<dd><p>Show the version number for <code>strip</code>.
</p>
</dd>
<dt><code>-v</code></dt>
<dt><code>--verbose</code></dt>
<dd><p>Verbose output: list all object files modified. In the case of
archives, &lsquo;<samp>strip -v</samp>&rsquo; lists all members of the archive.
</p></dd>
</dl>
<hr>
<div class="header">
<p>
Next: <a href="c_002b_002bfilt.html#c_002b_002bfilt" accesskey="n" rel="next">c++filt</a>, Previous: <a href="strings.html#strings" accesskey="p" rel="prev">strings</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>