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

DESCRIPTION

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

OPTIONS

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

SEE ALSO

935       ld(1), objdump(1), and the Info entries for binutils.
936
938       Copyright (c) 1991-2021 Free Software Foundation, Inc.
939
940       Permission is granted to copy, distribute and/or modify this document
941       under the terms of the GNU Free Documentation License, Version 1.3 or
942       any later version published by the Free Software Foundation; with no
943       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
944       Texts.  A copy of the license is included in the section entitled "GNU
945       Free Documentation License".
946
947
948
949binutils-2.37                     2022-03-10                        OBJCOPY(1)
Impressum