Debian Codegraph @

upstream/debian-trixie/man1/objcopy.1

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