[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
objcopy [`-F' bfdname|`--target='bfdname] [`-I' bfdname|`--input-target='bfdname] [`-O' bfdname|`--output-target='bfdname] [`-B' bfdarch|`--binary-architecture='bfdarch] [`-S'|`--strip-all'] [`-g'|`--strip-debug'] [`-K' symbolname|`--keep-symbol='symbolname] [`-N' symbolname|`--strip-symbol='symbolname] [`--strip-unneeded-symbol='symbolname] [`-G' symbolname|`--keep-global-symbol='symbolname] [`--localize-hidden'] [`-L' symbolname|`--localize-symbol='symbolname] [`--globalize-symbol='symbolname] [`-W' symbolname|`--weaken-symbol='symbolname] [`-w'|`--wildcard'] [`-x'|`--discard-all'] [`-X'|`--discard-locals'] [`-b' byte|`--byte='byte] [`-i' [breadth]|`--interleave'[=breadth]] [`--interleave-width='width] [`-j' sectionpattern|`--only-section='sectionpattern] [`-R' sectionpattern|`--remove-section='sectionpattern] [`-p'|`--preserve-dates'] [`-D'|`--enable-deterministic-archives'] [`-U'|`--disable-deterministic-archives'] [`--debugging'] [`--gap-fill='val] [`--pad-to='address] [`--set-start='val] [`--adjust-start='incr] [`--change-addresses='incr] [`--change-section-address' sectionpattern{=,+,-}val] [`--change-section-lma' sectionpattern{=,+,-}val] [`--change-section-vma' sectionpattern{=,+,-}val] [`--change-warnings'] [`--no-change-warnings'] [`--set-section-flags' sectionpattern=flags] [`--add-section' sectionname=filename] [`--rename-section' oldname=newname[,flags]] [`--long-section-names' {enable,disable,keep}] [`--change-leading-char'] [`--remove-leading-char'] [`--reverse-bytes='num] [`--srec-len='ival] [`--srec-forceS3'] [`--redefine-sym' old=new] [`--redefine-syms='filename] [`--weaken'] [`--keep-symbols='filename] [`--strip-symbols='filename] [`--strip-unneeded-symbols='filename] [`--keep-global-symbols='filename] [`--localize-symbols='filename] [`--globalize-symbols='filename] [`--weaken-symbols='filename] [`--alt-machine-code='index] [`--prefix-symbols='string] [`--prefix-sections='string] [`--prefix-alloc-sections='string] [`--add-gnu-debuglink='path-to-file] [`--keep-file-symbols'] [`--only-keep-debug'] [`--strip-dwo'] [`--extract-dwo'] [`--extract-symbol'] [`--writable-text'] [`--readonly-text'] [`--pure'] [`--impure'] [`--file-alignment='num] [`--heap='size] [`--image-base='address] [`--section-alignment='num] [`--stack='size] [`--subsystem='which:major.minor] [`--compress-debug-sections'] [`--decompress-debug-sections'] [`--dwarf-depth=n'] [`--dwarf-start=n'] [`-v'|`--verbose'] [`-V'|`--version'] [`--help'] [`--info'] infile [outfile] |
The GNU objcopy
utility copies the contents of an object
file to another. objcopy
uses the GNU BFD Library to
read and write the object files. It can write the destination object
file in a format different from that of the source object file. The
exact behavior of objcopy
is controlled by command-line options.
Note that objcopy
should be able to copy a fully linked file
between any two formats. However, copying a relocatable object file
between any two formats may not work as expected.
objcopy
creates temporary files to do its translations and
deletes them afterward. objcopy
uses BFD to do all its
translation work; it has access to all the formats described in BFD
and thus is able to recognize most formats without being told
explicitly. See section `BFD' in Using LD.
objcopy
can be used to generate S-records by using an output
target of `srec' (e.g., use `-O srec').
objcopy
can be used to generate a raw binary file by using an
output target of `binary' (e.g., use `-O binary'). When
objcopy
generates a raw binary file, it will essentially produce
a memory dump of the contents of the input object file. All symbols and
relocation information will be discarded. The memory dump will start at
the load address of the lowest section copied into the output file.
When generating an S-record or a raw binary file, it may be helpful to use `-S' to remove sections containing debugging information. In some cases `-R' will be useful to remove sections which contain information that is not needed by the binary file.
Note---objcopy
is not able to change the endianness of its input
files. If the input format has an endianness (some formats do not),
objcopy
can only copy the inputs into file formats that have the
same endianness or which have no endianness (e.g., `srec').
(However, see the `--reverse-bytes' option.)
infile
outfile
objcopy
creates a
temporary file and destructively renames the result with
the name of infile.
-I bfdname
--input-target=bfdname
-O bfdname
--output-target=bfdname
-F bfdname
--target=bfdname
-B bfdarch
--binary-architecture=bfdarch
-j sectionpattern
--only-section=sectionpattern
-R sectionpattern
--remove-section=sectionpattern
-S
--strip-all
-g
--strip-debug
--strip-unneeded
-K symbolname
--keep-symbol=symbolname
-N symbolname
--strip-symbol=symbolname
--strip-unneeded-symbol=symbolname
-G symbolname
--keep-global-symbol=symbolname
--localize-hidden
-L symbolname
--localize-symbol=symbolname
-W symbolname
--weaken-symbol=symbolname
--globalize-symbol=symbolname
-w
--wildcard
-w -W !foo -W fo* |
would cause objcopy to weaken all symbols that start with "fo" except for the symbol "foo".
-x
--discard-all
-X
--discard-locals
-b byte
--byte=byte
-i [breadth]
--interleave[=breadth]
This option is useful for creating files to program ROM. It is
typically used with an srec
output target. Note that
objcopy
will complain if you do not specify the
`--byte' option as well.
The default interleave breadth is 4, so with `--byte' set to 0,
objcopy
would copy the first byte out of every four bytes
from the input to the output.
--interleave-width=width
The default value for this option is 1. The value of width plus the byte value set by the `--byte' option must not exceed the interleave breadth set by the `--interleave' option.
This option can be used to create images for two 16-bit flashes interleaved
in a 32-bit bus by passing `-b 0 -i 4 --interleave-width=2'
and `-b 2 -i 4 --interleave-width=2' to two objcopy
commands. If the input was '12345678' then the outputs would be
'1256' and '3478' respectively.
-p
--preserve-dates
-D
--enable-deterministic-archives
If `binutils' was configured with `--enable-deterministic-archives', then this mode is on by default. It can be disabled with the `-U' option, below.
-U
--disable-deterministic-archives
This is the default unless `binutils' was configured with `--enable-deterministic-archives'.
--debugging
--gap-fill val
--pad-to address
--set-start val
--change-start incr
--adjust-start incr
--change-addresses incr
--adjust-vma incr
--change-section-address sectionpattern{=,+,-}val
--adjust-section-vma sectionpattern{=,+,-}val
--change-section-lma sectionpattern{=,+,-}val
--change-section-vma sectionpattern{=,+,-}val
--change-warnings
--adjust-warnings
--no-change-warnings
--no-adjust-warnings
--set-section-flags sectionpattern=flags
--add-section sectionname=filename
--rename-section oldname=newname[,flags]
This option is particularly helpful when the input format is binary, since this will always create a section called .data. If for example, you wanted instead to create a section called .rodata containing binary data you could use the following command line to achieve it:
objcopy -I binary -O <output_format> -B <architecture> \ --rename-section .data=.rodata,alloc,load,readonly,data,contents \ <input_binary_file> <output_object_file> |
--long-section-names {enable,disable,keep}
COFF
and PE-COFF
object formats. The default behaviour, `keep',
is to preserve long section names if any are present in the input file.
The `enable' and `disable' options forcibly enable or disable
the use of long section names in the output object; when `disable'
is in effect, any long section names in the input object will be truncated.
The `enable' option will only emit long section names if any are
present in the inputs; this is mostly the same as `keep', but it
is left undefined whether the `enable' option might force the
creation of an empty string table in the output file.
--change-leading-char
objcopy
to
change the leading character of every symbol when it converts between
object file formats. If the object file formats use the same leading
character, this option has no effect. Otherwise, it will add a
character, or remove a character, or change a character, as
appropriate.
--remove-leading-char
--reverse-bytes=num
This option is used typically in generating ROM images for problematic target systems. For example, on some target boards, the 32-bit words fetched from 8-bit ROMs are re-assembled in little-endian byte order regardless of the CPU byte order. Depending on the programming model, the endianness of the ROM may need to be modified.
Consider a simple file with a section containing the following eight
bytes: 12345678
.
Using `--reverse-bytes=2' for the above example, the bytes in the
output file would be ordered 21436587
.
Using `--reverse-bytes=4' for the above example, the bytes in the
output file would be ordered 43218765
.
By using `--reverse-bytes=2' for the above example, followed by
`--reverse-bytes=4' on the output file, the bytes in the second
output file would be ordered 34127856
.
--srec-len=ival
--srec-forceS3
--redefine-sym old=new
--redefine-syms=filename
--weaken
--keep-symbols=filename
--strip-symbols=filename
--strip-unneeded-symbols=filename
--keep-global-symbols=filename
--localize-symbols=filename
--globalize-symbols=filename
--weaken-symbols=filename
--alt-machine-code=index
--writable-text
--readonly-text
--pure
--impure
--prefix-symbols=string
--prefix-sections=string
--prefix-alloc-sections=string
--add-gnu-debuglink=path-to-file
--keep-file-symbols
--only-keep-debug
The intention is that this option will be used in conjunction with `--add-gnu-debuglink' to create a two part executable. One a stripped binary which will occupy less space in RAM and in a distribution and the second a debugging information file which is only needed if debugging abilities are required. The suggested procedure to create these files is as follows:
foo
then...
objcopy --only-keep-debug foo foo.dbg
to
create a file containing the debugging info.
objcopy --strip-debug foo
to create a
stripped executable.
objcopy --add-gnu-debuglink=foo.dbg foo
to add a link to the debugging info into the stripped executable.
Note--the choice of .dbg
as an extension for the debug info
file is arbitrary. Also the --only-keep-debug
step is
optional. You could instead do this:
foo
to foo.full
objcopy --strip-debug foo
objcopy --add-gnu-debuglink=foo.full foo
i.e., the file pointed to by the `--add-gnu-debuglink' can be the full executable. It does not have to be a file created by the `--only-keep-debug' switch.
Note--this switch is only intended for use on fully linked files. It does not make sense to use it on object files where the debugging information may be incomplete. Besides the gnu_debuglink feature currently only supports the presence of one filename containing debugging information, not multiple filenames on a one-per-object-file basis.
--strip-dwo
--extract-dwo
--file-alignment num
--heap reserve
--heap reserve,commit
--image-base value
--section-alignment num
--stack reserve
--stack reserve,commit
--subsystem which
--subsystem which:major
--subsystem which:major.minor
native
, windows
,
console
, posix
, efi-app
, efi-bsd
,
efi-rtd
, sal-rtd
, and xbox
. You may optionally set
the subsystem version also. Numeric values are also accepted for
which.
[This option is specific to PE targets.]
--extract-symbol
This option is used to build a `.sym' file for a VxWorks kernel. It can also be a useful way of reducing the size of a `--just-symbols' linker input file.
--compress-debug-sections
--decompress-debug-sections
-V
--version
objcopy
.
-v
--verbose
--help
objcopy
.
--info
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |