1OBJCOPY(1)                   GNU Development Tools                  OBJCOPY(1)
2
3
4

NAME

6       objcopy - copy and translate object files
7

SYNOPSIS

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               [--globalize-symbols=filename]
24               [-W symbolname|--weaken-symbol=symbolname]
25               [-w|--wildcard]
26               [-x|--discard-all]
27               [-X|--discard-locals]
28               [-b byte|--byte=byte]
29               [-i [breadth]|--interleave[=breadth]]
30               [--interleave-width=width]
31               [-j sectionpattern|--only-section=sectionpattern]
32               [-R sectionpattern|--remove-section=sectionpattern]
33               [--keep-section=sectionpattern]
34               [--remove-relocations=sectionpattern]
35               [-p|--preserve-dates]
36               [-D|--enable-deterministic-archives]
37               [-U|--disable-deterministic-archives]
38               [--debugging]
39               [--gap-fill=val]
40               [--pad-to=address]
41               [--set-start=val]
42               [--adjust-start=incr]
43               [--change-addresses=incr]
44               [--change-section-address sectionpattern{=,+,-}val]
45               [--change-section-lma sectionpattern{=,+,-}val]
46               [--change-section-vma sectionpattern{=,+,-}val]
47               [--change-warnings] [--no-change-warnings]
48               [--set-section-flags sectionpattern=flags]
49               [--set-section-alignment sectionpattern=align]
50               [--add-section sectionname=filename]
51               [--dump-section sectionname=filename]
52               [--update-section sectionname=filename]
53               [--rename-section oldname=newname[,flags]]
54               [--long-section-names {enable,disable,keep}]
55               [--change-leading-char] [--remove-leading-char]
56               [--reverse-bytes=num]
57               [--srec-len=ival] [--srec-forceS3]
58               [--redefine-sym old=new]
59               [--redefine-syms=filename]
60               [--weaken]
61               [--keep-symbols=filename]
62               [--strip-symbols=filename]
63               [--strip-unneeded-symbols=filename]
64               [--keep-global-symbols=filename]
65               [--localize-symbols=filename]
66               [--weaken-symbols=filename]
67               [--add-symbol name=[section:]value[,flags]]
68               [--alt-machine-code=index]
69               [--prefix-symbols=string]
70               [--prefix-sections=string]
71               [--prefix-alloc-sections=string]
72               [--add-gnu-debuglink=path-to-file]
73               [--keep-file-symbols]
74               [--only-keep-debug]
75               [--strip-dwo]
76               [--extract-dwo]
77               [--extract-symbol]
78               [--writable-text]
79               [--readonly-text]
80               [--pure]
81               [--impure]
82               [--file-alignment=num]
83               [--heap=size]
84               [--image-base=address]
85               [--section-alignment=num]
86               [--stack=size]
87               [--subsystem=which:major.minor]
88               [--compress-debug-sections]
89               [--decompress-debug-sections]
90               [--elf-stt-common=val]
91               [--merge-notes]
92               [--no-merge-notes]
93               [--verilog-data-width=val]
94               [-v|--verbose]
95               [-V|--version]
96               [--help] [--info]
97               infile [outfile]
98

DESCRIPTION

100       The GNU objcopy utility copies the contents of an object file to
101       another.  objcopy uses the GNU BFD Library to read and write the object
102       files.  It can write the destination object file in a format different
103       from that of the source object file.  The exact behavior of objcopy is
104       controlled by command-line options.  Note that objcopy should be able
105       to copy a fully linked file between any two formats. However, copying a
106       relocatable object file between any two formats may not work as
107       expected.
108
109       objcopy creates temporary files to do its translations and deletes them
110       afterward.  objcopy uses BFD to do all its translation work; it has
111       access to all the formats described in BFD and thus is able to
112       recognize most formats without being told explicitly.
113
114       objcopy can be used to generate S-records by using an output target of
115       srec (e.g., use -O srec).
116
117       objcopy can be used to generate a raw binary file by using an output
118       target of binary (e.g., use -O binary).  When objcopy generates a raw
119       binary file, it will essentially produce a memory dump of the contents
120       of the input object file.  All symbols and relocation information will
121       be discarded.  The memory dump will start at the load address of the
122       lowest section copied into the output file.
123
124       When generating an S-record or a raw binary file, it may be helpful to
125       use -S to remove sections containing debugging information.  In some
126       cases -R will be useful to remove sections which contain information
127       that is not needed by the binary file.
128
129       Note---objcopy is not able to change the endianness of its input files.
130       If the input format has an endianness (some formats do not), objcopy
131       can only copy the inputs into file formats that have the same
132       endianness or which have no endianness (e.g., srec).  (However, see the
133       --reverse-bytes option.)
134

OPTIONS

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

SEE ALSO

921       ld(1), objdump(1), and the Info entries for binutils.
922
924       Copyright (c) 1991-2020 Free Software Foundation, Inc.
925
926       Permission is granted to copy, distribute and/or modify this document
927       under the terms of the GNU Free Documentation License, Version 1.3 or
928       any later version published by the Free Software Foundation; with no
929       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
930       Texts.  A copy of the license is included in the section entitled "GNU
931       Free Documentation License".
932
933
934
935binutils-2.34                     2021-04-12                        OBJCOPY(1)
Impressum