• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/binutils.html/
1<html lang="en">
2<head>
3<title>strip - GNU Binary Utilities</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="GNU Binary Utilities">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="prev" href="strings.html#strings" title="strings">
9<link rel="next" href="elfedit.html#elfedit" title="elfedit">
10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
11<!--
12Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
132000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
14Free Software Foundation, Inc.
15
16Permission is granted to copy, distribute and/or modify this document
17under the terms of the GNU Free Documentation License, Version 1.3
18or any later version published by the Free Software Foundation;
19with no Invariant Sections, with no Front-Cover Texts, and with no
20Back-Cover Texts.  A copy of the license is included in the
21section entitled ``GNU Free Documentation License''.
22
23-->
24<meta http-equiv="Content-Style-Type" content="text/css">
25<style type="text/css"><!--
26  pre.display { font-family:inherit }
27  pre.format  { font-family:inherit }
28  pre.smalldisplay { font-family:inherit; font-size:smaller }
29  pre.smallformat  { font-family:inherit; font-size:smaller }
30  pre.smallexample { font-size:smaller }
31  pre.smalllisp    { font-size:smaller }
32  span.sc    { font-variant:small-caps }
33  span.roman { font-family:serif; font-weight:normal; } 
34  span.sansserif { font-family:sans-serif; font-weight:normal; } 
35--></style>
36<link rel="stylesheet" type="text/css" href="../cs.css">
37</head>
38<body>
39<div class="node">
40<a name="strip"></a>
41<p>
42Next:&nbsp;<a rel="next" accesskey="n" href="elfedit.html#elfedit">elfedit</a>,
43Previous:&nbsp;<a rel="previous" accesskey="p" href="strings.html#strings">strings</a>,
44Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
45<hr>
46</div>
47
48<h2 class="chapter">8 strip</h2>
49
50<p><a name="index-strip-117"></a><a name="index-removing-symbols-118"></a><a name="index-discarding-symbols-119"></a><a name="index-symbols_002c-discarding-120"></a>
51<!-- man title strip Discard symbols from object files. -->
52
53<pre class="smallexample">     <!-- man begin SYNOPSIS strip -->
54     strip [<samp><span class="option">-F</span></samp> <var>bfdname</var> |<samp><span class="option">--target=</span></samp><var>bfdname</var>]
55           [<samp><span class="option">-I</span></samp> <var>bfdname</var> |<samp><span class="option">--input-target=</span></samp><var>bfdname</var>]
56           [<samp><span class="option">-O</span></samp> <var>bfdname</var> |<samp><span class="option">--output-target=</span></samp><var>bfdname</var>]
57           [<samp><span class="option">-s</span></samp>|<samp><span class="option">--strip-all</span></samp>]
58           [<samp><span class="option">-S</span></samp>|<samp><span class="option">-g</span></samp>|<samp><span class="option">-d</span></samp>|<samp><span class="option">--strip-debug</span></samp>]
59           [<samp><span class="option">-K</span></samp> <var>symbolname</var> |<samp><span class="option">--keep-symbol=</span></samp><var>symbolname</var>]
60           [<samp><span class="option">-N</span></samp> <var>symbolname</var> |<samp><span class="option">--strip-symbol=</span></samp><var>symbolname</var>]
61           [<samp><span class="option">-w</span></samp>|<samp><span class="option">--wildcard</span></samp>]
62           [<samp><span class="option">-x</span></samp>|<samp><span class="option">--discard-all</span></samp>] [<samp><span class="option">-X</span></samp> |<samp><span class="option">--discard-locals</span></samp>]
63           [<samp><span class="option">-R</span></samp> <var>sectionname</var> |<samp><span class="option">--remove-section=</span></samp><var>sectionname</var>]
64           [<samp><span class="option">-o</span></samp> <var>file</var>] [<samp><span class="option">-p</span></samp>|<samp><span class="option">--preserve-dates</span></samp>]
65           [<samp><span class="option">--keep-file-symbols</span></samp>]
66           [<samp><span class="option">--only-keep-debug</span></samp>]
67           [<samp><span class="option">-v</span></samp> |<samp><span class="option">--verbose</span></samp>] [<samp><span class="option">-V</span></samp>|<samp><span class="option">--version</span></samp>]
68           [<samp><span class="option">--help</span></samp>] [<samp><span class="option">--info</span></samp>]
69           <var>objfile</var>...
70     <!-- man end -->
71</pre>
72   <!-- man begin DESCRIPTION strip -->
73   <p><span class="sc">gnu</span> <samp><span class="command">strip</span></samp> discards all symbols from object files
74<var>objfile</var>.  The list of object files may include archives. 
75At least one object file must be given.
76
77   <p><samp><span class="command">strip</span></samp> modifies the files named in its argument,
78rather than writing modified copies under different names.
79
80<!-- man end -->
81<!-- man begin OPTIONS strip -->
82     <dl>
83<dt><samp><span class="env">-F </span><var>bfdname</var></samp><dt><samp><span class="env">--target=</span><var>bfdname</var></samp><dd>Treat the original <var>objfile</var> as a file with the object
84code format <var>bfdname</var>, and rewrite it in the same format. 
85See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
86
87     <br><dt><samp><span class="env">--help</span></samp><dd>Show a summary of the options to <samp><span class="command">strip</span></samp> and exit.
88
89     <br><dt><samp><span class="env">--info</span></samp><dd>Display a list showing all architectures and object formats available.
90
91     <br><dt><samp><span class="env">-I </span><var>bfdname</var></samp><dt><samp><span class="env">--input-target=</span><var>bfdname</var></samp><dd>Treat the original <var>objfile</var> as a file with the object
92code format <var>bfdname</var>. 
93See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
94
95     <br><dt><samp><span class="env">-O </span><var>bfdname</var></samp><dt><samp><span class="env">--output-target=</span><var>bfdname</var></samp><dd>Replace <var>objfile</var> with a file in the output format <var>bfdname</var>. 
96See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
97
98     <br><dt><samp><span class="env">-R </span><var>sectionname</var></samp><dt><samp><span class="env">--remove-section=</span><var>sectionname</var></samp><dd>Remove any section named <var>sectionname</var> from the output file.  This
99option may be given more than once.  Note that using this option
100inappropriately may make the output file unusable.
101
102     <br><dt><samp><span class="env">-s</span></samp><dt><samp><span class="env">--strip-all</span></samp><dd>Remove all symbols.
103
104     <br><dt><samp><span class="env">-g</span></samp><dt><samp><span class="env">-S</span></samp><dt><samp><span class="env">-d</span></samp><dt><samp><span class="env">--strip-debug</span></samp><dd>Remove debugging symbols only.
105
106     <br><dt><samp><span class="env">--strip-unneeded</span></samp><dd>Remove all symbols that are not needed for relocation processing.
107
108     <br><dt><samp><span class="env">-K </span><var>symbolname</var></samp><dt><samp><span class="env">--keep-symbol=</span><var>symbolname</var></samp><dd>When stripping symbols, keep symbol <var>symbolname</var> even if it would
109normally be stripped.  This option may be given more than once.
110
111     <br><dt><samp><span class="env">-N </span><var>symbolname</var></samp><dt><samp><span class="env">--strip-symbol=</span><var>symbolname</var></samp><dd>Remove symbol <var>symbolname</var> from the source file. This option may be
112given more than once, and may be combined with strip options other than
113<samp><span class="option">-K</span></samp>.
114
115     <br><dt><samp><span class="env">-o </span><var>file</var></samp><dd>Put the stripped output in <var>file</var>, rather than replacing the
116existing file.  When this argument is used, only one <var>objfile</var>
117argument may be specified.
118
119     <br><dt><samp><span class="env">-p</span></samp><dt><samp><span class="env">--preserve-dates</span></samp><dd>Preserve the access and modification dates of the file.
120
121     <br><dt><samp><span class="env">-w</span></samp><dt><samp><span class="env">--wildcard</span></samp><dd>Permit regular expressions in <var>symbolname</var>s used in other command
122line options.  The question mark (?), asterisk (*), backslash (\) and
123square brackets ([]) operators can be used anywhere in the symbol
124name.  If the first character of the symbol name is the exclamation
125point (!) then the sense of the switch is reversed for that symbol. 
126For example:
127
128     <pre class="smallexample">            -w -K !foo -K fo*
129</pre>
130     <p>would cause strip to only keep symbols that start with the letters
131&ldquo;fo&rdquo;, but to discard the symbol &ldquo;foo&rdquo;.
132
133     <br><dt><samp><span class="env">-x</span></samp><dt><samp><span class="env">--discard-all</span></samp><dd>Remove non-global symbols.
134
135     <br><dt><samp><span class="env">-X</span></samp><dt><samp><span class="env">--discard-locals</span></samp><dd>Remove compiler-generated local symbols. 
136(These usually start with &lsquo;<samp><span class="samp">L</span></samp>&rsquo; or &lsquo;<samp><span class="samp">.</span></samp>&rsquo;.)
137
138     <br><dt><samp><span class="env">--keep-file-symbols</span></samp><dd>When stripping a file, perhaps with <samp><span class="option">--strip-debug</span></samp> or
139<samp><span class="option">--strip-unneeded</span></samp>, retain any symbols specifying source file names,
140which would otherwise get stripped.
141
142     <br><dt><samp><span class="env">--only-keep-debug</span></samp><dd>Strip a file, removing contents of any sections that would not be
143stripped by <samp><span class="option">--strip-debug</span></samp> and leaving the debugging sections
144intact.  In ELF files, this preserves all note sections in the output.
145
146     <p>The intention is that this option will be used in conjunction with
147<samp><span class="option">--add-gnu-debuglink</span></samp> to create a two part executable.  One a
148stripped binary which will occupy less space in RAM and in a
149distribution and the second a debugging information file which is only
150needed if debugging abilities are required.  The suggested procedure
151to create these files is as follows:
152
153          <ol type=1 start=1>
154<li>Link the executable as normal.  Assuming that is is called
155<code>foo</code> then... 
156<li>Run <code>objcopy --only-keep-debug foo foo.dbg</code> to
157create a file containing the debugging info. 
158<li>Run <code>objcopy --strip-debug foo</code> to create a
159stripped executable. 
160<li>Run <code>objcopy --add-gnu-debuglink=foo.dbg foo</code>
161to add a link to the debugging info into the stripped executable.
162          </ol>
163
164     <p>Note&mdash;the choice of <code>.dbg</code> as an extension for the debug info
165file is arbitrary.  Also the <code>--only-keep-debug</code> step is
166optional.  You could instead do this:
167
168          <ol type=1 start=1>
169<li>Link the executable as normal. 
170<li>Copy <code>foo</code> to <code>foo.full</code>
171<li>Run <code>strip --strip-debug foo</code>
172<li>Run <code>objcopy --add-gnu-debuglink=foo.full foo</code>
173          </ol>
174
175     <p>i.e., the file pointed to by the <samp><span class="option">--add-gnu-debuglink</span></samp> can be the
176full executable.  It does not have to be a file created by the
177<samp><span class="option">--only-keep-debug</span></samp> switch.
178
179     <p>Note&mdash;this switch is only intended for use on fully linked files.  It
180does not make sense to use it on object files where the debugging
181information may be incomplete.  Besides the gnu_debuglink feature
182currently only supports the presence of one filename containing
183debugging information, not multiple filenames on a one-per-object-file
184basis.
185
186     <br><dt><samp><span class="env">-V</span></samp><dt><samp><span class="env">--version</span></samp><dd>Show the version number for <samp><span class="command">strip</span></samp>.
187
188     <br><dt><samp><span class="env">-v</span></samp><dt><samp><span class="env">--verbose</span></samp><dd>Verbose output: list all object files modified.  In the case of
189archives, &lsquo;<samp><span class="samp">strip -v</span></samp>&rsquo; lists all members of the archive. 
190</dl>
191
192<!-- man end -->
193   </body></html>
194
195