1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 1991-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3
7or any later version published by the Free Software Foundation;
8with no Invariant Sections, with no Front-Cover Texts, and with no
9Back-Cover Texts.  A copy of the license is included in the
10section entitled "GNU Free Documentation License".
11 -->
12<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
13<head>
14<title>GNU Binary Utilities: objcopy</title>
15
16<meta name="description" content="GNU Binary Utilities: objcopy">
17<meta name="keywords" content="GNU Binary Utilities: objcopy">
18<meta name="resource-type" content="document">
19<meta name="distribution" content="global">
20<meta name="Generator" content="makeinfo">
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<link href="index.html#Top" rel="start" title="Top">
23<link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
24<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
25<link href="index.html#Top" rel="up" title="Top">
26<link href="objdump.html#objdump" rel="next" title="objdump">
27<link href="nm.html#nm" rel="previous" title="nm">
28<style type="text/css">
29<!--
30a.summary-letter {text-decoration: none}
31blockquote.smallquotation {font-size: smaller}
32div.display {margin-left: 3.2em}
33div.example {margin-left: 3.2em}
34div.indentedblock {margin-left: 3.2em}
35div.lisp {margin-left: 3.2em}
36div.smalldisplay {margin-left: 3.2em}
37div.smallexample {margin-left: 3.2em}
38div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
39div.smalllisp {margin-left: 3.2em}
40kbd {font-style:oblique}
41pre.display {font-family: inherit}
42pre.format {font-family: inherit}
43pre.menu-comment {font-family: serif}
44pre.menu-preformatted {font-family: serif}
45pre.smalldisplay {font-family: inherit; font-size: smaller}
46pre.smallexample {font-size: smaller}
47pre.smallformat {font-family: inherit; font-size: smaller}
48pre.smalllisp {font-size: smaller}
49span.nocodebreak {white-space:nowrap}
50span.nolinebreak {white-space:nowrap}
51span.roman {font-family:serif; font-weight:normal}
52span.sansserif {font-family:sans-serif; font-weight:normal}
53ul.no-bullet {list-style: none}
54-->
55</style>
56
57
58</head>
59
60<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
61<a name="objcopy"></a>
62<div class="header">
63<p>
64Next: <a href="objdump.html#objdump" accesskey="n" rel="next">objdump</a>, Previous: <a href="nm.html#nm" accesskey="p" rel="previous">nm</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>
65</div>
66<hr>
67<a name="objcopy-1"></a>
68<h2 class="chapter">3 objcopy</h2>
69
70
71<div class="smallexample">
72<pre class="smallexample">objcopy [<samp>-F</samp> <var>bfdname</var>|<samp>--target=</samp><var>bfdname</var>]
73        [<samp>-I</samp> <var>bfdname</var>|<samp>--input-target=</samp><var>bfdname</var>]
74        [<samp>-O</samp> <var>bfdname</var>|<samp>--output-target=</samp><var>bfdname</var>]
75        [<samp>-B</samp> <var>bfdarch</var>|<samp>--binary-architecture=</samp><var>bfdarch</var>]
76        [<samp>-S</samp>|<samp>--strip-all</samp>]
77        [<samp>-g</samp>|<samp>--strip-debug</samp>]
78        [<samp>--strip-unneeded</samp>]
79        [<samp>-K</samp> <var>symbolname</var>|<samp>--keep-symbol=</samp><var>symbolname</var>]
80        [<samp>-N</samp> <var>symbolname</var>|<samp>--strip-symbol=</samp><var>symbolname</var>]
81        [<samp>--strip-unneeded-symbol=</samp><var>symbolname</var>]
82        [<samp>-G</samp> <var>symbolname</var>|<samp>--keep-global-symbol=</samp><var>symbolname</var>]
83        [<samp>--localize-hidden</samp>]
84        [<samp>-L</samp> <var>symbolname</var>|<samp>--localize-symbol=</samp><var>symbolname</var>]
85        [<samp>--globalize-symbol=</samp><var>symbolname</var>]
86        [<samp>--globalize-symbols=</samp><var>filename</var>]
87        [<samp>-W</samp> <var>symbolname</var>|<samp>--weaken-symbol=</samp><var>symbolname</var>]
88        [<samp>-w</samp>|<samp>--wildcard</samp>]
89        [<samp>-x</samp>|<samp>--discard-all</samp>]
90        [<samp>-X</samp>|<samp>--discard-locals</samp>]
91        [<samp>-b</samp> <var>byte</var>|<samp>--byte=</samp><var>byte</var>]
92        [<samp>-i</samp> [<var>breadth</var>]|<samp>--interleave</samp>[=<var>breadth</var>]]
93        [<samp>--interleave-width=</samp><var>width</var>]
94        [<samp>-j</samp> <var>sectionpattern</var>|<samp>--only-section=</samp><var>sectionpattern</var>]
95        [<samp>-R</samp> <var>sectionpattern</var>|<samp>--remove-section=</samp><var>sectionpattern</var>]
96        [<samp>--keep-section=</samp><var>sectionpattern</var>]
97        [<samp>--remove-relocations=</samp><var>sectionpattern</var>]
98        [<samp>-p</samp>|<samp>--preserve-dates</samp>]
99        [<samp>-D</samp>|<samp>--enable-deterministic-archives</samp>]
100        [<samp>-U</samp>|<samp>--disable-deterministic-archives</samp>]
101        [<samp>--debugging</samp>]
102        [<samp>--gap-fill=</samp><var>val</var>]
103        [<samp>--pad-to=</samp><var>address</var>]
104        [<samp>--set-start=</samp><var>val</var>]
105        [<samp>--adjust-start=</samp><var>incr</var>]
106        [<samp>--change-addresses=</samp><var>incr</var>]
107        [<samp>--change-section-address</samp> <var>sectionpattern</var>{=,+,-}<var>val</var>]
108        [<samp>--change-section-lma</samp> <var>sectionpattern</var>{=,+,-}<var>val</var>]
109        [<samp>--change-section-vma</samp> <var>sectionpattern</var>{=,+,-}<var>val</var>]
110        [<samp>--change-warnings</samp>] [<samp>--no-change-warnings</samp>]
111        [<samp>--set-section-flags</samp> <var>sectionpattern</var>=<var>flags</var>]
112        [<samp>--set-section-alignment</samp> <var>sectionpattern</var>=<var>align</var>]
113        [<samp>--add-section</samp> <var>sectionname</var>=<var>filename</var>]
114        [<samp>--dump-section</samp> <var>sectionname</var>=<var>filename</var>]
115        [<samp>--update-section</samp> <var>sectionname</var>=<var>filename</var>]
116        [<samp>--rename-section</samp> <var>oldname</var>=<var>newname</var>[,<var>flags</var>]]
117        [<samp>--long-section-names</samp> {enable,disable,keep}]
118        [<samp>--change-leading-char</samp>] [<samp>--remove-leading-char</samp>]
119        [<samp>--reverse-bytes=</samp><var>num</var>]
120        [<samp>--srec-len=</samp><var>ival</var>] [<samp>--srec-forceS3</samp>]
121        [<samp>--redefine-sym</samp> <var>old</var>=<var>new</var>]
122        [<samp>--redefine-syms=</samp><var>filename</var>]
123        [<samp>--weaken</samp>]
124        [<samp>--keep-symbols=</samp><var>filename</var>]
125        [<samp>--strip-symbols=</samp><var>filename</var>]
126        [<samp>--strip-unneeded-symbols=</samp><var>filename</var>]
127        [<samp>--keep-global-symbols=</samp><var>filename</var>]
128        [<samp>--localize-symbols=</samp><var>filename</var>]
129        [<samp>--weaken-symbols=</samp><var>filename</var>]
130        [<samp>--add-symbol</samp> <var>name</var>=[<var>section</var>:]<var>value</var>[,<var>flags</var>]]
131        [<samp>--alt-machine-code=</samp><var>index</var>]
132        [<samp>--prefix-symbols=</samp><var>string</var>]
133        [<samp>--prefix-sections=</samp><var>string</var>]
134        [<samp>--prefix-alloc-sections=</samp><var>string</var>]
135        [<samp>--add-gnu-debuglink=</samp><var>path-to-file</var>]
136        [<samp>--keep-file-symbols</samp>]
137        [<samp>--only-keep-debug</samp>]
138        [<samp>--strip-dwo</samp>]
139        [<samp>--extract-dwo</samp>]
140        [<samp>--extract-symbol</samp>]
141        [<samp>--writable-text</samp>]
142        [<samp>--readonly-text</samp>]
143        [<samp>--pure</samp>]
144        [<samp>--impure</samp>]
145        [<samp>--file-alignment=</samp><var>num</var>]
146        [<samp>--heap=</samp><var>size</var>]
147        [<samp>--image-base=</samp><var>address</var>]
148        [<samp>--section-alignment=</samp><var>num</var>]
149        [<samp>--stack=</samp><var>size</var>]
150        [<samp>--subsystem=</samp><var>which</var>:<var>major</var>.<var>minor</var>]
151        [<samp>--compress-debug-sections</samp>]
152        [<samp>--decompress-debug-sections</samp>]
153        [<samp>--elf-stt-common=<var>val</var></samp>]
154        [<samp>--merge-notes</samp>]
155        [<samp>--no-merge-notes</samp>]
156        [<samp>--verilog-data-width=<var>val</var></samp>]
157        [<samp>-v</samp>|<samp>--verbose</samp>]
158        [<samp>-V</samp>|<samp>--version</samp>]
159        [<samp>--help</samp>] [<samp>--info</samp>]
160        <var>infile</var> [<var>outfile</var>]
161</pre></div>
162
163<p>The <small>GNU</small> <code>objcopy</code> utility copies the contents of an object
164file to another.  <code>objcopy</code> uses the <small>GNU</small> <small>BFD</small> Library to
165read and write the object files.  It can write the destination object
166file in a format different from that of the source object file.  The
167exact behavior of <code>objcopy</code> is controlled by command-line options.
168Note that <code>objcopy</code> should be able to copy a fully linked file
169between any two formats. However, copying a relocatable object file
170between any two formats may not work as expected.
171</p>
172<p><code>objcopy</code> creates temporary files to do its translations and
173deletes them afterward.  <code>objcopy</code> uses <small>BFD</small> to do all its
174translation work; it has access to all the formats described in <small>BFD</small>
175and thus is able to recognize most formats without being told
176explicitly.  See <a href="http://sourceware.org/binutils/docs/ld/BFD.html#BFD">BFD</a> in <cite>Using LD</cite>.
177</p>
178<p><code>objcopy</code> can be used to generate S-records by using an output
179target of &lsquo;<samp>srec</samp>&rsquo; (e.g., use &lsquo;<samp>-O srec</samp>&rsquo;).
180</p>
181<p><code>objcopy</code> can be used to generate a raw binary file by using an
182output target of &lsquo;<samp>binary</samp>&rsquo; (e.g., use <samp>-O binary</samp>).  When
183<code>objcopy</code> generates a raw binary file, it will essentially produce
184a memory dump of the contents of the input object file.  All symbols and
185relocation information will be discarded.  The memory dump will start at
186the load address of the lowest section copied into the output file.
187</p>
188<p>When generating an S-record or a raw binary file, it may be helpful to
189use <samp>-S</samp> to remove sections containing debugging information.  In
190some cases <samp>-R</samp> will be useful to remove sections which contain
191information that is not needed by the binary file.
192</p>
193<p>Note&mdash;<code>objcopy</code> is not able to change the endianness of its input
194files.  If the input format has an endianness (some formats do not),
195<code>objcopy</code> can only copy the inputs into file formats that have the
196same endianness or which have no endianness (e.g., &lsquo;<samp>srec</samp>&rsquo;).
197(However, see the <samp>--reverse-bytes</samp> option.)
198</p>
199
200
201<dl compact="compact">
202<dt><code><var>infile</var></code></dt>
203<dt><code><var>outfile</var></code></dt>
204<dd><p>The input and output files, respectively.
205If you do not specify <var>outfile</var>, <code>objcopy</code> creates a
206temporary file and destructively renames the result with
207the name of <var>infile</var>.
208</p>
209</dd>
210<dt><code>-I <var>bfdname</var></code></dt>
211<dt><code>--input-target=<var>bfdname</var></code></dt>
212<dd><p>Consider the source file&rsquo;s object format to be <var>bfdname</var>, rather than
213attempting to deduce it.  See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
214</p>
215</dd>
216<dt><code>-O <var>bfdname</var></code></dt>
217<dt><code>--output-target=<var>bfdname</var></code></dt>
218<dd><p>Write the output file using the object format <var>bfdname</var>.
219See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
220</p>
221</dd>
222<dt><code>-F <var>bfdname</var></code></dt>
223<dt><code>--target=<var>bfdname</var></code></dt>
224<dd><p>Use <var>bfdname</var> as the object format for both the input and the output
225file; i.e., simply transfer data from source to destination with no
226translation.  See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
227</p>
228</dd>
229<dt><code>-B <var>bfdarch</var></code></dt>
230<dt><code>--binary-architecture=<var>bfdarch</var></code></dt>
231<dd><p>Useful when transforming a architecture-less input file into an object file.
232In this case the output architecture can be set to <var>bfdarch</var>.  This
233option will be ignored if the input file has a known <var>bfdarch</var>.  You
234can access this binary data inside a program by referencing the special
235symbols that are created by the conversion process.  These symbols are
236called _binary_<var>objfile</var>_start, _binary_<var>objfile</var>_end and
237_binary_<var>objfile</var>_size.  e.g. you can transform a picture file into
238an object file and then access it in your code using these symbols.
239</p>
240</dd>
241<dt><code>-j <var>sectionpattern</var></code></dt>
242<dt><code>--only-section=<var>sectionpattern</var></code></dt>
243<dd><p>Copy only the indicated sections from the input file to the output file.
244This option may be given more than once.  Note that using this option
245inappropriately may make the output file unusable.  Wildcard
246characters are accepted in <var>sectionpattern</var>.
247</p>
248<p>If the first character of <var>sectionpattern</var> is the exclamation
249point (!) then matching sections will not be copied, even if earlier
250use of <samp>--only-section</samp> on the same command line would
251otherwise copy it.  For example:
252</p>
253<div class="smallexample">
254<pre class="smallexample">  --only-section=.text.* --only-section=!.text.foo
255</pre></div>
256
257<p>will copy all sectinos matching &rsquo;.text.*&rsquo; but not the section
258&rsquo;.text.foo&rsquo;.
259</p>
260</dd>
261<dt><code>-R <var>sectionpattern</var></code></dt>
262<dt><code>--remove-section=<var>sectionpattern</var></code></dt>
263<dd><p>Remove any section matching <var>sectionpattern</var> from the output file.
264This option may be given more than once.  Note that using this option
265inappropriately may make the output file unusable.  Wildcard
266characters are accepted in <var>sectionpattern</var>.  Using both the
267<samp>-j</samp> and <samp>-R</samp> options together results in undefined
268behaviour.
269</p>
270<p>If the first character of <var>sectionpattern</var> is the exclamation
271point (!) then matching sections will not be removed even if an
272earlier use of <samp>--remove-section</samp> on the same command line
273would otherwise remove it.  For example:
274</p>
275<div class="smallexample">
276<pre class="smallexample">  --remove-section=.text.* --remove-section=!.text.foo
277</pre></div>
278
279<p>will remove all sections matching the pattern &rsquo;.text.*&rsquo;, but will not
280remove the section &rsquo;.text.foo&rsquo;.
281</p>
282</dd>
283<dt><code>--keep-section=<var>sectionpattern</var></code></dt>
284<dd><p>When removing sections from the output file, keep sections that match
285<var>sectionpattern</var>.
286</p>
287</dd>
288<dt><code>--remove-relocations=<var>sectionpattern</var></code></dt>
289<dd><p>Remove non-dynamic relocations from the output file for any section
290matching <var>sectionpattern</var>.  This option may be given more than
291once.  Note that using this option inappropriately may make the output
292file unusable, and attempting to remove a dynamic relocation section
293such as &lsquo;<samp>.rela.plt</samp>&rsquo; from an executable or shared library with
294<samp>--remove-relocations=.plt</samp> will not work.  Wildcard characters
295are accepted in <var>sectionpattern</var>.
296For example:
297</p>
298<div class="smallexample">
299<pre class="smallexample">  --remove-relocations=.text.*
300</pre></div>
301
302<p>will remove the relocations for all sections matching the pattern
303&rsquo;.text.*&rsquo;.
304</p>
305<p>If the first character of <var>sectionpattern</var> is the exclamation
306point (!) then matching sections will not have their relocation
307removed even if an earlier use of <samp>--remove-relocations</samp> on the
308same command line would otherwise cause the relocations to be removed.
309For example:
310</p>
311<div class="smallexample">
312<pre class="smallexample">  --remove-relocations=.text.* --remove-relocations=!.text.foo
313</pre></div>
314
315<p>will remove all relocations for sections matching the pattern
316&rsquo;.text.*&rsquo;, but will not remove relocations for the section
317&rsquo;.text.foo&rsquo;.
318</p>
319</dd>
320<dt><code>-S</code></dt>
321<dt><code>--strip-all</code></dt>
322<dd><p>Do not copy relocation and symbol information from the source file.
323Also deletes debug sections.
324</p>
325</dd>
326<dt><code>-g</code></dt>
327<dt><code>--strip-debug</code></dt>
328<dd><p>Do not copy debugging symbols or sections from the source file.
329</p>
330</dd>
331<dt><code>--strip-unneeded</code></dt>
332<dd><p>Remove all symbols that are not needed for relocation processing in
333addition to debugging symbols and sections stripped by
334<samp>--strip-debug</samp>.
335</p>
336</dd>
337<dt><code>-K <var>symbolname</var></code></dt>
338<dt><code>--keep-symbol=<var>symbolname</var></code></dt>
339<dd><p>When stripping symbols, keep symbol <var>symbolname</var> even if it would
340normally be stripped.  This option may be given more than once.
341</p>
342</dd>
343<dt><code>-N <var>symbolname</var></code></dt>
344<dt><code>--strip-symbol=<var>symbolname</var></code></dt>
345<dd><p>Do not copy symbol <var>symbolname</var> from the source file.  This option
346may be given more than once.
347</p>
348</dd>
349<dt><code>--strip-unneeded-symbol=<var>symbolname</var></code></dt>
350<dd><p>Do not copy symbol <var>symbolname</var> from the source file unless it is needed
351by a relocation.  This option may be given more than once.
352</p>
353</dd>
354<dt><code>-G <var>symbolname</var></code></dt>
355<dt><code>--keep-global-symbol=<var>symbolname</var></code></dt>
356<dd><p>Keep only symbol <var>symbolname</var> global.  Make all other symbols local
357to the file, so that they are not visible externally.  This option may
358be given more than once.  Note: this option cannot be used in
359conjunction with the <samp>--globalize-symbol</samp> or
360<samp>--globalize-symbols</samp> options.
361</p>
362</dd>
363<dt><code>--localize-hidden</code></dt>
364<dd><p>In an ELF object, mark all symbols that have hidden or internal visibility
365as local.  This option applies on top of symbol-specific localization options
366such as <samp>-L</samp>.
367</p>
368</dd>
369<dt><code>-L <var>symbolname</var></code></dt>
370<dt><code>--localize-symbol=<var>symbolname</var></code></dt>
371<dd><p>Convert a global or weak symbol called <var>symbolname</var> into a local
372symbol, so that it is not visible externally.  This option may be
373given more than once.  Note - unique symbols are not converted.
374</p>
375</dd>
376<dt><code>-W <var>symbolname</var></code></dt>
377<dt><code>--weaken-symbol=<var>symbolname</var></code></dt>
378<dd><p>Make symbol <var>symbolname</var> weak. This option may be given more than once.
379</p>
380</dd>
381<dt><code>--globalize-symbol=<var>symbolname</var></code></dt>
382<dd><p>Give symbol <var>symbolname</var> global scoping so that it is visible
383outside of the file in which it is defined.  This option may be given
384more than once.  Note: this option cannot be used in conjunction with
385the <samp>-G</samp> or <samp>--keep-global-symbol</samp> options.
386</p>
387</dd>
388<dt><code>-w</code></dt>
389<dt><code>--wildcard</code></dt>
390<dd><p>Permit regular expressions in <var>symbolname</var>s used in other command
391line options.  The question mark (?), asterisk (*), backslash (\) and
392square brackets ([]) operators can be used anywhere in the symbol
393name.  If the first character of the symbol name is the exclamation
394point (!) then the sense of the switch is reversed for that symbol.
395For example:
396</p>
397<div class="smallexample">
398<pre class="smallexample">  -w -W !foo -W fo*
399</pre></div>
400
401<p>would cause objcopy to weaken all symbols that start with &ldquo;fo&rdquo;
402except for the symbol &ldquo;foo&rdquo;.
403</p>
404</dd>
405<dt><code>-x</code></dt>
406<dt><code>--discard-all</code></dt>
407<dd><p>Do not copy non-global symbols from the source file.
408</p>
409</dd>
410<dt><code>-X</code></dt>
411<dt><code>--discard-locals</code></dt>
412<dd><p>Do not copy compiler-generated local symbols.
413(These usually start with &lsquo;<samp>L</samp>&rsquo; or &lsquo;<samp>.</samp>&rsquo;.)
414</p>
415</dd>
416<dt><code>-b <var>byte</var></code></dt>
417<dt><code>--byte=<var>byte</var></code></dt>
418<dd><p>If interleaving has been enabled via the <samp>--interleave</samp> option
419then start the range of bytes to keep at the <var>byte</var>th byte.
420<var>byte</var> can be in the range from 0 to <var>breadth</var>-1, where
421<var>breadth</var> is the value given by the <samp>--interleave</samp> option.
422</p>
423</dd>
424<dt><code>-i [<var>breadth</var>]</code></dt>
425<dt><code>--interleave[=<var>breadth</var>]</code></dt>
426<dd><p>Only copy a range out of every <var>breadth</var> bytes.  (Header data is
427not affected).  Select which byte in the range begins the copy with
428the <samp>--byte</samp> option.  Select the width of the range with the
429<samp>--interleave-width</samp> option.
430</p>
431<p>This option is useful for creating files to program <small>ROM</small>.  It is
432typically used with an <code>srec</code> output target.  Note that
433<code>objcopy</code> will complain if you do not specify the
434<samp>--byte</samp> option as well.
435</p>
436<p>The default interleave breadth is 4, so with <samp>--byte</samp> set to 0,
437<code>objcopy</code> would copy the first byte out of every four bytes
438from the input to the output.
439</p>
440</dd>
441<dt><code>--interleave-width=<var>width</var></code></dt>
442<dd><p>When used with the <samp>--interleave</samp> option, copy <var>width</var>
443bytes at a time.  The start of the range of bytes to be copied is set
444by the <samp>--byte</samp> option, and the extent of the range is set with
445the <samp>--interleave</samp> option.
446</p>
447<p>The default value for this option is 1.  The value of <var>width</var> plus
448the <var>byte</var> value set by the <samp>--byte</samp> option must not exceed
449the interleave breadth set by the <samp>--interleave</samp> option.
450</p>
451<p>This option can be used to create images for two 16-bit flashes interleaved
452in a 32-bit bus by passing <samp>-b 0 -i 4 --interleave-width=2</samp>
453and <samp>-b 2 -i 4 --interleave-width=2</samp> to two <code>objcopy</code>
454commands.  If the input was &rsquo;12345678&rsquo; then the outputs would be
455&rsquo;1256&rsquo; and &rsquo;3478&rsquo; respectively.
456</p>
457</dd>
458<dt><code>-p</code></dt>
459<dt><code>--preserve-dates</code></dt>
460<dd><p>Set the access and modification dates of the output file to be the same
461as those of the input file.
462</p>
463</dd>
464<dt><code>-D</code></dt>
465<dt><code>--enable-deterministic-archives</code></dt>
466<dd><a name="index-deterministic-archives-2"></a>
467<a name="index-_002d_002denable_002ddeterministic_002darchives-2"></a>
468<p>Operate in <em>deterministic</em> mode.  When copying archive members
469and writing the archive index, use zero for UIDs, GIDs, timestamps,
470and use consistent file modes for all files.
471</p>
472<p>If <samp>binutils</samp> was configured with
473<samp>--enable-deterministic-archives</samp>, then this mode is on by default.
474It can be disabled with the &lsquo;<samp>-U</samp>&rsquo; option, below.
475</p>
476</dd>
477<dt><code>-U</code></dt>
478<dt><code>--disable-deterministic-archives</code></dt>
479<dd><a name="index-deterministic-archives-3"></a>
480<a name="index-_002d_002denable_002ddeterministic_002darchives-3"></a>
481<p>Do <em>not</em> operate in <em>deterministic</em> mode.  This is the
482inverse of the <samp>-D</samp> option, above: when copying archive members
483and writing the archive index, use their actual UID, GID, timestamp,
484and file mode values.
485</p>
486<p>This is the default unless <samp>binutils</samp> was configured with
487<samp>--enable-deterministic-archives</samp>.
488</p>
489</dd>
490<dt><code>--debugging</code></dt>
491<dd><p>Convert debugging information, if possible.  This is not the default
492because only certain debugging formats are supported, and the
493conversion process can be time consuming.
494</p>
495</dd>
496<dt><code>--gap-fill <var>val</var></code></dt>
497<dd><p>Fill gaps between sections with <var>val</var>.  This operation applies to
498the <em>load address</em> (LMA) of the sections.  It is done by increasing
499the size of the section with the lower address, and filling in the extra
500space created with <var>val</var>.
501</p>
502</dd>
503<dt><code>--pad-to <var>address</var></code></dt>
504<dd><p>Pad the output file up to the load address <var>address</var>.  This is
505done by increasing the size of the last section.  The extra space is
506filled in with the value specified by <samp>--gap-fill</samp> (default zero).
507</p>
508</dd>
509<dt><code>--set-start <var>val</var></code></dt>
510<dd><p>Set the start address (also known as the entry address) of the new
511file to <var>val</var>.  Not all object file formats support setting the
512start address.
513</p>
514</dd>
515<dt><code>--change-start <var>incr</var></code></dt>
516<dt><code>--adjust-start <var>incr</var></code></dt>
517<dd><a name="index-changing-start-address"></a>
518<p>Change the start address (also known as the entry address) by adding
519<var>incr</var>.  Not all object file formats support setting the start
520address.
521</p>
522</dd>
523<dt><code>--change-addresses <var>incr</var></code></dt>
524<dt><code>--adjust-vma <var>incr</var></code></dt>
525<dd><a name="index-changing-object-addresses"></a>
526<p>Change the VMA and LMA addresses of all sections, as well as the start
527address, by adding <var>incr</var>.  Some object file formats do not permit
528section addresses to be changed arbitrarily.  Note that this does not
529relocate the sections; if the program expects sections to be loaded at a
530certain address, and this option is used to change the sections such
531that they are loaded at a different address, the program may fail.
532</p>
533</dd>
534<dt><code>--change-section-address <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
535<dt><code>--adjust-section-vma <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
536<dd><a name="index-changing-section-address"></a>
537<p>Set or change both the VMA address and the LMA address of any section
538matching <var>sectionpattern</var>.  If &lsquo;<samp>=</samp>&rsquo; is used, the section
539address is set to <var>val</var>.  Otherwise, <var>val</var> is added to or
540subtracted from the section address.  See the comments under
541<samp>--change-addresses</samp>, above. If <var>sectionpattern</var> does not
542match any sections in the input file, a warning will be issued, unless
543<samp>--no-change-warnings</samp> is used.
544</p>
545</dd>
546<dt><code>--change-section-lma <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
547<dd><a name="index-changing-section-LMA"></a>
548<p>Set or change the LMA address of any sections matching
549<var>sectionpattern</var>.  The LMA address is the address where the
550section will be loaded into memory at program load time.  Normally
551this is the same as the VMA address, which is the address of the
552section at program run time, but on some systems, especially those
553where a program is held in ROM, the two can be different.  If &lsquo;<samp>=</samp>&rsquo;
554is used, the section address is set to <var>val</var>.  Otherwise,
555<var>val</var> is added to or subtracted from the section address.  See the
556comments under <samp>--change-addresses</samp>, above.  If
557<var>sectionpattern</var> does not match any sections in the input file, a
558warning will be issued, unless <samp>--no-change-warnings</samp> is used.
559</p>
560</dd>
561<dt><code>--change-section-vma <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
562<dd><a name="index-changing-section-VMA"></a>
563<p>Set or change the VMA address of any section matching
564<var>sectionpattern</var>.  The VMA address is the address where the
565section will be located once the program has started executing.
566Normally this is the same as the LMA address, which is the address
567where the section will be loaded into memory, but on some systems,
568especially those where a program is held in ROM, the two can be
569different.  If &lsquo;<samp>=</samp>&rsquo; is used, the section address is set to
570<var>val</var>.  Otherwise, <var>val</var> is added to or subtracted from the
571section address.  See the comments under <samp>--change-addresses</samp>,
572above.  If <var>sectionpattern</var> does not match any sections in the
573input file, a warning will be issued, unless
574<samp>--no-change-warnings</samp> is used.
575</p>
576</dd>
577<dt><code>--change-warnings</code></dt>
578<dt><code>--adjust-warnings</code></dt>
579<dd><p>If <samp>--change-section-address</samp> or <samp>--change-section-lma</samp> or
580<samp>--change-section-vma</samp> is used, and the section pattern does not
581match any sections, issue a warning.  This is the default.
582</p>
583</dd>
584<dt><code>--no-change-warnings</code></dt>
585<dt><code>--no-adjust-warnings</code></dt>
586<dd><p>Do not issue a warning if <samp>--change-section-address</samp> or
587<samp>--adjust-section-lma</samp> or <samp>--adjust-section-vma</samp> is used, even
588if the section pattern does not match any sections.
589</p>
590</dd>
591<dt><code>--set-section-flags <var>sectionpattern</var>=<var>flags</var></code></dt>
592<dd><p>Set the flags for any sections matching <var>sectionpattern</var>.  The
593<var>flags</var> argument is a comma separated string of flag names.  The
594recognized names are &lsquo;<samp>alloc</samp>&rsquo;, &lsquo;<samp>contents</samp>&rsquo;, &lsquo;<samp>load</samp>&rsquo;,
595&lsquo;<samp>noload</samp>&rsquo;, &lsquo;<samp>readonly</samp>&rsquo;, &lsquo;<samp>code</samp>&rsquo;, &lsquo;<samp>data</samp>&rsquo;, &lsquo;<samp>rom</samp>&rsquo;,
596&lsquo;<samp>exclude</samp>&rsquo;, &lsquo;<samp>share</samp>&rsquo;, and &lsquo;<samp>debug</samp>&rsquo;.  You can set the
597&lsquo;<samp>contents</samp>&rsquo; flag for a section which does not have contents, but it
598is not meaningful to clear the &lsquo;<samp>contents</samp>&rsquo; flag of a section which
599does have contents&ndash;just remove the section instead.  Not all flags are
600meaningful for all object file formats.  In particular the
601&lsquo;<samp>share</samp>&rsquo; flag is only meaningful for COFF format files and not for
602ELF format files.
603</p>
604</dd>
605<dt><code>--set-section-alignment <var>sectionpattern</var>=<var>align</var></code></dt>
606<dd><p>Set the alignment for any sections matching <var>sectionpattern</var>.
607<var>align</var> specifies the alignment in bytes and must be a power of
608two, i.e. 1, 2, 4, 8&hellip;.
609</p>
610</dd>
611<dt><code>--add-section <var>sectionname</var>=<var>filename</var></code></dt>
612<dd><p>Add a new section named <var>sectionname</var> while copying the file.  The
613contents of the new section are taken from the file <var>filename</var>.  The
614size of the section will be the size of the file.  This option only
615works on file formats which can support sections with arbitrary names.
616Note - it may be necessary to use the <samp>--set-section-flags</samp>
617option to set the attributes of the newly created section.
618</p>
619</dd>
620<dt><code>--dump-section <var>sectionname</var>=<var>filename</var></code></dt>
621<dd><p>Place the contents of section named <var>sectionname</var> into the file
622<var>filename</var>, overwriting any contents that may have been there
623previously.  This option is the inverse of <samp>--add-section</samp>.
624This option is similar to the <samp>--only-section</samp> option except
625that it does not create a formatted file, it just dumps the contents
626as raw binary data, without applying any relocations.  The option can
627be specified more than once.
628</p>
629</dd>
630<dt><code>--update-section <var>sectionname</var>=<var>filename</var></code></dt>
631<dd><p>Replace the existing contents of a section named <var>sectionname</var>
632with the contents of file <var>filename</var>.  The size of the section
633will be adjusted to the size of the file.  The section flags for
634<var>sectionname</var> will be unchanged.  For ELF format files the section
635to segment mapping will also remain unchanged, something which is not
636possible using <samp>--remove-section</samp> followed by
637<samp>--add-section</samp>.  The option can be specified more than once.
638</p>
639<p>Note - it is possible to use <samp>--rename-section</samp> and
640<samp>--update-section</samp> to both update and rename a section from one
641command line.  In this case, pass the original section name to
642<samp>--update-section</samp>, and the original and new section names to
643<samp>--rename-section</samp>.
644</p>
645</dd>
646<dt><code>--add-symbol <var>name</var>=[<var>section</var>:]<var>value</var>[,<var>flags</var>]</code></dt>
647<dd><p>Add a new symbol named <var>name</var> while copying the file.  This option may be
648specified multiple times.  If the <var>section</var> is given, the symbol will be
649associated with and relative to that section, otherwise it will be an ABS
650symbol.  Specifying an undefined section will result in a fatal error.  There
651is no check for the value, it will be taken as specified.  Symbol flags can
652be specified and not all flags will be meaningful for all object file
653formats.  By default, the symbol will be global.  The special flag
654&rsquo;before=<var>othersym</var>&rsquo; will insert the new symbol in front of the specified
655<var>othersym</var>, otherwise the symbol(s) will be added at the end of the
656symbol table in the order they appear.
657</p>
658</dd>
659<dt><code>--rename-section <var>oldname</var>=<var>newname</var>[,<var>flags</var>]</code></dt>
660<dd><p>Rename a section from <var>oldname</var> to <var>newname</var>, optionally
661changing the section&rsquo;s flags to <var>flags</var> in the process.  This has
662the advantage over using a linker script to perform the rename in that
663the output stays as an object file and does not become a linked
664executable.  This option accepts the same set of flags as the
665<samp>--sect-section-flags</samp> option.
666</p>
667<p>This option is particularly helpful when the input format is binary,
668since this will always create a section called .data.  If for example,
669you wanted instead to create a section called .rodata containing binary
670data you could use the following command line to achieve it:
671</p>
672<div class="smallexample">
673<pre class="smallexample">  objcopy -I binary -O &lt;output_format&gt; -B &lt;architecture&gt; \
674   --rename-section .data=.rodata,alloc,load,readonly,data,contents \
675   &lt;input_binary_file&gt; &lt;output_object_file&gt;
676</pre></div>
677
678</dd>
679<dt><code>--long-section-names {enable,disable,keep}</code></dt>
680<dd><p>Controls the handling of long section names when processing <code>COFF</code>
681and <code>PE-COFF</code> object formats.  The default behaviour, &lsquo;<samp>keep</samp>&rsquo;,
682is to preserve long section names if any are present in the input file.
683The &lsquo;<samp>enable</samp>&rsquo; and &lsquo;<samp>disable</samp>&rsquo; options forcibly enable or disable
684the use of long section names in the output object; when &lsquo;<samp>disable</samp>&rsquo;
685is in effect, any long section names in the input object will be truncated.
686The &lsquo;<samp>enable</samp>&rsquo; option will only emit long section names if any are
687present in the inputs; this is mostly the same as &lsquo;<samp>keep</samp>&rsquo;, but it
688is left undefined whether the &lsquo;<samp>enable</samp>&rsquo; option might force the
689creation of an empty string table in the output file.
690</p>
691</dd>
692<dt><code>--change-leading-char</code></dt>
693<dd><p>Some object file formats use special characters at the start of
694symbols.  The most common such character is underscore, which compilers
695often add before every symbol.  This option tells <code>objcopy</code> to
696change the leading character of every symbol when it converts between
697object file formats.  If the object file formats use the same leading
698character, this option has no effect.  Otherwise, it will add a
699character, or remove a character, or change a character, as
700appropriate.
701</p>
702</dd>
703<dt><code>--remove-leading-char</code></dt>
704<dd><p>If the first character of a global symbol is a special symbol leading
705character used by the object file format, remove the character.  The
706most common symbol leading character is underscore.  This option will
707remove a leading underscore from all global symbols.  This can be useful
708if you want to link together objects of different file formats with
709different conventions for symbol names.  This is different from
710<samp>--change-leading-char</samp> because it always changes the symbol name
711when appropriate, regardless of the object file format of the output
712file.
713</p>
714</dd>
715<dt><code>--reverse-bytes=<var>num</var></code></dt>
716<dd><p>Reverse the bytes in a section with output contents.  A section length must
717be evenly divisible by the value given in order for the swap to be able to
718take place. Reversing takes place before the interleaving is performed.
719</p>
720<p>This option is used typically in generating ROM images for problematic
721target systems.  For example, on some target boards, the 32-bit words
722fetched from 8-bit ROMs are re-assembled in little-endian byte order
723regardless of the CPU byte order.  Depending on the programming model, the
724endianness of the ROM may need to be modified.
725</p>
726<p>Consider a simple file with a section containing the following eight
727bytes:  <code>12345678</code>.
728</p>
729<p>Using &lsquo;<samp>--reverse-bytes=2</samp>&rsquo; for the above example, the bytes in the
730output file would be ordered <code>21436587</code>.
731</p>
732<p>Using &lsquo;<samp>--reverse-bytes=4</samp>&rsquo; for the above example, the bytes in the
733output file would be ordered <code>43218765</code>.
734</p>
735<p>By using &lsquo;<samp>--reverse-bytes=2</samp>&rsquo; for the above example, followed by
736&lsquo;<samp>--reverse-bytes=4</samp>&rsquo; on the output file, the bytes in the second
737output file would be ordered <code>34127856</code>.
738</p>
739</dd>
740<dt><code>--srec-len=<var>ival</var></code></dt>
741<dd><p>Meaningful only for srec output.  Set the maximum length of the Srecords
742being produced to <var>ival</var>.  This length covers both address, data and
743crc fields.
744</p>
745</dd>
746<dt><code>--srec-forceS3</code></dt>
747<dd><p>Meaningful only for srec output.  Avoid generation of S1/S2 records,
748creating S3-only record format.
749</p>
750</dd>
751<dt><code>--redefine-sym <var>old</var>=<var>new</var></code></dt>
752<dd><p>Change the name of a symbol <var>old</var>, to <var>new</var>.  This can be useful
753when one is trying link two things together for which you have no
754source, and there are name collisions.
755</p>
756</dd>
757<dt><code>--redefine-syms=<var>filename</var></code></dt>
758<dd><p>Apply <samp>--redefine-sym</samp> to each symbol pair &quot;<var>old</var> <var>new</var>&quot;
759listed in the file <var>filename</var>.  <var>filename</var> is simply a flat file,
760with one symbol pair per line.  Line comments may be introduced by the hash
761character.  This option may be given more than once.
762</p>
763</dd>
764<dt><code>--weaken</code></dt>
765<dd><p>Change all global symbols in the file to be weak.  This can be useful
766when building an object which will be linked against other objects using
767the <samp>-R</samp> option to the linker.  This option is only effective when
768using an object file format which supports weak symbols.
769</p>
770</dd>
771<dt><code>--keep-symbols=<var>filename</var></code></dt>
772<dd><p>Apply <samp>--keep-symbol</samp> option to each symbol listed in the file
773<var>filename</var>.  <var>filename</var> is simply a flat file, with one symbol
774name per line.  Line comments may be introduced by the hash character.
775This option may be given more than once.
776</p>
777</dd>
778<dt><code>--strip-symbols=<var>filename</var></code></dt>
779<dd><p>Apply <samp>--strip-symbol</samp> option to each symbol listed in the file
780<var>filename</var>.  <var>filename</var> is simply a flat file, with one symbol
781name per line.  Line comments may be introduced by the hash character.
782This option may be given more than once.
783</p>
784</dd>
785<dt><code>--strip-unneeded-symbols=<var>filename</var></code></dt>
786<dd><p>Apply <samp>--strip-unneeded-symbol</samp> option to each symbol listed in
787the file <var>filename</var>.  <var>filename</var> is simply a flat file, with one
788symbol name per line.  Line comments may be introduced by the hash
789character.  This option may be given more than once.
790</p>
791</dd>
792<dt><code>--keep-global-symbols=<var>filename</var></code></dt>
793<dd><p>Apply <samp>--keep-global-symbol</samp> option to each symbol listed in the
794file <var>filename</var>.  <var>filename</var> is simply a flat file, with one
795symbol name per line.  Line comments may be introduced by the hash
796character.  This option may be given more than once.
797</p>
798</dd>
799<dt><code>--localize-symbols=<var>filename</var></code></dt>
800<dd><p>Apply <samp>--localize-symbol</samp> option to each symbol listed in the file
801<var>filename</var>.  <var>filename</var> is simply a flat file, with one symbol
802name per line.  Line comments may be introduced by the hash character.
803This option may be given more than once.
804</p>
805</dd>
806<dt><code>--globalize-symbols=<var>filename</var></code></dt>
807<dd><p>Apply <samp>--globalize-symbol</samp> option to each symbol listed in the file
808<var>filename</var>.  <var>filename</var> is simply a flat file, with one symbol
809name per line.  Line comments may be introduced by the hash character.
810This option may be given more than once.  Note: this option cannot be
811used in conjunction with the <samp>-G</samp> or <samp>--keep-global-symbol</samp>
812options.
813</p>
814</dd>
815<dt><code>--weaken-symbols=<var>filename</var></code></dt>
816<dd><p>Apply <samp>--weaken-symbol</samp> option to each symbol listed in the file
817<var>filename</var>.  <var>filename</var> is simply a flat file, with one symbol
818name per line.  Line comments may be introduced by the hash character.
819This option may be given more than once.
820</p>
821</dd>
822<dt><code>--alt-machine-code=<var>index</var></code></dt>
823<dd><p>If the output architecture has alternate machine codes, use the
824<var>index</var>th code instead of the default one.  This is useful in case
825a machine is assigned an official code and the tool-chain adopts the
826new code, but other applications still depend on the original code
827being used.  For ELF based architectures if the <var>index</var>
828alternative does not exist then the value is treated as an absolute
829number to be stored in the e_machine field of the ELF header.
830</p>
831</dd>
832<dt><code>--writable-text</code></dt>
833<dd><p>Mark the output text as writable.  This option isn&rsquo;t meaningful for all
834object file formats.
835</p>
836</dd>
837<dt><code>--readonly-text</code></dt>
838<dd><p>Make the output text write protected.  This option isn&rsquo;t meaningful for all
839object file formats.
840</p>
841</dd>
842<dt><code>--pure</code></dt>
843<dd><p>Mark the output file as demand paged.  This option isn&rsquo;t meaningful for all
844object file formats.
845</p>
846</dd>
847<dt><code>--impure</code></dt>
848<dd><p>Mark the output file as impure.  This option isn&rsquo;t meaningful for all
849object file formats.
850</p>
851</dd>
852<dt><code>--prefix-symbols=<var>string</var></code></dt>
853<dd><p>Prefix all symbols in the output file with <var>string</var>.
854</p>
855</dd>
856<dt><code>--prefix-sections=<var>string</var></code></dt>
857<dd><p>Prefix all section names in the output file with <var>string</var>.
858</p>
859</dd>
860<dt><code>--prefix-alloc-sections=<var>string</var></code></dt>
861<dd><p>Prefix all the names of all allocated sections in the output file with
862<var>string</var>.
863</p>
864</dd>
865<dt><code>--add-gnu-debuglink=<var>path-to-file</var></code></dt>
866<dd><p>Creates a .gnu_debuglink section which contains a reference to
867<var>path-to-file</var> and adds it to the output file.  Note: the file at
868<var>path-to-file</var> must exist.  Part of the process of adding the
869.gnu_debuglink section involves embedding a checksum of the contents
870of the debug info file into the section.
871</p>
872<p>If the debug info file is built in one location but it is going to be
873installed at a later time into a different location then do not use
874the path to the installed location.  The <samp>--add-gnu-debuglink</samp>
875option will fail because the installed file does not exist yet.
876Instead put the debug info file in the current directory and use the
877<samp>--add-gnu-debuglink</samp> option without any directory components,
878like this:
879</p>
880<div class="smallexample">
881<pre class="smallexample"> objcopy --add-gnu-debuglink=foo.debug
882</pre></div>
883
884<p>At debug time the debugger will attempt to look for the separate debug
885info file in a set of known locations.  The exact set of these
886locations varies depending upon the distribution being used, but it
887typically includes:
888</p>
889<dl compact="compact">
890<dt><code>* The same directory as the executable.</code></dt>
891<dt><code>* A sub-directory of the directory containing the executable</code></dt>
892<dd><p>called .debug
893</p>
894</dd>
895<dt><code>* A global debug directory such as /usr/lib/debug.</code></dt>
896</dl>
897
898<p>As long as the debug info file has been installed into one of these
899locations before the debugger is run everything should work
900correctly.
901</p>
902</dd>
903<dt><code>--keep-file-symbols</code></dt>
904<dd><p>When stripping a file, perhaps with <samp>--strip-debug</samp> or
905<samp>--strip-unneeded</samp>, retain any symbols specifying source file names,
906which would otherwise get stripped.
907</p>
908</dd>
909<dt><code>--only-keep-debug</code></dt>
910<dd><p>Strip a file, removing contents of any sections that would not be
911stripped by <samp>--strip-debug</samp> and leaving the debugging sections
912intact.  In ELF files, this preserves all note sections in the output.
913</p>
914<p>Note - the section headers of the stripped sections are preserved,
915including their sizes, but the contents of the section are discarded.
916The section headers are preserved so that other tools can match up the
917debuginfo file with the real executable, even if that executable has
918been relocated to a different address space.
919</p>
920<p>The intention is that this option will be used in conjunction with
921<samp>--add-gnu-debuglink</samp> to create a two part executable.  One a
922stripped binary which will occupy less space in RAM and in a
923distribution and the second a debugging information file which is only
924needed if debugging abilities are required.  The suggested procedure
925to create these files is as follows:
926</p>
927<ol>
928<li> Link the executable as normal.  Assuming that it is called
929<code>foo</code> then...
930</li><li> Run <code>objcopy --only-keep-debug foo foo.dbg</code> to
931create a file containing the debugging info.
932</li><li> Run <code>objcopy --strip-debug foo</code> to create a
933stripped executable.
934</li><li> Run <code>objcopy --add-gnu-debuglink=foo.dbg foo</code>
935to add a link to the debugging info into the stripped executable.
936</li></ol>
937
938<p>Note&mdash;the choice of <code>.dbg</code> as an extension for the debug info
939file is arbitrary.  Also the <code>--only-keep-debug</code> step is
940optional.  You could instead do this:
941</p>
942<ol>
943<li> Link the executable as normal.
944</li><li> Copy <code>foo</code> to  <code>foo.full</code>
945</li><li> Run <code>objcopy --strip-debug foo</code>
946</li><li> Run <code>objcopy --add-gnu-debuglink=foo.full foo</code>
947</li></ol>
948
949<p>i.e., the file pointed to by the <samp>--add-gnu-debuglink</samp> can be the
950full executable.  It does not have to be a file created by the
951<samp>--only-keep-debug</samp> switch.
952</p>
953<p>Note&mdash;this switch is only intended for use on fully linked files.  It
954does not make sense to use it on object files where the debugging
955information may be incomplete.  Besides the gnu_debuglink feature
956currently only supports the presence of one filename containing
957debugging information, not multiple filenames on a one-per-object-file
958basis.
959</p>
960</dd>
961<dt><code>--strip-dwo</code></dt>
962<dd><p>Remove the contents of all DWARF .dwo sections, leaving the
963remaining debugging sections and all symbols intact.
964This option is intended for use by the compiler as part of
965the <samp>-gsplit-dwarf</samp> option, which splits debug information
966between the .o file and a separate .dwo file.  The compiler
967generates all debug information in the same file, then uses
968the <samp>--extract-dwo</samp> option to copy the .dwo sections to
969the .dwo file, then the <samp>--strip-dwo</samp> option to remove
970those sections from the original .o file.
971</p>
972</dd>
973<dt><code>--extract-dwo</code></dt>
974<dd><p>Extract the contents of all DWARF .dwo sections.  See the
975<samp>--strip-dwo</samp> option for more information.
976</p>
977</dd>
978<dt><code>--file-alignment <var>num</var></code></dt>
979<dd><p>Specify the file alignment.  Sections in the file will always begin at
980file offsets which are multiples of this number.  This defaults to
981512.
982[This option is specific to PE targets.]
983</p>
984</dd>
985<dt><code>--heap <var>reserve</var></code></dt>
986<dt><code>--heap <var>reserve</var>,<var>commit</var></code></dt>
987<dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
988to be used as heap for this program.
989[This option is specific to PE targets.]
990</p>
991</dd>
992<dt><code>--image-base <var>value</var></code></dt>
993<dd><p>Use <var>value</var> as the base address of your program or dll.  This is
994the lowest memory location that will be used when your program or dll
995is loaded.  To reduce the need to relocate and improve performance of
996your dlls, each should have a unique base address and not overlap any
997other dlls.  The default is 0x400000 for executables, and 0x10000000
998for dlls.
999[This option is specific to PE targets.]
1000</p>
1001</dd>
1002<dt><code>--section-alignment <var>num</var></code></dt>
1003<dd><p>Sets the section alignment field in the PE header.  Sections in memory
1004will always begin at addresses which are a multiple of this number.
1005Defaults to 0x1000.
1006[This option is specific to PE targets.]
1007</p>
1008</dd>
1009<dt><code>--stack <var>reserve</var></code></dt>
1010<dt><code>--stack <var>reserve</var>,<var>commit</var></code></dt>
1011<dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
1012to be used as stack for this program.
1013[This option is specific to PE targets.]
1014</p>
1015</dd>
1016<dt><code>--subsystem <var>which</var></code></dt>
1017<dt><code>--subsystem <var>which</var>:<var>major</var></code></dt>
1018<dt><code>--subsystem <var>which</var>:<var>major</var>.<var>minor</var></code></dt>
1019<dd><p>Specifies the subsystem under which your program will execute.  The
1020legal values for <var>which</var> are <code>native</code>, <code>windows</code>,
1021<code>console</code>, <code>posix</code>, <code>efi-app</code>, <code>efi-bsd</code>,
1022<code>efi-rtd</code>, <code>sal-rtd</code>, and <code>xbox</code>.  You may optionally set
1023the subsystem version also.  Numeric values are also accepted for
1024<var>which</var>.
1025[This option is specific to PE targets.]
1026</p>
1027</dd>
1028<dt><code>--extract-symbol</code></dt>
1029<dd><p>Keep the file&rsquo;s section flags and symbols but remove all section data.
1030Specifically, the option:
1031</p>
1032<ul>
1033<li> removes the contents of all sections;
1034</li><li> sets the size of every section to zero; and
1035</li><li> sets the file&rsquo;s start address to zero.
1036</li></ul>
1037
1038<p>This option is used to build a <samp>.sym</samp> file for a VxWorks kernel.
1039It can also be a useful way of reducing the size of a <samp>--just-symbols</samp>
1040linker input file.
1041</p>
1042</dd>
1043<dt><code>--compress-debug-sections</code></dt>
1044<dd><p>Compress DWARF debug sections using zlib with SHF_COMPRESSED from the
1045ELF ABI.  Note - if compression would actually make a section
1046<em>larger</em>, then it is not compressed.
1047</p>
1048</dd>
1049<dt><code>--compress-debug-sections=none</code></dt>
1050<dt><code>--compress-debug-sections=zlib</code></dt>
1051<dt><code>--compress-debug-sections=zlib-gnu</code></dt>
1052<dt><code>--compress-debug-sections=zlib-gabi</code></dt>
1053<dd><p>For ELF files, these options control how DWARF debug sections are
1054compressed.  <samp>--compress-debug-sections=none</samp> is equivalent
1055to <samp>--decompress-debug-sections</samp>.
1056<samp>--compress-debug-sections=zlib</samp> and
1057<samp>--compress-debug-sections=zlib-gabi</samp> are equivalent to
1058<samp>--compress-debug-sections</samp>.
1059<samp>--compress-debug-sections=zlib-gnu</samp> compresses DWARF debug
1060sections using zlib.  The debug sections are renamed to begin with
1061&lsquo;<samp>.zdebug</samp>&rsquo; instead of &lsquo;<samp>.debug</samp>&rsquo;.  Note - if compression would
1062actually make a section <em>larger</em>, then it is not compressed nor
1063renamed.
1064</p>
1065</dd>
1066<dt><code>--decompress-debug-sections</code></dt>
1067<dd><p>Decompress DWARF debug sections using zlib.  The original section
1068names of the compressed sections are restored.
1069</p>
1070</dd>
1071<dt><code>--elf-stt-common=yes</code></dt>
1072<dt><code>--elf-stt-common=no</code></dt>
1073<dd><p>For ELF files, these options control whether common symbols should be
1074converted to the <code>STT_COMMON</code> or <code>STT_OBJECT</code> type.
1075<samp>--elf-stt-common=yes</samp> converts common symbol type to
1076<code>STT_COMMON</code>. <samp>--elf-stt-common=no</samp> converts common symbol
1077type to <code>STT_OBJECT</code>.
1078</p>
1079</dd>
1080<dt><code>--merge-notes</code></dt>
1081<dt><code>--no-merge-notes</code></dt>
1082<dd><p>For ELF files, attempt (or do not attempt) to reduce the size of any
1083SHT_NOTE type sections by removing duplicate notes.
1084</p>
1085</dd>
1086<dt><code>-V</code></dt>
1087<dt><code>--version</code></dt>
1088<dd><p>Show the version number of <code>objcopy</code>.
1089</p>
1090</dd>
1091<dt><code>--verilog-data-width=<var>bytes</var></code></dt>
1092<dd><p>For Verilog output, this options controls the number of bytes
1093converted for each output data element.  The input target controls the
1094endianness of the conversion.
1095</p>
1096</dd>
1097<dt><code>-v</code></dt>
1098<dt><code>--verbose</code></dt>
1099<dd><p>Verbose output: list all object files modified.  In the case of
1100archives, &lsquo;<samp>objcopy -V</samp>&rsquo; lists all members of the archive.
1101</p>
1102</dd>
1103<dt><code>--help</code></dt>
1104<dd><p>Show a summary of the options to <code>objcopy</code>.
1105</p>
1106</dd>
1107<dt><code>--info</code></dt>
1108<dd><p>Display a list showing all architectures and object formats available.
1109</p></dd>
1110</dl>
1111
1112
1113
1114<hr>
1115<div class="header">
1116<p>
1117Next: <a href="objdump.html#objdump" accesskey="n" rel="next">objdump</a>, Previous: <a href="nm.html#nm" accesskey="p" rel="previous">nm</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>
1118</div>
1119
1120
1121
1122</body>
1123</html>
1124