The GNU oobbjjccooppyy utility copies the contents of an object
file to another. oobbjjccooppyy 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 oobbjjccooppyy is controlled by command-line options.
Note that oobbjjccooppyy 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.
oobbjjccooppyy creates temporary files to do its translations and
deletes them afterward. oobbjjccooppyy 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.
oobbjjccooppyy can be used to generate S-records by using an output
target of ssrreecc (e.g., use --OO ssrreecc).
oobbjjccooppyy can be used to generate a raw binary file by using an
output target of bbiinnaarryy (e.g., use --OO bbiinnaarryy). When
oobbjjccooppyy 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 --SS to remove sections containing debugging information. In
some cases --RR will be useful to remove sections which contain
information that is not needed by the binary file.
Note---oobbjjccooppyy is not able to change the endianness of its input
files. If the input format has an endianness (some formats do not),
oobbjjccooppyy can only copy the inputs into file formats that have the
same endianness or which have no endianness (e.g., ssrreecc).
OPTIONS
_i_n_f_i_l_e
_o_u_t_f_i_l_e
The input and output files, respectively.
If you do not specify _o_u_t_f_i_l_e, oobbjjccooppyy creates a
temporary file and destructively renames the result with
the name of _i_n_f_i_l_e.
--II _b_f_d_n_a_m_e
----iinnppuutt--ttaarrggeett==_b_f_d_n_a_m_e
Consider the source file's object format to be _b_f_d_n_a_m_e, rather than
attempting to deduce it.
--OO _b_f_d_n_a_m_e
----oouuttppuutt--ttaarrggeett==_b_f_d_n_a_m_e
Write the output file using the object format _b_f_d_n_a_m_e.
--FF _b_f_d_n_a_m_e
----ttaarrggeett==_b_f_d_n_a_m_e
Use _b_f_d_n_a_m_e as the object format for both the input and the output
file; i.e., simply transfer data from source to destination with no
translation.
--BB _b_f_d_a_r_c_h
----bbiinnaarryy--aarrcchhiitteeccttuurree==_b_f_d_a_r_c_h
Useful when transforming a raw binary input file into an object file.
In this case the output architecture can be set to _b_f_d_a_r_c_h. This
option will be ignored if the input file has a known _b_f_d_a_r_c_h. You
can access this binary data inside a program by referencing the special
symbols that are created by the conversion process. These symbols are
called _binary__o_b_j_f_i_l_e_start, _binary__o_b_j_f_i_l_e_end and
_binary__o_b_j_f_i_l_e_size. e.g. you can transform a picture file into
an object file and then access it in your code using these symbols.
--jj _s_e_c_t_i_o_n_n_a_m_e
----oonnllyy--sseeccttiioonn==_s_e_c_t_i_o_n_n_a_m_e
Copy only the named section from the input file to the output file.
This option may be given more than once. Note that using this option
inappropriately may make the output file unusable.
--RR _s_e_c_t_i_o_n_n_a_m_e
----rreemmoovvee--sseeccttiioonn==_s_e_c_t_i_o_n_n_a_m_e
Remove any section named _s_e_c_t_i_o_n_n_a_m_e from the output file. This
option may be given more than once. Note that using this option
inappropriately may make the output file unusable.
--SS
----ssttrriipp--aallll
Do not copy relocation and symbol information from the source file.
--gg
----ssttrriipp--ddeebbuugg
Do not copy debugging symbols or sections from the source file.
----ssttrriipp--uunnnneeeeddeedd
Strip all symbols that are not needed for relocation processing.
--KK _s_y_m_b_o_l_n_a_m_e
----kkeeeepp--ssyymmbbooll==_s_y_m_b_o_l_n_a_m_e
Copy only symbol _s_y_m_b_o_l_n_a_m_e from the source file. This option may
be given more than once.
--NN _s_y_m_b_o_l_n_a_m_e
----ssttrriipp--ssyymmbbooll==_s_y_m_b_o_l_n_a_m_e
Do not copy symbol _s_y_m_b_o_l_n_a_m_e from the source file. This option
may be given more than once.
----ssttrriipp--uunnnneeeeddeedd--ssyymmbbooll==_s_y_m_b_o_l_n_a_m_e
Do not copy symbol _s_y_m_b_o_l_n_a_m_e from the source file unless it is needed
by a relocation. This option may be given more than once.
--GG _s_y_m_b_o_l_n_a_m_e
----kkeeeepp--gglloobbaall--ssyymmbbooll==_s_y_m_b_o_l_n_a_m_e
Keep only symbol _s_y_m_b_o_l_n_a_m_e global. Make all other symbols local
to the file, so that they are not visible externally. This option may
be given more than once.
--LL _s_y_m_b_o_l_n_a_m_e
----llooccaalliizzee--ssyymmbbooll==_s_y_m_b_o_l_n_a_m_e
Make symbol _s_y_m_b_o_l_n_a_m_e local to the file, so that it is not
visible externally. This option may be given more than once.
--WW _s_y_m_b_o_l_n_a_m_e
----wweeaakkeenn--ssyymmbbooll==_s_y_m_b_o_l_n_a_m_e
Make symbol _s_y_m_b_o_l_n_a_m_e weak. This option may be given more than once.
--ww
----wwiillddccaarrdd
Permit regular expressions in _s_y_m_b_o_l_n_a_m_es used in other command
line options. The question mark (?), asterisk (*), backslash (\) and
square brackets ([]) operators can be used anywhere in the symbol
name. If the first character of the symbol name is the exclamation
point (!) then the sense of the switch is reversed for that symbol.
For example:
-w -W !foo -W fo*
would cause objcopy to weaken all symbols that start with ``fo''
except for the symbol ``foo''.
--xx
----ddiissccaarrdd--aallll
Do not copy non-global symbols from the source file.
--XX
----ddiissccaarrdd--llooccaallss
Do not copy compiler-generated local symbols.
(These usually start with LL or ...)
--bb _b_y_t_e
----bbyyttee==_b_y_t_e
Keep only every _b_y_t_eth byte of the input file (header data is not
affected). _b_y_t_e can be in the range from 0 to _i_n_t_e_r_l_e_a_v_e-1,
where _i_n_t_e_r_l_e_a_v_e is given by the --ii or ----iinntteerrlleeaavvee
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.
--ii _i_n_t_e_r_l_e_a_v_e
----iinntteerrlleeaavvee==_i_n_t_e_r_l_e_a_v_e
Only copy one out of every _i_n_t_e_r_l_e_a_v_e bytes. Select which byte to
copy with the --bb or ----bbyyttee option. The default is 4.
oobbjjccooppyy ignores this option if you do not specify either --bb or
----bbyyttee.
--pp
----pprreesseerrvvee--ddaatteess
Set the access and modification dates of the output file to be the same
as those of the input file.
----ddeebbuuggggiinngg
Convert debugging information, if possible. This is not the default
because only certain debugging formats are supported, and the
conversion process can be time consuming.
----ggaapp--ffiillll _v_a_l
Fill gaps between sections with _v_a_l. This operation applies to
the _l_o_a_d _a_d_d_r_e_s_s (LMA) of the sections. It is done by increasing
the size of the section with the lower address, and filling in the extra
space created with _v_a_l.
----ppaadd--ttoo _a_d_d_r_e_s_s
Pad the output file up to the load address _a_d_d_r_e_s_s. This is
done by increasing the size of the last section. The extra space is
filled in with the value specified by ----ggaapp--ffiillll (default zero).
----sseett--ssttaarrtt _v_a_l
Set the start address of the new file to _v_a_l. Not all object file
formats support setting the start address.
----cchhaannggee--ssttaarrtt _i_n_c_r
----aaddjjuusstt--ssttaarrtt _i_n_c_r
Change the start address by adding _i_n_c_r. Not all object file
formats support setting the start address.
----cchhaannggee--aaddddrreesssseess _i_n_c_r
----aaddjjuusstt--vvmmaa _i_n_c_r
Change the VMA and LMA addresses of all sections, as well as the start
address, by adding _i_n_c_r. Some object file formats do not permit
section addresses to be changed arbitrarily. Note that this does not
relocate the sections; if the program expects sections to be loaded at a
certain address, and this option is used to change the sections such
that they are loaded at a different address, the program may fail.
----aaddjjuusstt--sseeccttiioonn--vvmmaa _s_e_c_t_i_o_n{{==,,++,,--}}_v_a_l
Set or change both the VMA address and the LMA address of the named
_s_e_c_t_i_o_n. If == is used, the section address is set to
_v_a_l. Otherwise, _v_a_l is added to or subtracted from the
section address. See the comments under ----cchhaannggee--aaddddrreesssseess,
above. If _s_e_c_t_i_o_n does not exist in the input file, a warning will
be issued, unless ----nnoo--cchhaannggee--wwaarrnniinnggss is used.
----cchhaannggee--sseeccttiioonn--llmmaa _s_e_c_t_i_o_n{{==,,++,,--}}_v_a_l
Set or change the LMA address of the named _s_e_c_t_i_o_n. The LMA
address is the address where the section will be loaded into memory at
program load time. Normally this is the same as the VMA address, which
is the address of the section at program run time, but on some systems,
especially those where a program is held in ROM, the two can be
different. If == is used, the section address is set to
_v_a_l. Otherwise, _v_a_l is added to or subtracted from the
section address. See the comments under ----cchhaannggee--aaddddrreesssseess,
above. If _s_e_c_t_i_o_n does not exist in the input file, a warning
will be issued, unless ----nnoo--cchhaannggee--wwaarrnniinnggss is used.
----cchhaannggee--sseeccttiioonn--vvmmaa _s_e_c_t_i_o_n{{==,,++,,--}}_v_a_l
Set or change the VMA address of the named _s_e_c_t_i_o_n. The VMA
address is the address where the section will be located once the
program has started executing. Normally this is the same as the LMA
address, which is the address where the section will be loaded into
memory, but on some systems, especially those where a program is held in
ROM, the two can be different. If == is used, the section address
is set to _v_a_l. Otherwise, _v_a_l is added to or subtracted
from the section address. See the comments under
----cchhaannggee--aaddddrreesssseess, above. If _s_e_c_t_i_o_n does not exist in
the input file, a warning will be issued, unless
----nnoo--cchhaannggee--wwaarrnniinnggss is used.
----cchhaannggee--wwaarrnniinnggss
----aaddjjuusstt--wwaarrnniinnggss
If ----cchhaannggee--sseeccttiioonn--aaddddrreessss or ----cchhaannggee--sseeccttiioonn--llmmaa or
----cchhaannggee--sseeccttiioonn--vvmmaa is used, and the named section does not
exist, issue a warning. This is the default.
----nnoo--cchhaannggee--wwaarrnniinnggss
----nnoo--aaddjjuusstt--wwaarrnniinnggss
Do not issue a warning if ----cchhaannggee--sseeccttiioonn--aaddddrreessss or
----aaddjjuusstt--sseeccttiioonn--llmmaa or ----aaddjjuusstt--sseeccttiioonn--vvmmaa is used, even
if the named section does not exist.
----sseett--sseeccttiioonn--ffllaaggss _s_e_c_t_i_o_n==_f_l_a_g_s
Set the flags for the named section. The _f_l_a_g_s argument is a
comma separated string of flag names. The recognized names are
aalllloocc, ccoonntteennttss, llooaadd, nnoollooaadd,
rreeaaddoonnllyy, ccooddee, ddaattaa, rroomm, sshhaarree, and
ddeebbuugg. You can set the ccoonntteennttss flag for a section which
does not have contents, but it is not meaningful to clear the
ccoonntteennttss flag of a section which does have contents--just remove
the section instead. Not all flags are meaningful for all object file
formats.
----aadddd--sseeccttiioonn _s_e_c_t_i_o_n_n_a_m_e==_f_i_l_e_n_a_m_e
Add a new section named _s_e_c_t_i_o_n_n_a_m_e while copying the file. The
contents of the new section are taken from the file _f_i_l_e_n_a_m_e. The
size of the section will be the size of the file. This option only
works on file formats which can support sections with arbitrary names.
----rreennaammee--sseeccttiioonn _o_l_d_n_a_m_e==_n_e_w_n_a_m_e[[,,_f_l_a_g_s]]
Rename a section from _o_l_d_n_a_m_e to _n_e_w_n_a_m_e, optionally
changing the section's flags to _f_l_a_g_s in the process. This has
the advantage over usng a linker script to perform the rename in that
the output stays as an object file and does not become a linked
executable.
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:
----cchhaannggee--lleeaaddiinngg--cchhaarr
Some object file formats use special characters at the start of
symbols. The most common such character is underscore, which compilers
often add before every symbol. This option tells oobbjjccooppyy 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.
----rreemmoovvee--lleeaaddiinngg--cchhaarr
If the first character of a global symbol is a special symbol leading
character used by the object file format, remove the character. The
most common symbol leading character is underscore. This option will
remove a leading underscore from all global symbols. This can be useful
if you want to link together objects of different file formats with
different conventions for symbol names. This is different from
----cchhaannggee--lleeaaddiinngg--cchhaarr because it always changes the symbol name
when appropriate, regardless of the object file format of the output
file.
----ssrreecc--lleenn==_i_v_a_l
Meaningful only for srec output. Set the maximum length of the Srecords
being produced to _i_v_a_l. This length covers both address, data and
crc fields.
----ssrreecc--ffoorrcceeSS33
Meaningful only for srec output. Avoid generation of S1/S2 records,
creating S3-only record format.
----rreeddeeffiinnee--ssyymm _o_l_d==_n_e_w
Change the name of a symbol _o_l_d, to _n_e_w. This can be useful
when one is trying link two things together for which you have no
source, and there are name collisions.
----rreeddeeffiinnee--ssyymmss==_f_i_l_e_n_a_m_e
Apply ----rreeddeeffiinnee--ssyymm to each symbol pair "_o_l_d _n_e_w"
listed in the file _f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e is simply a flat file,
with one symbol pair per line. Line comments may be introduced by the hash
character. This option may be given more than once.
----wweeaakkeenn
Change all global symbols in the file to be weak. This can be useful
when building an object which will be linked against other objects using
the --RR option to the linker. This option is only effective when
using an object file format which supports weak symbols.
----kkeeeepp--ssyymmbboollss==_f_i_l_e_n_a_m_e
Apply ----kkeeeepp--ssyymmbbooll option to each symbol listed in the file
_f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e 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.
----ssttrriipp--ssyymmbboollss==_f_i_l_e_n_a_m_e
Apply ----ssttrriipp--ssyymmbbooll option to each symbol listed in the file
_f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e 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.
----ssttrriipp--uunnnneeeeddeedd--ssyymmbboollss==_f_i_l_e_n_a_m_e
Apply ----ssttrriipp--uunnnneeeeddeedd--ssyymmbbooll option to each symbol listed in
the file _f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e 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.
----kkeeeepp--gglloobbaall--ssyymmbboollss==_f_i_l_e_n_a_m_e
Apply ----kkeeeepp--gglloobbaall--ssyymmbbooll option to each symbol listed in the
file _f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e 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.
----llooccaalliizzee--ssyymmbboollss==_f_i_l_e_n_a_m_e
Apply ----llooccaalliizzee--ssyymmbbooll option to each symbol listed in the file
_f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e 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.
----wweeaakkeenn--ssyymmbboollss==_f_i_l_e_n_a_m_e
Apply ----wweeaakkeenn--ssyymmbbooll option to each symbol listed in the file
_f_i_l_e_n_a_m_e. _f_i_l_e_n_a_m_e 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.
----aalltt--mmaacchhiinnee--ccooddee==_i_n_d_e_x
If the output architecture has alternate machine codes, use the
_i_n_d_e_xth code instead of the default one. This is useful in case
a machine is assigned an official code and the tool-chain adopts the
new code, but other applications still depend on the original code
being used.
----wwrriittaabbllee--tteexxtt
Mark the output text as writable. This option isn't meaningful for all
object file formats.
----rreeaaddoonnllyy--tteexxtt
Make the output text write protected. This option isn't meaningful for all
object file formats.
----ppuurree
Mark the output file as demand paged. This option isn't meaningful for all
object file formats.
----iimmppuurree
Mark the output file as impure. This option isn't meaningful for all
object file formats.
----pprreeffiixx--ssyymmbboollss==_s_t_r_i_n_g
Prefix all symbols in the output file with _s_t_r_i_n_g.
----pprreeffiixx--sseeccttiioonnss==_s_t_r_i_n_g
Prefix all section names in the output file with _s_t_r_i_n_g.
----pprreeffiixx--aalllloocc--sseeccttiioonnss==_s_t_r_i_n_g
Prefix all the names of all allocated sections in the output file with
_s_t_r_i_n_g.
----aadddd--ggnnuu--ddeebbuugglliinnkk==_p_a_t_h_-_t_o_-_f_i_l_e
Creates a .gnu_debuglink section which contains a reference to _p_a_t_h_-_t_o_-_f_i_l_e
and adds it to the output file.
----oonnllyy--kkeeeepp--ddeebbuugg
Strip a file, removing any sections that would be stripped by
----ssttrriipp--ddeebbuugg and leaving the debugging sections.
The intention is that this option will be used in conjunction with
----aadddd--ggnnuu--ddeebbuugglliinnkk 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:
1.
"foo" then...
1.
create a file containing the debugging info.
1.
stripped executable.
1.
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:
1.
1.
1.
1.
ie the file pointed to by the ----aadddd--ggnnuu--ddeebbuugglliinnkk can be the
full executable. It does not have to be a file created by the
----oonnllyy--kkeeeepp--ddeebbuugg switch.
--VV
----vveerrssiioonn
Show the version number of oobbjjccooppyy.
--vv
----vveerrbboossee
Verbose output: list all object files modified. In the case of
archives, oobbjjccooppyy --VV lists all members of the archive.
----hheellpp
Show a summary of the options to oobbjjccooppyy.
----iinnffoo
Display a list showing all architectures and object formats available.
SEE ALSO
_l_d(1), _o_b_j_d_u_m_p(1), and the Info entries for _b_i_n_u_t_i_l_s.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.