]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - gnu/usr.bin/binutils/objcopy/objcopy.1
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / gnu / usr.bin / binutils / objcopy / objcopy.1
1 .\" $FreeBSD$
2 .\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" Set up some character translations and predefined strings.  \*(-- will
20 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
21 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
22 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
23 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
24 .\" nothing in troff, for use with C<>.
25 .tr \(*W-
26 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
27 .ie n \{\
28 .    ds -- \(*W-
29 .    ds PI pi
30 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
31 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
32 .    ds L" ""
33 .    ds R" ""
34 .    ds C` ""
35 .    ds C' ""
36 'br\}
37 .el\{\
38 .    ds -- \|\(em\|
39 .    ds PI \(*p
40 .    ds L" ``
41 .    ds R" ''
42 'br\}
43 .\"
44 .\" Escape single quotes in literal strings from groff's Unicode transform.
45 .ie \n(.g .ds Aq \(aq
46 .el       .ds Aq '
47 .\"
48 .\" If the F register is turned on, we'll generate index entries on stderr for
49 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
50 .\" entries marked with X<> in POD.  Of course, you'll have to process the
51 .\" output yourself in some meaningful fashion.
52 .ie \nF \{\
53 .    de IX
54 .    tm Index:\\$1\t\\n%\t"\\$2"
55 ..
56 .    nr % 0
57 .    rr F
58 .\}
59 .el \{\
60 .    de IX
61 ..
62 .\}
63 .\"
64 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
65 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
66 .    \" fudge factors for nroff and troff
67 .if n \{\
68 .    ds #H 0
69 .    ds #V .8m
70 .    ds #F .3m
71 .    ds #[ \f1
72 .    ds #] \fP
73 .\}
74 .if t \{\
75 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
76 .    ds #V .6m
77 .    ds #F 0
78 .    ds #[ \&
79 .    ds #] \&
80 .\}
81 .    \" simple accents for nroff and troff
82 .if n \{\
83 .    ds ' \&
84 .    ds ` \&
85 .    ds ^ \&
86 .    ds , \&
87 .    ds ~ ~
88 .    ds /
89 .\}
90 .if t \{\
91 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
92 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
93 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
94 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
95 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
96 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
97 .\}
98 .    \" troff and (daisy-wheel) nroff accents
99 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
100 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
101 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
102 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
103 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
104 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
105 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
106 .ds ae a\h'-(\w'a'u*4/10)'e
107 .ds Ae A\h'-(\w'A'u*4/10)'E
108 .    \" corrections for vroff
109 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
110 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
111 .    \" for low resolution devices (crt and lpr)
112 .if \n(.H>23 .if \n(.V>19 \
113 \{\
114 .    ds : e
115 .    ds 8 ss
116 .    ds o a
117 .    ds d- d\h'-1'\(ga
118 .    ds D- D\h'-1'\(hy
119 .    ds th \o'bp'
120 .    ds Th \o'LP'
121 .    ds ae ae
122 .    ds Ae AE
123 .\}
124 .rm #[ #] #H #V #F C
125 .\" ========================================================================
126 .\"
127 .IX Title "OBJCOPY 1"
128 .TH OBJCOPY 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
129 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
130 .\" way too many mistakes in technical documents.
131 .if n .ad l
132 .nh
133 .SH "NAME"
134 objcopy \- copy and translate object files
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 objcopy [\fB\-F\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR]
138         [\fB\-I\fR \fIbfdname\fR|\fB\-\-input\-target=\fR\fIbfdname\fR]
139         [\fB\-O\fR \fIbfdname\fR|\fB\-\-output\-target=\fR\fIbfdname\fR]
140         [\fB\-B\fR \fIbfdarch\fR|\fB\-\-binary\-architecture=\fR\fIbfdarch\fR]
141         [\fB\-S\fR|\fB\-\-strip\-all\fR]
142         [\fB\-g\fR|\fB\-\-strip\-debug\fR]
143         [\fB\-K\fR \fIsymbolname\fR|\fB\-\-keep\-symbol=\fR\fIsymbolname\fR]
144         [\fB\-N\fR \fIsymbolname\fR|\fB\-\-strip\-symbol=\fR\fIsymbolname\fR]
145         [\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR]
146         [\fB\-G\fR \fIsymbolname\fR|\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR]
147         [\fB\-\-localize\-hidden\fR]
148         [\fB\-L\fR \fIsymbolname\fR|\fB\-\-localize\-symbol=\fR\fIsymbolname\fR]
149         [\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR]
150         [\fB\-W\fR \fIsymbolname\fR|\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR]
151         [\fB\-w\fR|\fB\-\-wildcard\fR]
152         [\fB\-x\fR|\fB\-\-discard\-all\fR]
153         [\fB\-X\fR|\fB\-\-discard\-locals\fR]
154         [\fB\-b\fR \fIbyte\fR|\fB\-\-byte=\fR\fIbyte\fR]
155         [\fB\-i\fR \fIinterleave\fR|\fB\-\-interleave=\fR\fIinterleave\fR]
156         [\fB\-j\fR \fIsectionname\fR|\fB\-\-only\-section=\fR\fIsectionname\fR]
157         [\fB\-R\fR \fIsectionname\fR|\fB\-\-remove\-section=\fR\fIsectionname\fR]
158         [\fB\-p\fR|\fB\-\-preserve\-dates\fR]
159         [\fB\-\-debugging\fR]
160         [\fB\-\-gap\-fill=\fR\fIval\fR]
161         [\fB\-\-pad\-to=\fR\fIaddress\fR]
162         [\fB\-\-set\-start=\fR\fIval\fR]
163         [\fB\-\-adjust\-start=\fR\fIincr\fR]
164         [\fB\-\-change\-addresses=\fR\fIincr\fR]
165         [\fB\-\-change\-section\-address\fR \fIsection\fR{=,+,\-}\fIval\fR]
166         [\fB\-\-change\-section\-lma\fR \fIsection\fR{=,+,\-}\fIval\fR]
167         [\fB\-\-change\-section\-vma\fR \fIsection\fR{=,+,\-}\fIval\fR]
168         [\fB\-\-change\-warnings\fR] [\fB\-\-no\-change\-warnings\fR]
169         [\fB\-\-set\-section\-flags\fR \fIsection\fR=\fIflags\fR]
170         [\fB\-\-add\-section\fR \fIsectionname\fR=\fIfilename\fR]
171         [\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR[,\fIflags\fR]]
172         [\fB\-\-change\-leading\-char\fR] [\fB\-\-remove\-leading\-char\fR]
173         [\fB\-\-reverse\-bytes=\fR\fInum\fR]
174         [\fB\-\-srec\-len=\fR\fIival\fR] [\fB\-\-srec\-forceS3\fR]
175         [\fB\-\-redefine\-sym\fR \fIold\fR=\fInew\fR]
176         [\fB\-\-redefine\-syms=\fR\fIfilename\fR]
177         [\fB\-\-weaken\fR]
178         [\fB\-\-keep\-symbols=\fR\fIfilename\fR]
179         [\fB\-\-strip\-symbols=\fR\fIfilename\fR]
180         [\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR]
181         [\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR]
182         [\fB\-\-localize\-symbols=\fR\fIfilename\fR]
183         [\fB\-\-globalize\-symbols=\fR\fIfilename\fR]
184         [\fB\-\-weaken\-symbols=\fR\fIfilename\fR]
185         [\fB\-\-alt\-machine\-code=\fR\fIindex\fR]
186         [\fB\-\-prefix\-symbols=\fR\fIstring\fR]
187         [\fB\-\-prefix\-sections=\fR\fIstring\fR]
188         [\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR]
189         [\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR]
190         [\fB\-\-keep\-file\-symbols\fR]
191         [\fB\-\-only\-keep\-debug\fR]
192         [\fB\-\-extract\-symbol\fR]
193         [\fB\-\-writable\-text\fR]
194         [\fB\-\-readonly\-text\fR]
195         [\fB\-\-pure\fR]
196         [\fB\-\-impure\fR]
197         [\fB\-v\fR|\fB\-\-verbose\fR]
198         [\fB\-V\fR|\fB\-\-version\fR]
199         [\fB\-\-help\fR] [\fB\-\-info\fR]
200         \fIinfile\fR [\fIoutfile\fR]
201 .SH "DESCRIPTION"
202 .IX Header "DESCRIPTION"
203 The \s-1GNU\s0 \fBobjcopy\fR utility copies the contents of an object
204 file to another.  \fBobjcopy\fR uses the \s-1GNU\s0 \s-1BFD\s0 Library to
205 read and write the object files.  It can write the destination object
206 file in a format different from that of the source object file.  The
207 exact behavior of \fBobjcopy\fR is controlled by command-line options.
208 Note that \fBobjcopy\fR should be able to copy a fully linked file
209 between any two formats. However, copying a relocatable object file
210 between any two formats may not work as expected.
211 .PP
212 \&\fBobjcopy\fR creates temporary files to do its translations and
213 deletes them afterward.  \fBobjcopy\fR uses \s-1BFD\s0 to do all its
214 translation work; it has access to all the formats described in \s-1BFD\s0
215 and thus is able to recognize most formats without being told
216 explicitly.
217 .PP
218 \&\fBobjcopy\fR can be used to generate S\-records by using an output
219 target of \fBsrec\fR (e.g., use \fB\-O srec\fR).
220 .PP
221 \&\fBobjcopy\fR can be used to generate a raw binary file by using an
222 output target of \fBbinary\fR (e.g., use \fB\-O binary\fR).  When
223 \&\fBobjcopy\fR generates a raw binary file, it will essentially produce
224 a memory dump of the contents of the input object file.  All symbols and
225 relocation information will be discarded.  The memory dump will start at
226 the load address of the lowest section copied into the output file.
227 .PP
228 When generating an S\-record or a raw binary file, it may be helpful to
229 use \fB\-S\fR to remove sections containing debugging information.  In
230 some cases \fB\-R\fR will be useful to remove sections which contain
231 information that is not needed by the binary file.
232 .PP
233 Note\-\-\-\fBobjcopy\fR is not able to change the endianness of its input
234 files.  If the input format has an endianness (some formats do not),
235 \&\fBobjcopy\fR can only copy the inputs into file formats that have the
236 same endianness or which have no endianness (e.g., \fBsrec\fR).
237 (However, see the \fB\-\-reverse\-bytes\fR option.)
238 .SH "OPTIONS"
239 .IX Header "OPTIONS"
240 .IP "\fIinfile\fR" 4
241 .IX Item "infile"
242 .PD 0
243 .IP "\fIoutfile\fR" 4
244 .IX Item "outfile"
245 .PD
246 The input and output files, respectively.
247 If you do not specify \fIoutfile\fR, \fBobjcopy\fR creates a
248 temporary file and destructively renames the result with
249 the name of \fIinfile\fR.
250 .IP "\fB\-I\fR \fIbfdname\fR" 4
251 .IX Item "-I bfdname"
252 .PD 0
253 .IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4
254 .IX Item "--input-target=bfdname"
255 .PD
256 Consider the source file's object format to be \fIbfdname\fR, rather than
257 attempting to deduce it.
258 .IP "\fB\-O\fR \fIbfdname\fR" 4
259 .IX Item "-O bfdname"
260 .PD 0
261 .IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4
262 .IX Item "--output-target=bfdname"
263 .PD
264 Write the output file using the object format \fIbfdname\fR.
265 .IP "\fB\-F\fR \fIbfdname\fR" 4
266 .IX Item "-F bfdname"
267 .PD 0
268 .IP "\fB\-\-target=\fR\fIbfdname\fR" 4
269 .IX Item "--target=bfdname"
270 .PD
271 Use \fIbfdname\fR as the object format for both the input and the output
272 file; i.e., simply transfer data from source to destination with no
273 translation.
274 .IP "\fB\-B\fR \fIbfdarch\fR" 4
275 .IX Item "-B bfdarch"
276 .PD 0
277 .IP "\fB\-\-binary\-architecture=\fR\fIbfdarch\fR" 4
278 .IX Item "--binary-architecture=bfdarch"
279 .PD
280 Useful when transforming a raw binary input file into an object file.
281 In this case the output architecture can be set to \fIbfdarch\fR. This
282 option will be ignored if the input file has a known \fIbfdarch\fR. You
283 can access this binary data inside a program by referencing the special
284 symbols that are created by the conversion process.  These symbols are
285 called _binary_\fIobjfile\fR_start, _binary_\fIobjfile\fR_end and
286 _binary_\fIobjfile\fR_size.  e.g. you can transform a picture file into
287 an object file and then access it in your code using these symbols.
288 .IP "\fB\-j\fR \fIsectionname\fR" 4
289 .IX Item "-j sectionname"
290 .PD 0
291 .IP "\fB\-\-only\-section=\fR\fIsectionname\fR" 4
292 .IX Item "--only-section=sectionname"
293 .PD
294 Copy only the named section from the input file to the output file.
295 This option may be given more than once.  Note that using this option
296 inappropriately may make the output file unusable.
297 .IP "\fB\-R\fR \fIsectionname\fR" 4
298 .IX Item "-R sectionname"
299 .PD 0
300 .IP "\fB\-\-remove\-section=\fR\fIsectionname\fR" 4
301 .IX Item "--remove-section=sectionname"
302 .PD
303 Remove any section named \fIsectionname\fR from the output file.  This
304 option may be given more than once.  Note that using this option
305 inappropriately may make the output file unusable.
306 .IP "\fB\-S\fR" 4
307 .IX Item "-S"
308 .PD 0
309 .IP "\fB\-\-strip\-all\fR" 4
310 .IX Item "--strip-all"
311 .PD
312 Do not copy relocation and symbol information from the source file.
313 .IP "\fB\-g\fR" 4
314 .IX Item "-g"
315 .PD 0
316 .IP "\fB\-\-strip\-debug\fR" 4
317 .IX Item "--strip-debug"
318 .PD
319 Do not copy debugging symbols or sections from the source file.
320 .IP "\fB\-\-strip\-unneeded\fR" 4
321 .IX Item "--strip-unneeded"
322 Strip all symbols that are not needed for relocation processing.
323 .IP "\fB\-K\fR \fIsymbolname\fR" 4
324 .IX Item "-K symbolname"
325 .PD 0
326 .IP "\fB\-\-keep\-symbol=\fR\fIsymbolname\fR" 4
327 .IX Item "--keep-symbol=symbolname"
328 .PD
329 When stripping symbols, keep symbol \fIsymbolname\fR even if it would
330 normally be stripped.  This option may be given more than once.
331 .IP "\fB\-N\fR \fIsymbolname\fR" 4
332 .IX Item "-N symbolname"
333 .PD 0
334 .IP "\fB\-\-strip\-symbol=\fR\fIsymbolname\fR" 4
335 .IX Item "--strip-symbol=symbolname"
336 .PD
337 Do not copy symbol \fIsymbolname\fR from the source file.  This option
338 may be given more than once.
339 .IP "\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR" 4
340 .IX Item "--strip-unneeded-symbol=symbolname"
341 Do not copy symbol \fIsymbolname\fR from the source file unless it is needed
342 by a relocation.  This option may be given more than once.
343 .IP "\fB\-G\fR \fIsymbolname\fR" 4
344 .IX Item "-G symbolname"
345 .PD 0
346 .IP "\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR" 4
347 .IX Item "--keep-global-symbol=symbolname"
348 .PD
349 Keep only symbol \fIsymbolname\fR global.  Make all other symbols local
350 to the file, so that they are not visible externally.  This option may
351 be given more than once.
352 .IP "\fB\-\-localize\-hidden\fR" 4
353 .IX Item "--localize-hidden"
354 In an \s-1ELF\s0 object, mark all symbols that have hidden or internal visibility
355 as local.  This option applies on top of symbol-specific localization options
356 such as \fB\-L\fR.
357 .IP "\fB\-L\fR \fIsymbolname\fR" 4
358 .IX Item "-L symbolname"
359 .PD 0
360 .IP "\fB\-\-localize\-symbol=\fR\fIsymbolname\fR" 4
361 .IX Item "--localize-symbol=symbolname"
362 .PD
363 Make symbol \fIsymbolname\fR local to the file, so that it is not
364 visible externally.  This option may be given more than once.
365 .IP "\fB\-W\fR \fIsymbolname\fR" 4
366 .IX Item "-W symbolname"
367 .PD 0
368 .IP "\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR" 4
369 .IX Item "--weaken-symbol=symbolname"
370 .PD
371 Make symbol \fIsymbolname\fR weak. This option may be given more than once.
372 .IP "\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR" 4
373 .IX Item "--globalize-symbol=symbolname"
374 Give symbol \fIsymbolname\fR global scoping so that it is visible
375 outside of the file in which it is defined.  This option may be given
376 more than once.
377 .IP "\fB\-w\fR" 4
378 .IX Item "-w"
379 .PD 0
380 .IP "\fB\-\-wildcard\fR" 4
381 .IX Item "--wildcard"
382 .PD
383 Permit regular expressions in \fIsymbolname\fRs used in other command
384 line options.  The question mark (?), asterisk (*), backslash (\e) and
385 square brackets ([]) operators can be used anywhere in the symbol
386 name.  If the first character of the symbol name is the exclamation
387 point (!) then the sense of the switch is reversed for that symbol.
388 For example:
389 .Sp
390 .Vb 1
391 \&          \-w \-W !foo \-W fo*
392 .Ve
393 .Sp
394 would cause objcopy to weaken all symbols that start with \*(L"fo\*(R"
395 except for the symbol \*(L"foo\*(R".
396 .IP "\fB\-x\fR" 4
397 .IX Item "-x"
398 .PD 0
399 .IP "\fB\-\-discard\-all\fR" 4
400 .IX Item "--discard-all"
401 .PD
402 Do not copy non-global symbols from the source file.
403 .IP "\fB\-X\fR" 4
404 .IX Item "-X"
405 .PD 0
406 .IP "\fB\-\-discard\-locals\fR" 4
407 .IX Item "--discard-locals"
408 .PD
409 Do not copy compiler-generated local symbols.
410 (These usually start with \fBL\fR or \fB.\fR.)
411 .IP "\fB\-b\fR \fIbyte\fR" 4
412 .IX Item "-b byte"
413 .PD 0
414 .IP "\fB\-\-byte=\fR\fIbyte\fR" 4
415 .IX Item "--byte=byte"
416 .PD
417 Keep only every \fIbyte\fRth byte of the input file (header data is not
418 affected).  \fIbyte\fR can be in the range from 0 to \fIinterleave\fR\-1,
419 where \fIinterleave\fR is given by the \fB\-i\fR or \fB\-\-interleave\fR
420 option, or the default of 4.  This option is useful for creating files
421 to program \s-1ROM\s0.  It is typically used with an \f(CW\*(C`srec\*(C'\fR output
422 target.
423 .IP "\fB\-i\fR \fIinterleave\fR" 4
424 .IX Item "-i interleave"
425 .PD 0
426 .IP "\fB\-\-interleave=\fR\fIinterleave\fR" 4
427 .IX Item "--interleave=interleave"
428 .PD
429 Only copy one out of every \fIinterleave\fR bytes.  Select which byte to
430 copy with the \fB\-b\fR or \fB\-\-byte\fR option.  The default is 4.
431 \&\fBobjcopy\fR ignores this option if you do not specify either \fB\-b\fR or
432 \&\fB\-\-byte\fR.
433 .IP "\fB\-p\fR" 4
434 .IX Item "-p"
435 .PD 0
436 .IP "\fB\-\-preserve\-dates\fR" 4
437 .IX Item "--preserve-dates"
438 .PD
439 Set the access and modification dates of the output file to be the same
440 as those of the input file.
441 .IP "\fB\-\-debugging\fR" 4
442 .IX Item "--debugging"
443 Convert debugging information, if possible.  This is not the default
444 because only certain debugging formats are supported, and the
445 conversion process can be time consuming.
446 .IP "\fB\-\-gap\-fill\fR \fIval\fR" 4
447 .IX Item "--gap-fill val"
448 Fill gaps between sections with \fIval\fR.  This operation applies to
449 the \fIload address\fR (\s-1LMA\s0) of the sections.  It is done by increasing
450 the size of the section with the lower address, and filling in the extra
451 space created with \fIval\fR.
452 .IP "\fB\-\-pad\-to\fR \fIaddress\fR" 4
453 .IX Item "--pad-to address"
454 Pad the output file up to the load address \fIaddress\fR.  This is
455 done by increasing the size of the last section.  The extra space is
456 filled in with the value specified by \fB\-\-gap\-fill\fR (default zero).
457 .IP "\fB\-\-set\-start\fR \fIval\fR" 4
458 .IX Item "--set-start val"
459 Set the start address of the new file to \fIval\fR.  Not all object file
460 formats support setting the start address.
461 .IP "\fB\-\-change\-start\fR \fIincr\fR" 4
462 .IX Item "--change-start incr"
463 .PD 0
464 .IP "\fB\-\-adjust\-start\fR \fIincr\fR" 4
465 .IX Item "--adjust-start incr"
466 .PD
467 Change the start address by adding \fIincr\fR.  Not all object file
468 formats support setting the start address.
469 .IP "\fB\-\-change\-addresses\fR \fIincr\fR" 4
470 .IX Item "--change-addresses incr"
471 .PD 0
472 .IP "\fB\-\-adjust\-vma\fR \fIincr\fR" 4
473 .IX Item "--adjust-vma incr"
474 .PD
475 Change the \s-1VMA\s0 and \s-1LMA\s0 addresses of all sections, as well as the start
476 address, by adding \fIincr\fR.  Some object file formats do not permit
477 section addresses to be changed arbitrarily.  Note that this does not
478 relocate the sections; if the program expects sections to be loaded at a
479 certain address, and this option is used to change the sections such
480 that they are loaded at a different address, the program may fail.
481 .IP "\fB\-\-change\-section\-address\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4
482 .IX Item "--change-section-address section{=,+,-}val"
483 .PD 0
484 .IP "\fB\-\-adjust\-section\-vma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4
485 .IX Item "--adjust-section-vma section{=,+,-}val"
486 .PD
487 Set or change both the \s-1VMA\s0 address and the \s-1LMA\s0 address of the named
488 \&\fIsection\fR.  If \fB=\fR is used, the section address is set to
489 \&\fIval\fR.  Otherwise, \fIval\fR is added to or subtracted from the
490 section address.  See the comments under \fB\-\-change\-addresses\fR,
491 above. If \fIsection\fR does not exist in the input file, a warning will
492 be issued, unless \fB\-\-no\-change\-warnings\fR is used.
493 .IP "\fB\-\-change\-section\-lma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4
494 .IX Item "--change-section-lma section{=,+,-}val"
495 Set or change the \s-1LMA\s0 address of the named \fIsection\fR.  The \s-1LMA\s0
496 address is the address where the section will be loaded into memory at
497 program load time.  Normally this is the same as the \s-1VMA\s0 address, which
498 is the address of the section at program run time, but on some systems,
499 especially those where a program is held in \s-1ROM\s0, the two can be
500 different.  If \fB=\fR is used, the section address is set to
501 \&\fIval\fR.  Otherwise, \fIval\fR is added to or subtracted from the
502 section address.  See the comments under \fB\-\-change\-addresses\fR,
503 above.  If \fIsection\fR does not exist in the input file, a warning
504 will be issued, unless \fB\-\-no\-change\-warnings\fR is used.
505 .IP "\fB\-\-change\-section\-vma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4
506 .IX Item "--change-section-vma section{=,+,-}val"
507 Set or change the \s-1VMA\s0 address of the named \fIsection\fR.  The \s-1VMA\s0
508 address is the address where the section will be located once the
509 program has started executing.  Normally this is the same as the \s-1LMA\s0
510 address, which is the address where the section will be loaded into
511 memory, but on some systems, especially those where a program is held in
512 \&\s-1ROM\s0, the two can be different.  If \fB=\fR is used, the section address
513 is set to \fIval\fR.  Otherwise, \fIval\fR is added to or subtracted
514 from the section address.  See the comments under
515 \&\fB\-\-change\-addresses\fR, above.  If \fIsection\fR does not exist in
516 the input file, a warning will be issued, unless
517 \&\fB\-\-no\-change\-warnings\fR is used.
518 .IP "\fB\-\-change\-warnings\fR" 4
519 .IX Item "--change-warnings"
520 .PD 0
521 .IP "\fB\-\-adjust\-warnings\fR" 4
522 .IX Item "--adjust-warnings"
523 .PD
524 If \fB\-\-change\-section\-address\fR or \fB\-\-change\-section\-lma\fR or
525 \&\fB\-\-change\-section\-vma\fR is used, and the named section does not
526 exist, issue a warning.  This is the default.
527 .IP "\fB\-\-no\-change\-warnings\fR" 4
528 .IX Item "--no-change-warnings"
529 .PD 0
530 .IP "\fB\-\-no\-adjust\-warnings\fR" 4
531 .IX Item "--no-adjust-warnings"
532 .PD
533 Do not issue a warning if \fB\-\-change\-section\-address\fR or
534 \&\fB\-\-adjust\-section\-lma\fR or \fB\-\-adjust\-section\-vma\fR is used, even
535 if the named section does not exist.
536 .IP "\fB\-\-set\-section\-flags\fR \fIsection\fR\fB=\fR\fIflags\fR" 4
537 .IX Item "--set-section-flags section=flags"
538 Set the flags for the named section.  The \fIflags\fR argument is a
539 comma separated string of flag names.  The recognized names are
540 \&\fBalloc\fR, \fBcontents\fR, \fBload\fR, \fBnoload\fR,
541 \&\fBreadonly\fR, \fBcode\fR, \fBdata\fR, \fBrom\fR, \fBshare\fR, and
542 \&\fBdebug\fR.  You can set the \fBcontents\fR flag for a section which
543 does not have contents, but it is not meaningful to clear the
544 \&\fBcontents\fR flag of a section which does have contents\*(--just remove
545 the section instead.  Not all flags are meaningful for all object file
546 formats.
547 .IP "\fB\-\-add\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4
548 .IX Item "--add-section sectionname=filename"
549 Add a new section named \fIsectionname\fR while copying the file.  The
550 contents of the new section are taken from the file \fIfilename\fR.  The
551 size of the section will be the size of the file.  This option only
552 works on file formats which can support sections with arbitrary names.
553 .IP "\fB\-\-rename\-section\fR \fIoldname\fR\fB=\fR\fInewname\fR\fB[,\fR\fIflags\fR\fB]\fR" 4
554 .IX Item "--rename-section oldname=newname[,flags]"
555 Rename a section from \fIoldname\fR to \fInewname\fR, optionally
556 changing the section's flags to \fIflags\fR in the process.  This has
557 the advantage over usng a linker script to perform the rename in that
558 the output stays as an object file and does not become a linked
559 executable.
560 .Sp
561 This option is particularly helpful when the input format is binary,
562 since this will always create a section called .data.  If for example,
563 you wanted instead to create a section called .rodata containing binary
564 data you could use the following command line to achieve it:
565 .Sp
566 .Vb 3
567 \&          objcopy \-I binary \-O <output_format> \-B <architecture> \e
568 \&           \-\-rename\-section .data=.rodata,alloc,load,readonly,data,contents \e
569 \&           <input_binary_file> <output_object_file>
570 .Ve
571 .IP "\fB\-\-change\-leading\-char\fR" 4
572 .IX Item "--change-leading-char"
573 Some object file formats use special characters at the start of
574 symbols.  The most common such character is underscore, which compilers
575 often add before every symbol.  This option tells \fBobjcopy\fR to
576 change the leading character of every symbol when it converts between
577 object file formats.  If the object file formats use the same leading
578 character, this option has no effect.  Otherwise, it will add a
579 character, or remove a character, or change a character, as
580 appropriate.
581 .IP "\fB\-\-remove\-leading\-char\fR" 4
582 .IX Item "--remove-leading-char"
583 If the first character of a global symbol is a special symbol leading
584 character used by the object file format, remove the character.  The
585 most common symbol leading character is underscore.  This option will
586 remove a leading underscore from all global symbols.  This can be useful
587 if you want to link together objects of different file formats with
588 different conventions for symbol names.  This is different from
589 \&\fB\-\-change\-leading\-char\fR because it always changes the symbol name
590 when appropriate, regardless of the object file format of the output
591 file.
592 .IP "\fB\-\-reverse\-bytes=\fR\fInum\fR" 4
593 .IX Item "--reverse-bytes=num"
594 Reverse the bytes in a section with output contents.  A section length must
595 be evenly divisible by the value given in order for the swap to be able to
596 take place. Reversing takes place before the interleaving is performed.
597 .Sp
598 This option is used typically in generating \s-1ROM\s0 images for problematic
599 target systems.  For example, on some target boards, the 32\-bit words
600 fetched from 8\-bit ROMs are re-assembled in little-endian byte order
601 regardless of the \s-1CPU\s0 byte order.  Depending on the programming model, the
602 endianness of the \s-1ROM\s0 may need to be modified.
603 .Sp
604 Consider a simple file with a section containing the following eight
605 bytes:  \f(CW12345678\fR.
606 .Sp
607 Using \fB\-\-reverse\-bytes=2\fR for the above example, the bytes in the
608 output file would be ordered \f(CW21436587\fR.
609 .Sp
610 Using \fB\-\-reverse\-bytes=4\fR for the above example, the bytes in the
611 output file would be ordered \f(CW43218765\fR.
612 .Sp
613 By using \fB\-\-reverse\-bytes=2\fR for the above example, followed by
614 \&\fB\-\-reverse\-bytes=4\fR on the output file, the bytes in the second
615 output file would be ordered \f(CW34127856\fR.
616 .IP "\fB\-\-srec\-len=\fR\fIival\fR" 4
617 .IX Item "--srec-len=ival"
618 Meaningful only for srec output.  Set the maximum length of the Srecords
619 being produced to \fIival\fR.  This length covers both address, data and
620 crc fields.
621 .IP "\fB\-\-srec\-forceS3\fR" 4
622 .IX Item "--srec-forceS3"
623 Meaningful only for srec output.  Avoid generation of S1/S2 records,
624 creating S3\-only record format.
625 .IP "\fB\-\-redefine\-sym\fR \fIold\fR\fB=\fR\fInew\fR" 4
626 .IX Item "--redefine-sym old=new"
627 Change the name of a symbol \fIold\fR, to \fInew\fR.  This can be useful
628 when one is trying link two things together for which you have no
629 source, and there are name collisions.
630 .IP "\fB\-\-redefine\-syms=\fR\fIfilename\fR" 4
631 .IX Item "--redefine-syms=filename"
632 Apply \fB\-\-redefine\-sym\fR to each symbol pair "\fIold\fR \fInew\fR"
633 listed in the file \fIfilename\fR.  \fIfilename\fR is simply a flat file,
634 with one symbol pair per line.  Line comments may be introduced by the hash
635 character.  This option may be given more than once.
636 .IP "\fB\-\-weaken\fR" 4
637 .IX Item "--weaken"
638 Change all global symbols in the file to be weak.  This can be useful
639 when building an object which will be linked against other objects using
640 the \fB\-R\fR option to the linker.  This option is only effective when
641 using an object file format which supports weak symbols.
642 .IP "\fB\-\-keep\-symbols=\fR\fIfilename\fR" 4
643 .IX Item "--keep-symbols=filename"
644 Apply \fB\-\-keep\-symbol\fR option to each symbol listed in the file
645 \&\fIfilename\fR.  \fIfilename\fR is simply a flat file, with one symbol
646 name per line.  Line comments may be introduced by the hash character.
647 This option may be given more than once.
648 .IP "\fB\-\-strip\-symbols=\fR\fIfilename\fR" 4
649 .IX Item "--strip-symbols=filename"
650 Apply \fB\-\-strip\-symbol\fR option to each symbol listed in the file
651 \&\fIfilename\fR.  \fIfilename\fR is simply a flat file, with one symbol
652 name per line.  Line comments may be introduced by the hash character.
653 This option may be given more than once.
654 .IP "\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR" 4
655 .IX Item "--strip-unneeded-symbols=filename"
656 Apply \fB\-\-strip\-unneeded\-symbol\fR option to each symbol listed in
657 the file \fIfilename\fR.  \fIfilename\fR is simply a flat file, with one
658 symbol name per line.  Line comments may be introduced by the hash
659 character.  This option may be given more than once.
660 .IP "\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR" 4
661 .IX Item "--keep-global-symbols=filename"
662 Apply \fB\-\-keep\-global\-symbol\fR option to each symbol listed in the
663 file \fIfilename\fR.  \fIfilename\fR is simply a flat file, with one
664 symbol name per line.  Line comments may be introduced by the hash
665 character.  This option may be given more than once.
666 .IP "\fB\-\-localize\-symbols=\fR\fIfilename\fR" 4
667 .IX Item "--localize-symbols=filename"
668 Apply \fB\-\-localize\-symbol\fR option to each symbol listed in the file
669 \&\fIfilename\fR.  \fIfilename\fR is simply a flat file, with one symbol
670 name per line.  Line comments may be introduced by the hash character.
671 This option may be given more than once.
672 .IP "\fB\-\-globalize\-symbols=\fR\fIfilename\fR" 4
673 .IX Item "--globalize-symbols=filename"
674 Apply \fB\-\-globalize\-symbol\fR option to each symbol listed in the file
675 \&\fIfilename\fR.  \fIfilename\fR is simply a flat file, with one symbol
676 name per line.  Line comments may be introduced by the hash character.
677 This option may be given more than once.
678 .IP "\fB\-\-weaken\-symbols=\fR\fIfilename\fR" 4
679 .IX Item "--weaken-symbols=filename"
680 Apply \fB\-\-weaken\-symbol\fR option to each symbol listed in the file
681 \&\fIfilename\fR.  \fIfilename\fR is simply a flat file, with one symbol
682 name per line.  Line comments may be introduced by the hash character.
683 This option may be given more than once.
684 .IP "\fB\-\-alt\-machine\-code=\fR\fIindex\fR" 4
685 .IX Item "--alt-machine-code=index"
686 If the output architecture has alternate machine codes, use the
687 \&\fIindex\fRth code instead of the default one.  This is useful in case
688 a machine is assigned an official code and the tool-chain adopts the
689 new code, but other applications still depend on the original code
690 being used.  For \s-1ELF\s0 based architectures if the \fIindex\fR
691 alternative does not exist then the value is treated as an absolute
692 number to be stored in the e_machine field of the \s-1ELF\s0 header.
693 .IP "\fB\-\-writable\-text\fR" 4
694 .IX Item "--writable-text"
695 Mark the output text as writable.  This option isn't meaningful for all
696 object file formats.
697 .IP "\fB\-\-readonly\-text\fR" 4
698 .IX Item "--readonly-text"
699 Make the output text write protected.  This option isn't meaningful for all
700 object file formats.
701 .IP "\fB\-\-pure\fR" 4
702 .IX Item "--pure"
703 Mark the output file as demand paged.  This option isn't meaningful for all
704 object file formats.
705 .IP "\fB\-\-impure\fR" 4
706 .IX Item "--impure"
707 Mark the output file as impure.  This option isn't meaningful for all
708 object file formats.
709 .IP "\fB\-\-prefix\-symbols=\fR\fIstring\fR" 4
710 .IX Item "--prefix-symbols=string"
711 Prefix all symbols in the output file with \fIstring\fR.
712 .IP "\fB\-\-prefix\-sections=\fR\fIstring\fR" 4
713 .IX Item "--prefix-sections=string"
714 Prefix all section names in the output file with \fIstring\fR.
715 .IP "\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR" 4
716 .IX Item "--prefix-alloc-sections=string"
717 Prefix all the names of all allocated sections in the output file with
718 \&\fIstring\fR.
719 .IP "\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR" 4
720 .IX Item "--add-gnu-debuglink=path-to-file"
721 Creates a .gnu_debuglink section which contains a reference to \fIpath-to-file\fR
722 and adds it to the output file.
723 .IP "\fB\-\-keep\-file\-symbols\fR" 4
724 .IX Item "--keep-file-symbols"
725 When stripping a file, perhaps with \fB\-\-strip\-debug\fR or
726 \&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names,
727 which would otherwise get stripped.
728 .IP "\fB\-\-only\-keep\-debug\fR" 4
729 .IX Item "--only-keep-debug"
730 Strip a file, removing contents of any sections that would not be
731 stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections
732 intact.  In \s-1ELF\s0 files, this preserves all note sections in the output.
733 .Sp
734 The intention is that this option will be used in conjunction with
735 \&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable.  One a
736 stripped binary which will occupy less space in \s-1RAM\s0 and in a
737 distribution and the second a debugging information file which is only
738 needed if debugging abilities are required.  The suggested procedure
739 to create these files is as follows:
740 .RS 4
741 .IP "1.<Link the executable as normal.  Assuming that is is called>" 4
742 .IX Item "1.<Link the executable as normal.  Assuming that is is called>"
743 \&\f(CW\*(C`foo\*(C'\fR then...
744 .ie n .IP "1.<Run ""objcopy \-\-only\-keep\-debug foo foo.dbg"" to>" 4
745 .el .IP "1.<Run \f(CWobjcopy \-\-only\-keep\-debug foo foo.dbg\fR to>" 4
746 .IX Item "1.<Run objcopy --only-keep-debug foo foo.dbg to>"
747 create a file containing the debugging info.
748 .ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"" to create a>" 4
749 .el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR to create a>" 4
750 .IX Item "1.<Run objcopy --strip-debug foo to create a>"
751 stripped executable.
752 .ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.dbg foo"">" 4
753 .el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.dbg foo\fR>" 4
754 .IX Item "1.<Run objcopy --add-gnu-debuglink=foo.dbg foo>"
755 to add a link to the debugging info into the stripped executable.
756 .RE
757 .RS 4
758 .Sp
759 Note \- the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info
760 file is arbitrary.  Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is
761 optional.  You could instead do this:
762 .IP "1.<Link the executable as normal.>" 4
763 .IX Item "1.<Link the executable as normal.>"
764 .PD 0
765 .ie n .IP "1.<Copy ""foo"" to  ""foo.full"">" 4
766 .el .IP "1.<Copy \f(CWfoo\fR to  \f(CWfoo.full\fR>" 4
767 .IX Item "1.<Copy foo to  foo.full>"
768 .ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"">" 4
769 .el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR>" 4
770 .IX Item "1.<Run objcopy --strip-debug foo>"
771 .ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.full foo"">" 4
772 .el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.full foo\fR>" 4
773 .IX Item "1.<Run objcopy --add-gnu-debuglink=foo.full foo>"
774 .RE
775 .RS 4
776 .PD
777 .Sp
778 i.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the
779 full executable.  It does not have to be a file created by the
780 \&\fB\-\-only\-keep\-debug\fR switch.
781 .Sp
782 Note \- this switch is only intended for use on fully linked files.  It
783 does not make sense to use it on object files where the debugging
784 information may be incomplete.  Besides the gnu_debuglink feature
785 currently only supports the presence of one filename containing
786 debugging information, not multiple filenames on a one-per-object-file
787 basis.
788 .RE
789 .IP "\fB\-\-extract\-symbol\fR" 4
790 .IX Item "--extract-symbol"
791 Keep the file's section flags and symbols but remove all section data.
792 Specifically, the option:
793 .RS 4
794 .IP "*<sets the virtual and load addresses of every section to zero;>" 4
795 .IX Item "*<sets the virtual and load addresses of every section to zero;>"
796 .PD 0
797 .IP "*<removes the contents of all sections;>" 4
798 .IX Item "*<removes the contents of all sections;>"
799 .IP "*<sets the size of every section to zero; and>" 4
800 .IX Item "*<sets the size of every section to zero; and>"
801 .IP "*<sets the file's start address to zero.>" 4
802 .IX Item "*<sets the file's start address to zero.>"
803 .RE
804 .RS 4
805 .PD
806 .Sp
807 This option is used to build a \fI.sym\fR file for a VxWorks kernel.
808 It can also be a useful way of reducing the size of a \fB\-\-just\-symbols\fR
809 linker input file.
810 .RE
811 .IP "\fB\-V\fR" 4
812 .IX Item "-V"
813 .PD 0
814 .IP "\fB\-\-version\fR" 4
815 .IX Item "--version"
816 .PD
817 Show the version number of \fBobjcopy\fR.
818 .IP "\fB\-v\fR" 4
819 .IX Item "-v"
820 .PD 0
821 .IP "\fB\-\-verbose\fR" 4
822 .IX Item "--verbose"
823 .PD
824 Verbose output: list all object files modified.  In the case of
825 archives, \fBobjcopy \-V\fR lists all members of the archive.
826 .IP "\fB\-\-help\fR" 4
827 .IX Item "--help"
828 Show a summary of the options to \fBobjcopy\fR.
829 .IP "\fB\-\-info\fR" 4
830 .IX Item "--info"
831 Display a list showing all architectures and object formats available.
832 .IP "\fB@\fR\fIfile\fR" 4
833 .IX Item "@file"
834 Read command-line options from \fIfile\fR.  The options read are
835 inserted in place of the original @\fIfile\fR option.  If \fIfile\fR
836 does not exist, or cannot be read, then the option will be treated
837 literally, and not removed.
838 .Sp
839 Options in \fIfile\fR are separated by whitespace.  A whitespace
840 character may be included in an option by surrounding the entire
841 option in either single or double quotes.  Any character (including a
842 backslash) may be included by prefixing the character to be included
843 with a backslash.  The \fIfile\fR may itself contain additional
844 @\fIfile\fR options; any such options will be processed recursively.
845 .SH "SEE ALSO"
846 .IX Header "SEE ALSO"
847 \&\fIld\fR\|(1), \fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR.
848 .SH "COPYRIGHT"
849 .IX Header "COPYRIGHT"
850 Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
851 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
852 .PP
853 Permission is granted to copy, distribute and/or modify this document
854 under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
855 or any later version published by the Free Software Foundation;
856 with no Invariant Sections, with no Front-Cover Texts, and with no
857 Back-Cover Texts.  A copy of the license is included in the
858 section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".