Usage: objcopy [option(s)] in-file [out-file]
Copies a binary file, possibly transforming it in the process
The options are:
-I --input-target
Usage: objcopy [option(s)] in-file [out-file]
Copies a binary file, possibly transforming it in the process
The options are:
-I --input-target
objcopy(1) GNU Development Tools objcopy(1) 名前 objcopy - オブジェクトファイルのコピーや変換を行う 書式 objcopy [-F bfdname | --target=bfdname] [-I bfdname | --input-target=bfdname] [-O bfdname | --output-target=bfdname] [-R sectionname | --remove-section=sectionname] [-S | --strip-all] [-g | --strip-debug] [--strip-unneeded] [-K symbolname | --keep-symbol=symbolname] [-N symbolname | --strip-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] [-p | --preserve-dates] [--debugging] [--gap-fill=val] [--pad-to=address] [--set-start=val] [--adjust-start=incr] [--adjust-vma=incr] [--adjust-section-vma=section{=,+,-}val] [--adjust-warnings] [--no-adjust-warnings] [--set-section-flags=section=flags] [--add-section=sectionname=filename] [--change-leading-char] [--remove-leading-char] [--weaken] [-v | --verbose] [-V | --version] [--help] infile [outfile] 説明 GNU objcopy ユーティリティはオブジェクトファイルの内容を別ファイルにコ ピーする。 objcopy はオブジェクトファイルの読み書きに GNU BFD ライブラ リを用いる。これによって書き込み先のファイルのオブジェクトフォーマット を読み込みファイルのフォーマットから変更することができる。 objcopy の詳 細な動作はコマンドラインオプションによって決定される。 objcopy は変換を行う際に一時ファイルを作成し、動作後にこれを消去する。 objcopy 変換作業はすべて BFD によって行われる。したがって BFD が種々の フォーマットに関して持っているすべての情報を利用することができ、明示し ないでもほとんどのフォーマットを認識できる。 objcopy はターゲットを srec に指定する (つまり -O srec とする) ことによ って S-record を生成することもできる。 objcopy は出力ターゲットを binary に指定する (つまり -O binary とする) ことによって raw バイナリファイルを生成することもできる。この際には、基 本的には入力オブジェクトファイルの内容のメモリダンプが作られる。メモリ ダンプは出力ファイルにコピーされる最抵位のセクションの仮想アドレスから スタートする。 S-record や raw バイナリファイルを生成する場合に -S を用いれば、デバッ グ情報を持つセクションを削除できる。また、バイナリファイルに不要な情報 を持ったセクションを消去するのに -R が役に立つ場合もある。 infile と outfile はそれぞれ入力・出力ファイルである。 outfile が指定さ れないと objcopy は一時ファイルを作成し、その結果を入力ファイルの名前に リネームする (すなわちもとの入力ファイルは破壊される)。 -I bfdname, --input-target=bfdname 入力ファイルのオブジェクトフォーマットを bfdname として取り扱う 。通常は自動的に認識する。 -O bfdname, --output-target=bfdname 出力ファイルのオブジェクトフォーマットを bfdname にする。 -F bfdname, --target=bfdname 入出力ファイルのオブジェクトフォーマットに bfdname を用いる。す なわち入力ファイルを変換せずに単に出力ファイルにコピーする。 -R sectionname, --remove-section=sectionname 指定したセクションをファイルから削除する。このオプションは複数回 指定することができる。このオプションを誤って用いると、出力ファイ ルが役立たずになる可能性がある。 -S, --strip-all リロケーション情報とシンボル情報を入力ファイルからコピーしない。 -g, --strip-debug デバッグシンボルを入力ファイルからコピーしない。 --strip-unneeded リロケーション処理に不要なシンボルをすべて取り去る。 -K symbolname, --keep-symbol=symbolname 入力ファイルから symbolname という名前のシンボルだけをコピーする 。複数回指定できる。 -N symbolname, --strip-symbol=symbolname 入力ファイルの symbolname という名前のシンボルをコピーしない。複 数回指定できる。 -L symbolname, --localize-symbol=symbolname symbolname をそのファイルにローカルなものにし、外部から見えない ようにする。複数回指定できる。 -W symbolname, --weaken-symbol=symbolname symbolname を weak にする。複数回指定できる。 -x, --discard-all 入力ファイルのグローバルでないシンボルはコピーしない。 -X, --discard-locals コンパイラが生成したローカルなシンボル (通常 "L" または "." では じまるシンボル) はコピーしない。 -b byte, --byte=byte 入力ファイルを interleave づつ区切った各セクションから byte バイ ト目だけをコピーする (ヘッダデータは影響されない)。 byte の範囲 は 0 から interleave-1 までである。 interleave の値は -i(また は--interleave) オプションで指定する。このオプションは ROM プロ グラム用のファイルを作成するときに便利である。出力ターゲット srec と共に用いられることが多い。 -i interleave, --interleave=interleave interleave バイトにつき 1 バイトづつをコピーする。デフォルトは 4 である。何番目のバイトをコピーするかは -b(または--byte ) オプシ ョンで指定する。 -b も --bytes も指定されなかった場合は interleave は無視される。 -p, --preserve-dates 出力ファイルのアクセス時刻と修正時刻を入力ファイルと同じにする。 --debugging 可能ならばデバッグ情報を変換する。このオプションはデフォルトには なっていない。すべてのデバッグフォーマットがサポートされているわ けではないし、この変換には時間がかかるからである。 --gap-fill=val セクション間のギャップを val で埋める。この動作はセクションの load address (LMA) に適用される。これはセクションのサイズを抵位 アドレスの分増やし、その余分を val で埋めることでなされる。 --pad-to=address 出力ファイルをロードアドレス address まで水増しする。これは最後 のセクションのサイズを増やすことでなされる。余分なスペースは --gap-fill で指定された値で埋められる (デフォルトは 0)。 --set-start=val 新しいファイルのスタートアドレスを val に設定する。すべてのオブ ジェクトファイルフォーマットでこの指定が可能ではないことに注意す ること。 --adjust-start=incr スタートアドレスを incr だけ増やす。すべてのオブジェクトファイル フォーマットでこの指定が可能ではないことに注意すること。 --adjust-vma=incr すべてのセクション (スタートアドレスも含まれる) のアドレスを incr だけ増やす。すべてのオブジェクトファイルフォーマットで任意 のアドレス設定が指定が可能なわけではないことに注意すること。また このオプションではそれぞれのセクションがロードされるアドレスを変 えてしまうので、プログラムが動かなくなる可能性がある --adjust-section-vma=section{=,+,-}val 名前が section のセクションのアドレスを設定する。 = が用いられた 場合はセクションのアドレスは val にされる。それ以外の場合はセク ションのアドレスから val が増減される。上記の --adjust-vma に関 するコメントを参照のこと。 section が入力ファイルに存在しない場 合は警告グメッセージが表示される (ただし --no-adjust-warning が 指定されていたら表示しない)。 --adjust-warnings --adjust-section-vma が指定されているとき、対象となるセクション が存在しなければ警告メッセージを表示する。デフォルトの動作である 。 --no-adjust-warnings --adjust-section-vma が指定されているとき、かつ対象となるセクシ ョンが存在していなくても警告メッセージを表示しない。 --set-section-flags=section=flags 指定したセクションのフラグを設定する。引数 flags はコンマ (,) で 区切られたフラグ文字列である。認識される文字列は alloc、 load、 readonly、 code、 data、 rom である。すべてのフラグがあらゆるフ ォーマットで有効なわけではないことに注意すること。 --add-section=sectionname=filename ファイルをコピーするときに sectionname という名前のセクションを 追加する。この新しいセクションの内容はファイル filename から取ら れる。このオプションが機能するのは、任意のセクション名をサポート しているフォーマットだけである。 --change-leading-char オブジェクトファイルのフォーマットによっては、シンボル名の先頭に 特定の文字を使っている場合がある。よくある例はアンダースコア (_) で、これはコンパイラがすべてのシンボル名に前置する。このオプショ ンを指定すると objcopy はフォーマット変換の際にすべてのシンボル における先頭文字を変更しようとする。同じ先頭文字を持つオブジェク ト間では、このオプションは意味を持たない。異なる場合は、場合に応 じて先頭文字が追加されたり削除、変更されたりする。 --remove-leading-char グローバルシンボルの先頭文字がオブジェクトファイルに特有のもので あった場合、これを削除する。通常はアンダースコア (_) がこれにあ たる。このオプションはすべてのグローバルシンボルから先頭にあるア ンダースコアを削除する。これは (シンボル名の命名流儀が異なる) 複 数のフォーマットに属するオブジェクト群を同時にリンクする場合に有 用である。このオプションは --change-leading-char とは異なる。後 者では出力のフォーマットにかかわらず、該当したケースではすべて変 更が行われる。 --weaken ファイルのすべての global なシンボルを weak に変更する。 -v, --verbose 詳細出力モード。修正されたすべてのオブジェクトファイルをリストす る。書庫の場合は"objcopy -V" とすると書庫のすべてのメンバーを表 示する。 -V, --version objcopy のバージョン番号を表示して終了する。 --help objcopy のオプションの要約を表示して終了する。 関連項目 info の ‘ binutils ’ エントリ、 The GNU Binary Utilities, Roland H. Pesch (June 1993)、 著作権 Copyright (c) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. cygnus support October 1994 objcopy(1)
OBJCOPY(1) GNU Development Tools OBJCOPY(1)
NAME
objcopy - copy and translate object files
SYNOPSIS
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 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]]
[--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]
[--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]
[-v|--verbose]
[-V|--version]
[--help] [--info]
infile [outfile]
DESCRIPTION
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.
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.)
OPTIONS
infile
outfile
The input and output files, respectively. If you do not specify
outfile, objcopy creates a temporary file and destructively renames
the result with the name of infile.
-I bfdname
--input-target=bfdname
Consider the source file’s object format to be bfdname, rather than
attempting to deduce it.
-O bfdname
--output-target=bfdname
Write the output file using the object format bfdname.
-F bfdname
--target=bfdname
Use bfdname as the object format for both the input and the output
file; i.e., simply transfer data from source to destination with no
translation.
-B bfdarch
--binary-architecture=bfdarch
Useful when transforming a architecture-less input file into an
object file. In this case the output architecture can be set to
bfdarch. This option will be ignored if the input file has a known
bfdarch. 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_objfile_start,
_binary_objfile_end and _binary_objfile_size. e.g. you can
transform a picture file into an object file and then access it in
your code using these symbols.
-j sectionname
--only-section=sectionname
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.
-R sectionname
--remove-section=sectionname
Remove any section named sectionname from the output file. This
option may be given more than once. Note that using this option
inappropriately may make the output file unusable.
-S
--strip-all
Do not copy relocation and symbol information from the source file.
-g
--strip-debug
Do not copy debugging symbols or sections from the source file.
--strip-unneeded
Strip all symbols that are not needed for relocation processing.
-K symbolname
--keep-symbol=symbolname
When stripping symbols, keep symbol symbolname even if it would
normally be stripped. This option may be given more than once.
-N symbolname
--strip-symbol=symbolname
Do not copy symbol symbolname from the source file. This option
may be given more than once.
--strip-unneeded-symbol=symbolname
Do not copy symbol symbolname from the source file unless it is
needed by a relocation. This option may be given more than once.
-G symbolname
--keep-global-symbol=symbolname
Keep only symbol symbolname global. Make all other symbols local
to the file, so that they are not visible externally. This option
may be given more than once.
--localize-hidden
In an ELF object, mark all symbols that have hidden or internal
visibility as local. This option applies on top of symbol-specific
localization options such as -L.
-L symbolname
--localize-symbol=symbolname
Make symbol symbolname local to the file, so that it is not visible
externally. This option may be given more than once.
-W symbolname
--weaken-symbol=symbolname
Make symbol symbolname weak. This option may be given more than
once.
--globalize-symbol=symbolname
Give symbol symbolname global scoping so that it is visible outside
of the file in which it is defined. This option may be given more
than once.
-w
--wildcard
Permit regular expressions in symbolnames 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".
-x
--discard-all
Do not copy non-global symbols from the source file.
-X
--discard-locals
Do not copy compiler-generated local symbols. (These usually start
with L or ..)
-b byte
--byte=byte
Keep only every byteth byte of the input file (header data is not
affected). byte can be in the range from 0 to interleave-1, where
interleave is given by the -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
Only copy one out of every interleave bytes. Select which byte to
copy with the -b or --byte option. The default is 4. objcopy
ignores this option if you do not specify either -b or --byte.
-p
--preserve-dates
Set the access and modification dates of the output file to be the
same as those of the input file.
--debugging
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.
--gap-fill val
Fill gaps between sections with val. This operation applies to the
load address (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 val.
--pad-to address
Pad the output file up to the load address address. This is done
by increasing the size of the last section. The extra space is
filled in with the value specified by --gap-fill (default zero).
--set-start val
Set the start address of the new file to val. Not all object file
formats support setting the start address.
--change-start incr
--adjust-start incr
Change the start address by adding incr. Not all object file
formats support setting the start address.
--change-addresses incr
--adjust-vma incr
Change the VMA and LMA addresses of all sections, as well as the
start address, by adding incr. 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.
--change-section-address section{=,+,-}val
--adjust-section-vma section{=,+,-}val
Set or change both the VMA address and the LMA address of the named
section. If = 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
Set or change the LMA address of the named section. 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 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
Set or change the VMA address of the named section. 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 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
If --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
Do not issue a warning if --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
Set the flags for the named section. The flags argument is a comma
separated string of flag names. The recognized names are 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
Add a new section named sectionname while copying the file. The
contents of the new section are taken from the file filename. 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.
--rename-section oldname=newname[,flags]
Rename a section from oldname to newname, optionally changing the
section’s flags to flags 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:
objcopy -I binary -O
コロナウイルスの日ごとの感染者数・死者数をグラフ化してみました。どの国が増加傾向にあり、どの国が終息に向かっているかを視覚化しています。
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa