Debian Codegraph @

upstream/fedora-44/man1/objcopy.1

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