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

DESCRIPTION

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

OPTIONS

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

SEE ALSO

837       ld(1), objdump(1), and the Info entries for binutils.
838
840       Copyright (c) 1991-2015 Free Software Foundation, Inc.
841
842       Permission is granted to copy, distribute and/or modify this document
843       under the terms of the GNU Free Documentation License, Version 1.3 or
844       any later version published by the Free Software Foundation; with no
845       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
846       Texts.  A copy of the license is included in the section entitled "GNU
847       Free Documentation License".
848
849
850
851binutils-2.26                     2016-01-25                        OBJCOPY(1)
Impressum