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