191 lines
		
	
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			191 lines
		
	
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
								 | 
							
								<html lang="en">
							 | 
						||
| 
								 | 
							
								<head>
							 | 
						||
| 
								 | 
							
								<title>strip - GNU Binary Utilities</title>
							 | 
						||
| 
								 | 
							
								<meta http-equiv="Content-Type" content="text/html">
							 | 
						||
| 
								 | 
							
								<meta name="description" content="GNU Binary Utilities">
							 | 
						||
| 
								 | 
							
								<meta name="generator" content="makeinfo 4.7">
							 | 
						||
| 
								 | 
							
								<link title="Top" rel="start" href="index.html#Top">
							 | 
						||
| 
								 | 
							
								<link rel="prev" href="strings.html#strings" title="strings">
							 | 
						||
| 
								 | 
							
								<link rel="next" href="c_002b_002bfilt.html#c_002b_002bfilt" title="c++filt">
							 | 
						||
| 
								 | 
							
								<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
							 | 
						||
| 
								 | 
							
								<!--
							 | 
						||
| 
								 | 
							
								Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
							 | 
						||
| 
								 | 
							
								2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 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.2
							 | 
						||
| 
								 | 
							
								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''.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								man end-->
							 | 
						||
| 
								 | 
							
								<meta http-equiv="Content-Style-Type" content="text/css">
							 | 
						||
| 
								 | 
							
								<style type="text/css"><!--
							 | 
						||
| 
								 | 
							
								  pre.display { font-family:inherit }
							 | 
						||
| 
								 | 
							
								  pre.format  { font-family:inherit }
							 | 
						||
| 
								 | 
							
								  pre.smalldisplay { font-family:inherit; font-size:smaller }
							 | 
						||
| 
								 | 
							
								  pre.smallformat  { font-family:inherit; font-size:smaller }
							 | 
						||
| 
								 | 
							
								  pre.smallexample { font-size:smaller }
							 | 
						||
| 
								 | 
							
								  pre.smalllisp    { font-size:smaller }
							 | 
						||
| 
								 | 
							
								  span.sc { font-variant:small-caps }
							 | 
						||
| 
								 | 
							
								  span.roman { font-family: serif; font-weight: normal; } 
							 | 
						||
| 
								 | 
							
								--></style>
							 | 
						||
| 
								 | 
							
								</head>
							 | 
						||
| 
								 | 
							
								<body>
							 | 
						||
| 
								 | 
							
								<div class="node">
							 | 
						||
| 
								 | 
							
								<p>
							 | 
						||
| 
								 | 
							
								<a name="strip"></a>Next: <a rel="next" accesskey="n" href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>,
							 | 
						||
| 
								 | 
							
								Previous: <a rel="previous" accesskey="p" href="strings.html#strings">strings</a>,
							 | 
						||
| 
								 | 
							
								Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
							 | 
						||
| 
								 | 
							
								<hr><br>
							 | 
						||
| 
								 | 
							
								</div>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<h2 class="chapter">8 strip</h2>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<p><a name="index-strip-111"></a><a name="index-removing-symbols-112"></a><a name="index-discarding-symbols-113"></a><a name="index-symbols_002c-discarding-114"></a>
							 | 
						||
| 
								 | 
							
								<!-- man title strip Discard symbols from object files. -->
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<pre class="smallexample">     <!-- man begin SYNOPSIS strip -->
							 | 
						||
| 
								 | 
							
								     strip [<span class="option">-F</span> <var>bfdname</var> |<span class="option">--target=</span><var>bfdname</var>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-I</span> <var>bfdname</var> |<span class="option">--input-target=</span><var>bfdname</var>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-O</span> <var>bfdname</var> |<span class="option">--output-target=</span><var>bfdname</var>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-s</span>|<span class="option">--strip-all</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-S</span>|<span class="option">-g</span>|<span class="option">-d</span>|<span class="option">--strip-debug</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-K</span> <var>symbolname</var> |<span class="option">--keep-symbol=</span><var>symbolname</var>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-N</span> <var>symbolname</var> |<span class="option">--strip-symbol=</span><var>symbolname</var>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-w</span>|<span class="option">--wildcard</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-x</span>|<span class="option">--discard-all</span>] [<span class="option">-X</span> |<span class="option">--discard-locals</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-R</span> <var>sectionname</var> |<span class="option">--remove-section=</span><var>sectionname</var>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-o</span> <var>file</var>] [<span class="option">-p</span>|<span class="option">--preserve-dates</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">--keep-file-symbols</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">--only-keep-debug</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">-v</span> |<span class="option">--verbose</span>] [<span class="option">-V</span>|<span class="option">--version</span>]
							 | 
						||
| 
								 | 
							
								           [<span class="option">--help</span>] [<span class="option">--info</span>]
							 | 
						||
| 
								 | 
							
								           <var>objfile</var>...
							 | 
						||
| 
								 | 
							
								     <!-- man end -->
							 | 
						||
| 
								 | 
							
								</pre>
							 | 
						||
| 
								 | 
							
								   <!-- man begin DESCRIPTION strip -->
							 | 
						||
| 
								 | 
							
								<p><span class="sc">gnu</span> <span class="command">strip</span> 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><span class="command">strip</span> modifies the files named in its argument,
							 | 
						||
| 
								 | 
							
								rather than writing modified copies under different names.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<!-- man end -->
							 | 
						||
| 
								 | 
							
								<!-- man begin OPTIONS strip -->
							 | 
						||
| 
								 | 
							
								<dl>
							 | 
						||
| 
								 | 
							
								<dt><span class="env">-F </span><var>bfdname</var><dt><span class="env">--target=</span><var>bfdname</var><dd>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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">--help</span><dd>Show a summary of the options to <span class="command">strip</span> and exit.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">--info</span><dd>Display a list showing all architectures and object formats available.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-I </span><var>bfdname</var><dt><span class="env">--input-target=</span><var>bfdname</var><dd>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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-O </span><var>bfdname</var><dt><span class="env">--output-target=</span><var>bfdname</var><dd>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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-R </span><var>sectionname</var><dt><span class="env">--remove-section=</span><var>sectionname</var><dd>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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-s</span><dt><span class="env">--strip-all</span><dd>Remove all symbols.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-g</span><dt><span class="env">-S</span><dt><span class="env">-d</span><dt><span class="env">--strip-debug</span><dd>Remove debugging symbols only.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">--strip-unneeded</span><dd>Remove all symbols that are not needed for relocation processing.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-K </span><var>symbolname</var><dt><span class="env">--keep-symbol=</span><var>symbolname</var><dd>When stripping symbols, keep symbol <var>symbolname</var> even if it would
							 | 
						||
| 
								 | 
							
								normally be stripped.  This option may be given more than once.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-N </span><var>symbolname</var><dt><span class="env">--strip-symbol=</span><var>symbolname</var><dd>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
							 | 
						||
| 
								 | 
							
								<span class="option">-K</span>.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-o </span><var>file</var><dd>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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-p</span><dt><span class="env">--preserve-dates</span><dd>Preserve the access and modification dates of the file.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-w</span><dt><span class="env">--wildcard</span><dd>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:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <pre class="smallexample">            -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”.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-x</span><dt><span class="env">--discard-all</span><dd>Remove non-global symbols.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-X</span><dt><span class="env">--discard-locals</span><dd>Remove compiler-generated local symbols. 
							 | 
						||
| 
								 | 
							
								(These usually start with <span class="samp">L</span> or <span class="samp">.</span>.)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">--keep-file-symbols</span><dd>When stripping a file, perhaps with <span class="option">--strip-debug</span> or
							 | 
						||
| 
								 | 
							
								<span class="option">--strip-unneeded</span>, retain any symbols specifying source file names,
							 | 
						||
| 
								 | 
							
								which would otherwise get stripped.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">--only-keep-debug</span><dd>Strip a file, removing contents of any sections that would not be
							 | 
						||
| 
								 | 
							
								stripped by <span class="option">--strip-debug</span> and leaving the debugging sections
							 | 
						||
| 
								 | 
							
								intact.  In ELF files, this preserves all note sections in the output.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <p>The intention is that this option will be used in conjunction with
							 | 
						||
| 
								 | 
							
								<span class="option">--add-gnu-debuglink</span> 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:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								          <ol type=1 start=1>
							 | 
						||
| 
								 | 
							
								<li>Link the executable as normal.  Assuming that is is called
							 | 
						||
| 
								 | 
							
								<code>foo</code> then... 
							 | 
						||
| 
								 | 
							
								<li>Run <code>objcopy --only-keep-debug foo foo.dbg</code> to
							 | 
						||
| 
								 | 
							
								create a file containing the debugging info. 
							 | 
						||
| 
								 | 
							
								<li>Run <code>objcopy --strip-debug foo</code> to create a
							 | 
						||
| 
								 | 
							
								stripped executable. 
							 | 
						||
| 
								 | 
							
								<li>Run <code>objcopy --add-gnu-debuglink=foo.dbg foo</code>
							 | 
						||
| 
								 | 
							
								to add a link to the debugging info into the stripped executable.
							 | 
						||
| 
								 | 
							
								          </ol>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <p>Note—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:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								          <ol type=1 start=1>
							 | 
						||
| 
								 | 
							
								<li>Link the executable as normal. 
							 | 
						||
| 
								 | 
							
								<li>Copy <code>foo</code> to <code>foo.full</code>
							 | 
						||
| 
								 | 
							
								<li>Run <code>strip --strip-debug foo</code>
							 | 
						||
| 
								 | 
							
								<li>Run <code>objcopy --add-gnu-debuglink=foo.full foo</code>
							 | 
						||
| 
								 | 
							
								          </ol>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <p>i.e., the file pointed to by the <span class="option">--add-gnu-debuglink</span> can be the
							 | 
						||
| 
								 | 
							
								full executable.  It does not have to be a file created by the
							 | 
						||
| 
								 | 
							
								<span class="option">--only-keep-debug</span> 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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-V</span><dt><span class="env">--version</span><dd>Show the version number for <span class="command">strip</span>.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="env">-v</span><dt><span class="env">--verbose</span><dd>Verbose output: list all object files modified.  In the case of
							 | 
						||
| 
								 | 
							
								archives, <span class="samp">strip -v</span> lists all members of the archive. 
							 | 
						||
| 
								 | 
							
								</dl>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<!-- man end -->
							 | 
						||
| 
								 | 
							
								</body></html>
							 | 
						||
| 
								 | 
							
								
							 |