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="c_002b_002bfilt.html#c_002b_002bfilt" title="c++filt"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1991-2013 Free Software Foundation, Inc. 13 14Permission is granted to copy, distribute and/or modify this document 15under the terms of the GNU Free Documentation License, Version 1.3 16or any later version published by the Free Software Foundation; 17with no Invariant Sections, with no Front-Cover Texts, and with no 18Back-Cover Texts. A copy of the license is included in the 19section entitled ``GNU Free Documentation License''. 20 21--> 22<meta http-equiv="Content-Style-Type" content="text/css"> 23<style type="text/css"><!-- 24 pre.display { font-family:inherit } 25 pre.format { font-family:inherit } 26 pre.smalldisplay { font-family:inherit; font-size:smaller } 27 pre.smallformat { font-family:inherit; font-size:smaller } 28 pre.smallexample { font-size:smaller } 29 pre.smalllisp { font-size:smaller } 30 span.sc { font-variant:small-caps } 31 span.roman { font-family:serif; font-weight:normal; } 32 span.sansserif { font-family:sans-serif; font-weight:normal; } 33--></style> 34<link rel="stylesheet" type="text/css" href="../cs.css"> 35</head> 36<body> 37<div class="node"> 38<a name="strip"></a> 39<p> 40Next: <a rel="next" accesskey="n" href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>, 41Previous: <a rel="previous" accesskey="p" href="strings.html#strings">strings</a>, 42Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> 43<hr> 44</div> 45 46<h2 class="chapter">8 strip</h2> 47 48<p><a name="index-strip-128"></a><a name="index-removing-symbols-129"></a><a name="index-discarding-symbols-130"></a><a name="index-symbols_002c-discarding-131"></a> 49<!-- man title strip Discard symbols from object files. --> 50 51<pre class="smallexample"> <!-- man begin SYNOPSIS strip --> 52 strip [<samp><span class="option">-F</span></samp> <var>bfdname</var> |<samp><span class="option">--target=</span></samp><var>bfdname</var>] 53 [<samp><span class="option">-I</span></samp> <var>bfdname</var> |<samp><span class="option">--input-target=</span></samp><var>bfdname</var>] 54 [<samp><span class="option">-O</span></samp> <var>bfdname</var> |<samp><span class="option">--output-target=</span></samp><var>bfdname</var>] 55 [<samp><span class="option">-s</span></samp>|<samp><span class="option">--strip-all</span></samp>] 56 [<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>] 57 [<samp><span class="option">--strip-dwo</span></samp>] 58 [<samp><span class="option">-K</span></samp> <var>symbolname</var> |<samp><span class="option">--keep-symbol=</span></samp><var>symbolname</var>] 59 [<samp><span class="option">-N</span></samp> <var>symbolname</var> |<samp><span class="option">--strip-symbol=</span></samp><var>symbolname</var>] 60 [<samp><span class="option">-w</span></samp>|<samp><span class="option">--wildcard</span></samp>] 61 [<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>] 62 [<samp><span class="option">-R</span></samp> <var>sectionname</var> |<samp><span class="option">--remove-section=</span></samp><var>sectionname</var>] 63 [<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>] 64 [<samp><span class="option">-D</span></samp>|<samp><span class="option">--enable-deterministic-archives</span></samp>] 65 [<samp><span class="option">-U</span></samp>|<samp><span class="option">--disable-deterministic-archives</span></samp>] 66 [<samp><span class="option">--keep-file-symbols</span></samp>] 67 [<samp><span class="option">--only-keep-debug</span></samp>] 68 [<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>] 69 [<samp><span class="option">--help</span></samp>] [<samp><span class="option">--info</span></samp>] 70 <var>objfile</var>... 71 <!-- man end --> 72</pre> 73 <!-- man begin DESCRIPTION strip --> 74 <p><span class="sc">gnu</span> <samp><span class="command">strip</span></samp> discards all symbols from object files 75<var>objfile</var>. The list of object files may include archives. 76At least one object file must be given. 77 78 <p><samp><span class="command">strip</span></samp> modifies the files named in its argument, 79rather than writing modified copies under different names. 80 81<!-- man end --> 82<!-- man begin OPTIONS strip --> 83 <dl> 84<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 85code format <var>bfdname</var>, and rewrite it in the same format. 86See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information. 87 88 <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. 89 90 <br><dt><samp><span class="env">--info</span></samp><dd>Display a list showing all architectures and object formats available. 91 92 <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 93code format <var>bfdname</var>. 94See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information. 95 96 <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>. 97See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information. 98 99 <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 100option may be given more than once. Note that using this option 101inappropriately may make the output file unusable. The wildcard 102character ‘<samp><span class="samp">*</span></samp>’ may be given at the end of <var>sectionname</var>. If 103so, then any section starting with <var>sectionname</var> will be removed. 104 105 <br><dt><samp><span class="env">-s</span></samp><dt><samp><span class="env">--strip-all</span></samp><dd>Remove all symbols. 106 107 <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. 108 109 <br><dt><samp><span class="env">--strip-dwo</span></samp><dd>Remove the contents of all DWARF .dwo sections, leaving the 110remaining debugging sections and all symbols intact. 111See the description of this option in the <samp><span class="command">objcopy</span></samp> section 112for more information. 113 114 <br><dt><samp><span class="env">--strip-unneeded</span></samp><dd>Remove all symbols that are not needed for relocation processing. 115 116 <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 117normally be stripped. This option may be given more than once. 118 119 <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 120given more than once, and may be combined with strip options other than 121<samp><span class="option">-K</span></samp>. 122 123 <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 124existing file. When this argument is used, only one <var>objfile</var> 125argument may be specified. 126 127 <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. 128 129 <br><dt><samp><span class="env">-D</span></samp><dt><samp><span class="env">--enable-deterministic-archives</span></samp><dd><a name="index-deterministic-archives-132"></a><a name="index-g_t_002d_002denable_002ddeterministic_002darchives-133"></a>Operate in <em>deterministic</em> mode. When copying archive members 130and writing the archive index, use zero for UIDs, GIDs, timestamps, 131and use consistent file modes for all files. 132 133 <p>If <samp><span class="file">binutils</span></samp> was configured with 134<samp><span class="option">--enable-deterministic-archives</span></samp>, then this mode is on by default. 135It can be disabled with the ‘<samp><span class="samp">-U</span></samp>’ option, below. 136 137 <br><dt><samp><span class="env">-U</span></samp><dt><samp><span class="env">--disable-deterministic-archives</span></samp><dd><a name="index-deterministic-archives-134"></a><a name="index-g_t_002d_002denable_002ddeterministic_002darchives-135"></a>Do <em>not</em> operate in <em>deterministic</em> mode. This is the 138inverse of the <samp><span class="option">-D</span></samp> option, above: when copying archive members 139and writing the archive index, use their actual UID, GID, timestamp, 140and file mode values. 141 142 <p>This is the default unless <samp><span class="file">binutils</span></samp> was configured with 143<samp><span class="option">--enable-deterministic-archives</span></samp>. 144 145 <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 146line options. The question mark (?), asterisk (*), backslash (\) and 147square brackets ([]) operators can be used anywhere in the symbol 148name. If the first character of the symbol name is the exclamation 149point (!) then the sense of the switch is reversed for that symbol. 150For example: 151 152 <pre class="smallexample"> -w -K !foo -K fo* 153</pre> 154 <p>would cause strip to only keep symbols that start with the letters 155“fo”, but to discard the symbol “foo”. 156 157 <br><dt><samp><span class="env">-x</span></samp><dt><samp><span class="env">--discard-all</span></samp><dd>Remove non-global symbols. 158 159 <br><dt><samp><span class="env">-X</span></samp><dt><samp><span class="env">--discard-locals</span></samp><dd>Remove compiler-generated local symbols. 160(These usually start with ‘<samp><span class="samp">L</span></samp>’ or ‘<samp><span class="samp">.</span></samp>’.) 161 162 <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 163<samp><span class="option">--strip-unneeded</span></samp>, retain any symbols specifying source file names, 164which would otherwise get stripped. 165 166 <br><dt><samp><span class="env">--only-keep-debug</span></samp><dd>Strip a file, removing contents of any sections that would not be 167stripped by <samp><span class="option">--strip-debug</span></samp> and leaving the debugging sections 168intact. In ELF files, this preserves all note sections in the output. 169 170 <p>The intention is that this option will be used in conjunction with 171<samp><span class="option">--add-gnu-debuglink</span></samp> to create a two part executable. One a 172stripped binary which will occupy less space in RAM and in a 173distribution and the second a debugging information file which is only 174needed if debugging abilities are required. The suggested procedure 175to create these files is as follows: 176 177 <ol type=1 start=1> 178<li>Link the executable as normal. Assuming that is is called 179<code>foo</code> then... 180<li>Run <code>objcopy --only-keep-debug foo foo.dbg</code> to 181create a file containing the debugging info. 182<li>Run <code>objcopy --strip-debug foo</code> to create a 183stripped executable. 184<li>Run <code>objcopy --add-gnu-debuglink=foo.dbg foo</code> 185to add a link to the debugging info into the stripped executable. 186 </ol> 187 188 <p>Note—the choice of <code>.dbg</code> as an extension for the debug info 189file is arbitrary. Also the <code>--only-keep-debug</code> step is 190optional. You could instead do this: 191 192 <ol type=1 start=1> 193<li>Link the executable as normal. 194<li>Copy <code>foo</code> to <code>foo.full</code> 195<li>Run <code>strip --strip-debug foo</code> 196<li>Run <code>objcopy --add-gnu-debuglink=foo.full foo</code> 197 </ol> 198 199 <p>i.e., the file pointed to by the <samp><span class="option">--add-gnu-debuglink</span></samp> can be the 200full executable. It does not have to be a file created by the 201<samp><span class="option">--only-keep-debug</span></samp> switch. 202 203 <p>Note—this switch is only intended for use on fully linked files. It 204does not make sense to use it on object files where the debugging 205information may be incomplete. Besides the gnu_debuglink feature 206currently only supports the presence of one filename containing 207debugging information, not multiple filenames on a one-per-object-file 208basis. 209 210 <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>. 211 212 <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 213archives, ‘<samp><span class="samp">strip -v</span></samp>’ lists all members of the archive. 214</dl> 215 216<!-- man end --> 217 </body></html> 218 219