Node:objcopy, Next:objdump, Previous:nm, Up:Top
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] [-G
symbolname|--keep-global-symbol=
symbolname] [-L
symbolname|--localize-symbol=
symbolname] [-W
symbolname|--weaken-symbol=
symbolname] [-x
|--discard-all
] [-X
|--discard-locals
] [-b
byte|--byte=
byte] [-i
interleave|--interleave=
interleave] [-j
sectionname|--only-section=
sectionname] [-R
sectionname|--remove-section=
sectionname] [-p
|--preserve-dates
] [--debugging
] [--gap-fill=
val] [--pad-to=
address] [--set-start=
val] [--adjust-start=
incr] [--change-addresses=
incr] [--change-section-address
section{=,+,-}val] [--change-section-lma
section{=,+,-}val] [--change-section-vma
section{=,+,-}val] [--change-warnings
] [--no-change-warnings
] [--set-section-flags
section=flags] [--add-section
sectionname=filename] [--rename-section
oldname=newname[,flags]] [--change-leading-char
] [--remove-leading-char
] [--srec-len=
ival ] [--srec-forceS3
] [--redefine-sym
old=new ] [--weaken
] [--keep-symbols=
filename] [--strip-symbols=
filename] [--keep-global-symbols=
filename] [--localize-symbols=
filename] [--weaken-symbols=
filename] [--alt-machine-code=index
] [-v
|--verbose
] [-V
|--version
] [--help
] 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 BFD.
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 (eg srec
).
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 sectionname
--only-section=sectionname
-R sectionname
--remove-section=sectionname
-S
--strip-all
-g
--strip-debug
--strip-unneeded
-K symbolname
--keep-symbol=symbolname
-N symbolname
--strip-symbol=symbolname
-G symbolname
--keep-global-symbol=symbolname
-L symbolname
--localize-symbol=symbolname
-W symbolname
--weaken-symbol=symbolname
-x
--discard-all
-X
--discard-locals
L
or .
.)
-b byte
--byte=byte
-i
or --interleave
option, or the default of 4. This option is useful for creating files
to program ROM. It is typically used with an srec
output
target.
-i interleave
--interleave=interleave
-b
or --byte
option. The default is 4.
objcopy
ignores this option if you do not specify either -b
or
--byte
.
-p
--preserve-dates
--debugging
--gap-fill val
--pad-to address
--gap-fill
(default zero).
--set-start val
--change-start incr
--adjust-start incr
--change-addresses incr
--adjust-vma incr
--change-section-address section{=,+,-}val
--adjust-section-vma section{=,+,-}val
=
is used, the section address is set to
val. Otherwise, val is added to or subtracted from the
section address. See the comments under --change-addresses
,
above. If section does not exist in the input file, a warning will
be issued, unless --no-change-warnings
is used.
--change-section-lma section{=,+,-}val
=
is used, the section address is set to
val. Otherwise, val is added to or subtracted from the
section address. See the comments under --change-addresses
,
above. If section does not exist in the input file, a warning
will be issued, unless --no-change-warnings
is used.
--change-section-vma section{=,+,-}val
=
is used, the section address
is set to val. Otherwise, val is added to or subtracted
from the section address. See the comments under
--change-addresses
, above. If section does not exist in
the input file, a warning will be issued, unless
--no-change-warnings
is used.
--change-warnings
--adjust-warnings
--change-section-address
or --change-section-lma
or
--change-section-vma
is used, and the named section does not
exist, issue a warning. This is the default.
--no-change-warnings
--no-adjust-warnings
--change-section-address
or
--adjust-section-lma
or --adjust-section-vma
is used, even
if the named section does not exist.
--set-section-flags section=flags
alloc
, contents
, load
, noload
,
readonly
, code
, data
, rom
, share
, and
debug
. You can set the contents
flag for a section which
does not have contents, but it is not meaningful to clear the
contents
flag of a section which does have contents-just remove
the section instead. Not all flags are meaningful for all object file
formats.
--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>
--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
--change-leading-char
because it always changes the symbol name
when appropriate, regardless of the object file format of the output
file.
--srec-len=ival
--srec-forceS3
--redefine-sym old=new
--weaken
-R
option to the linker. This option is only effective when
using an object file format which supports weak symbols.
--keep-symbols=filename
--keep-symbol
option to each symbol listed in the file
filename. filename is simply a flat file, with one symbol
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
--strip-symbols=filename
--strip-symbol
option to each symbol listed in the file
filename. filename is simply a flat file, with one symbol
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
--keep-global-symbols=filename
--keep-global-symbol
option to each symbol listed in the
file filename. filename is simply a flat file, with one
symbol name per line. Line comments may be introduced by the hash
character. This option may be given more than once.
--localize-symbols=filename
--localize-symbol
option to each symbol listed in the file
filename. filename is simply a flat file, with one symbol
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
--weaken-symbols=filename
--weaken-symbol
option to each symbol listed in the file
filename. filename is simply a flat file, with one symbol
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
--alt-machine-code=index
-V
--version
objcopy
.
-v
--verbose
objcopy -V
lists all members of the archive.
--help
objcopy
.