Debian Codegraph @

upstream/opensuse-tumbleweed/man1/objcopy.1

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