objcopy的详细说明
生活随笔
收集整理的這篇文章主要介紹了
objcopy的详细说明
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
objcopy把一種目標(biāo)文件中的內(nèi)容復(fù)制到另一種類型的目標(biāo)文件中.?
(1)將圖像編譯到可執(zhí)行文件內(nèi) Q: 如何將一個(gè)二進(jìn)制文件,比如圖片,詞典一類的東西做為.o文件,直接鏈接到可執(zhí)行文件內(nèi)部呢? A:?
$ objcopy -I binary -O elf32-i386 -B i386 14_95_13.jpg image.o?
$ gcc image.o tt.o -o tt?
$ nm tt | grep 14_95?
0805d6c7 D _binary_14_95_13_jpg_end?
00014213 A _binary_14_95_13_jpg_size?
080494b4 D _binary_14_95_13_jpg_start?
(2)使用objcopy把不用的信息去掉: $ objcopy?-R?.comment?-R?.note?halo?halo.min?
(3)?
$ objcopy?-R?.note?-R?.comment?-S?-O?binary?xyb?xyb.bin?
-R?.note?-R?.comment?表示移掉?.note?與?.comment?段?
-S?表示移出所有的標(biāo)志及重定位信息?
-O?binary?xyb?xyb.bin?表示由xyb生成二進(jìn)制文件xyb.bin objcopy工具使用指南
objcopy Utility
objcopy [ -F bfdname | --target=bfdname ]
[ -I bfdname | --input-target=bfdname ]
[ -O bfdname | --output-target= bfdname ]
[ -S | --strip-all ] [ -g | --strip-debug ]
[ -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 ]
[ -R sectionname | --remove-section= sectionname ]
[ -p | --preserve-dates ] [ --debugging ]
[ --gap-fill= val ] [ --pad-to= address ]
[ --set-start= val ] [ --adjust-start= incr ]
[ --change-address= incr ]
[ --change-section-address= section{=,+,-} val ]
[ --change-warnings ] [ --no-change-warnings ]
[ --set-section-flags= section= flags ]
[ --add-section= sectionname= filename ]
[ --change-leading char ] [--remove-leading-char ]
[ --weaken ]
[ -v | --verbose ] [ -V | --version ] [ --help ]
input-file [ outfile ]?? GNU實(shí)用工具程序objcopy的作用是拷貝一個(gè)目標(biāo)文件的內(nèi)容到另一個(gè)目標(biāo)文件中。Objcopy使用GNU BFD庫(kù)去讀或?qū)懩繕?biāo)文件。Objcopy可以使用不同于源目標(biāo)文件的格式來(lái)寫(xiě)目的目標(biāo)文件(也即是說(shuō)可以將一種格式的目標(biāo)文件轉(zhuǎn)換成另一種格式的目標(biāo)文件)。通過(guò)以上命令行選項(xiàng)可以控制Objcopy的具體操作。
Objcopy在進(jìn)行目標(biāo)文件的轉(zhuǎn)換時(shí),將生成一個(gè)臨時(shí)文件,轉(zhuǎn)換完成后就將這個(gè)臨時(shí)文件刪掉。Objcopy使用BFD做轉(zhuǎn)換工作。如果沒(méi)有明確地格式要求,則Objcopy將訪問(wèn)所有在BFD庫(kù)中已經(jīng)描述了的并且它可以識(shí)別的格式,請(qǐng)參見(jiàn)《GNUpro Decelopment Tools》中“using ld”一章中“BFD庫(kù)”部分和“BFD庫(kù)中規(guī)范的目標(biāo)文件格式”部分。
通過(guò)使用srec作為輸出目標(biāo)(使用命令行選項(xiàng)-o srec),Objcopy可以產(chǎn)生S記錄格式文件。
通過(guò)使用binary作為輸出目標(biāo)(使用命令行選項(xiàng)-o binary),Objcopy可以產(chǎn)生原始的二進(jìn)制文件。使用Objcopy產(chǎn)生一個(gè)原始的二進(jìn)制文件,實(shí)質(zhì)上是進(jìn)行了一回輸入目標(biāo)文件內(nèi)容的內(nèi)存轉(zhuǎn)儲(chǔ)。所有的符號(hào)和重定位信息都將被丟棄。內(nèi)存轉(zhuǎn)儲(chǔ)起始于輸入目標(biāo)文件中那些將要拷貝到輸出目標(biāo)文件去的部分的最小虛地址處。
使用Objcopy生成S記錄格式文件或者原始的二進(jìn)制文件的過(guò)程中,-S選項(xiàng)和-R選項(xiàng)可能會(huì)比較有用。-S選項(xiàng)是用來(lái)刪掉包含調(diào)試信息的部分,-R選項(xiàng)是用來(lái)刪掉包含了二進(jìn)制文件不需要的內(nèi)容的那些部分。 input-file
outfile
參數(shù)input-file和outfile分別表示輸入目標(biāo)文件(源目標(biāo)文件)和輸出目標(biāo)文件(目的目標(biāo)文件)。如果在命令行中沒(méi)有明確地指定outfile,那么Objcopy將創(chuàng)建一個(gè)臨時(shí)文件來(lái)存放目標(biāo)結(jié)果,然后使用input-file的名字來(lái)重命名這個(gè)臨時(shí)文件(這時(shí)候,原來(lái)的input-file將被覆蓋)。 -I bfdname?
--input-target=bfdname
明確告訴Objcopy,源文件的格式是什么,bfdname是BFD庫(kù)中描述的標(biāo)準(zhǔn)格式名。這樣做要比“讓Objcopy自己去分析源文件的格式,然后去和BFD中描述的各種格式比較,通過(guò)而得知源文件的目標(biāo)格式名”的方法要高效得多。 -O bfdname?
--output-target= bfdname
使用指定的格式來(lái)寫(xiě)輸出文件(即目標(biāo)文件),bfdname是BFD庫(kù)中描述的標(biāo)準(zhǔn)格式名。 -F bfdname
--target= bfdname
明確告訴Objcopy,源文件的格式是什么,同時(shí)也使用這個(gè)格式來(lái)寫(xiě)輸出文件(即目標(biāo)文件),也就是說(shuō)將源目標(biāo)文件中的內(nèi)容拷貝到目的目標(biāo)文件的過(guò)程中,只進(jìn)行拷貝不做格式轉(zhuǎn)換,源目標(biāo)文件是什么格式,目的目標(biāo)文件就是什么格式。 -R sectionname
--remove-section= sectionname
從輸出文件中刪掉所有名為sectionname的段。這個(gè)選項(xiàng)可以多次使用。
注意:不恰當(dāng)?shù)厥褂眠@個(gè)選項(xiàng)可能會(huì)導(dǎo)致輸出文件不可用。 -S
--strip-all (strip 剝?nèi)ァ?#xff09;
不從源文件中拷貝重定位信息和符號(hào)信息到輸出文件(目的文件)中去。 -g
--strip-debug
不從源文件中拷貝調(diào)試符號(hào)到輸出文件(目的文件)中去。 --strip-undeeded
剝?nèi)ニ性谥囟ㄎ惶幚頃r(shí)所不需要的符號(hào)。 -K symbolname
--keep-symbol= symbolname
僅從源文件中拷貝名為symbolname的符號(hào)。這個(gè)選項(xiàng)可以多次使用。 -N symbolname
--strip-symbol= symbolname
不從源文件中拷貝名為symbolname的符號(hào)。這個(gè)選項(xiàng)可以多次使用。它可以和其他的strip選項(xiàng)聯(lián)合起來(lái)使用(除了-K symbolname | --keep-symbol= symbolname外)。 -L symbolname
--localize-symbol= symbolname
使名為symbolname的符號(hào)在文件內(nèi)局部化,以便該符號(hào)在該文件外部是不可見(jiàn)的。這個(gè)選項(xiàng)可以多次使用。 -W symbolname
-weaken-symbol= symbolname
弱化名為symbolname的符號(hào)。這個(gè)選項(xiàng)可以多次使用。 -x
--discard-all (discard 丟棄、拋棄)
不從源文件中拷貝非全局符號(hào)。 -X
--discard-locals
不從源文件中拷貝又編譯器生成的局部符號(hào)(這些符號(hào)通常是L或 . 開(kāi)頭的)。 -b byte
--byte= byte?
Keep only every 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 (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 (preserve 保存、保持)
設(shè)置輸出文件的訪問(wèn)和修改日期和輸入文件相同。 [ --debugging ]
如果可能的話,轉(zhuǎn)換調(diào)試信息。因?yàn)橹挥刑囟ǖ恼{(diào)試格式被支持,以及這個(gè)轉(zhuǎn)換過(guò)程要耗費(fèi)一定的時(shí)間,所以這個(gè)選項(xiàng)不是默認(rèn)的。
--gap-fill= val
使用內(nèi)容val填充段與段之間的空隙。通過(guò)增加段的大小,在地址較低的一段附加空間中填充內(nèi)容val來(lái)完成這一選項(xiàng)的功能。 --pad-to= address
填充輸出文件到虛擬地址address。通過(guò)增加輸出文件中最后一個(gè)段的大小,在輸出文件中最后一段的末尾和address之間的這段附加空間中,用--gap-fill= val選項(xiàng)中指定的內(nèi)容val來(lái)填充(默認(rèn)內(nèi)容是0,即沒(méi)有使用--gap-fill= val選項(xiàng)的情況下)。 --set-start= val
設(shè)置新文件(應(yīng)該是輸出文件吧?)的起始地址為val。不是所有的目標(biāo)文件格式都支持設(shè)置起始地址。 --change-start = incr
--adjust-start= incr
通過(guò)增加值incr來(lái)改變起始地址。不是所有的目標(biāo)文件格式都支持設(shè)置起始地址。 --change-addresses incr
--adjust-vma incr
Change the VMA and LMA addresses of all sections, section., as well as the
start address, by adding incr. Some object file formats do not permit section
addresses to be changed arbitrarily. 通過(guò)加上一個(gè)值incr,改變所有段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址),以及起始地址。某些目標(biāo)文件格式不允許隨便更改段的地址。 --change-section-address section{=,+,-} val
--adjust-section-vma section{=,+,-} val
設(shè)置或者改變名為section的段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)。如果這個(gè)選項(xiàng)中使用的是“=”,那么名為section的段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)將被設(shè)置成val;如果這個(gè)選項(xiàng)中使用的是“-”或者“+”,那么上述兩個(gè)地址將被設(shè)置或者改變成這兩個(gè)地址的當(dāng)前值減去或加上val后的值。如果在輸入文件中名為section的段不存在,那么Objcopy將發(fā)出一個(gè)警告,除非--no-change-warnings選項(xiàng)被使用。
這里的段地址設(shè)置和改變都是輸出文件中的段相對(duì)于輸入文件中的段而言的。例如:
(1)--change-section-address .text = 10000
這里是指將輸入文件(即源文件)中名為.text的段拷貝到輸出文件中后,輸出文件中的.text段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)將都被設(shè)置成10000。
(2)--change-section-address .text + 100
這里是指將輸入文件(即源文件)中名為.text的段拷貝到輸出文件中后,輸出文件中的.text段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)將都被設(shè)置成以前輸入文件中.text段的地址(當(dāng)前地址)加上100后的值。 --change-section-lma section{=,+,-} val
僅設(shè)置或者改變名為section的段的LMA(Load Memory Address裝載地址)。一個(gè)段的LMA是程序被加載時(shí),該段將被加載到的一段內(nèi)存空間的首地址。通常LMA和VMA(Virtual Memory Address運(yùn)行時(shí)地址)是相同的,但是在某些系統(tǒng)中,特別是在那些程序放在ROM的系統(tǒng)中,LMA和VMA是不相同的。如果這個(gè)選項(xiàng)中使用的是“=”,那么名為section的段的LMA(Load Memory Address裝載地址)將被設(shè)置成val;如果這個(gè)選項(xiàng)中使用的是“-”或者“+”,那么LMA將被設(shè)置或者改變成這兩個(gè)地址的當(dāng)前值減去或加上val后的值。如果在輸入文件中名為section的段不存在,那么Objcopy將發(fā)出一個(gè)警告,除非--no-change-warnings選項(xiàng)被使用。 --change-section-vma section{=,+,-} val
僅設(shè)置或者改變名為section的段的VMA(Load Memory Address裝載地址)。一個(gè)段的VMA是程序運(yùn)行時(shí),該段的定位地址。通常VMA和LMA(Virtual Memory Address運(yùn)行時(shí)地址)是相同的,但是在某些系統(tǒng)中,特別是在那些程序放在ROM的系統(tǒng)中,LMA和VMA是不相同的。如果這個(gè)選項(xiàng)中使用的是“=”,那么名為section的段的LMA(Load Memory Address裝載地址)將被設(shè)置成val;如果這個(gè)選項(xiàng)中使用的是“-”或者“+”,那么LMA將被設(shè)置或者改變成這兩個(gè)地址的當(dāng)前值減去或加上val后的值。如果在輸入文件中名為section的段不存在,那么Objcopy將發(fā)出一個(gè)警告,除非--no-change-warnings選項(xiàng)被使用。 --change-warnings
--adjust-warnings
如果命令行中使用了--change-section-address section{=,+,-} val或者--adjust-section-vma section{=,+,-} val,又或者--change-section-lma section{=,+,-} val,又或者--change-section-vma section{=,+,-} val,并且輸入文件中名為section的段不存在,則Objcopy發(fā)出警告。這是默認(rèn)的選項(xiàng)。 --no-chagne-warnings
--no-adjust-warnings
如果命令行中使用了--change-section-address section{=,+,-} val或者--adjust-section-vma section{=,+,-} val,又或者--change-section-lma section{=,+,-} val,又或者--change-section-vma section{=,+,-} val,即使輸入文件中名為section的段不存在, Objcopy也不會(huì)發(fā)出警告。 --set-section-flags section=flags
為為section的段設(shè)置一個(gè)標(biāo)識(shí)。這個(gè)flags變量的可以取逗號(hào)分隔的多個(gè)標(biāo)識(shí)名字符串(這些標(biāo)識(shí)名字符串是能夠被Objcopy程序所識(shí)別的),合法的標(biāo)識(shí)名有alloc,load,readonly,code,data和rom。
You can set the contents flag for a section which does not havecontents, 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
進(jìn)行目標(biāo)文件拷貝的過(guò)程中,在輸出文件中增加一個(gè)名為sectionname的新段。這個(gè)新增加的段的內(nèi)容從文件filename得到。這個(gè)新增加的段的大小就是這個(gè)文件filename的大小。只要輸出文件的格式允許該文件的段可以有任意的段名(段名不是標(biāo)準(zhǔn)的,固定的),這個(gè)選項(xiàng)才能使用。 --change-leading-char
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 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
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. --weaken
Change all global symbols in the file to be weak. This can be useful when building
an object that will be linked against other objects using the -R option to the linker.
This option is only effective when using an object file format that supports weak
symbols. -V
--version
Show the version number of objcopy. -v
--verbose
Verbose output: list all object files modified. In the case of archives, objcopy -V
lists all members of the archive. --help
Show a summary of the options to objcopy.
(1)將圖像編譯到可執(zhí)行文件內(nèi) Q: 如何將一個(gè)二進(jìn)制文件,比如圖片,詞典一類的東西做為.o文件,直接鏈接到可執(zhí)行文件內(nèi)部呢? A:?
$ objcopy -I binary -O elf32-i386 -B i386 14_95_13.jpg image.o?
$ gcc image.o tt.o -o tt?
$ nm tt | grep 14_95?
0805d6c7 D _binary_14_95_13_jpg_end?
00014213 A _binary_14_95_13_jpg_size?
080494b4 D _binary_14_95_13_jpg_start?
(2)使用objcopy把不用的信息去掉: $ objcopy?-R?.comment?-R?.note?halo?halo.min?
(3)?
$ objcopy?-R?.note?-R?.comment?-S?-O?binary?xyb?xyb.bin?
-R?.note?-R?.comment?表示移掉?.note?與?.comment?段?
-S?表示移出所有的標(biāo)志及重定位信息?
-O?binary?xyb?xyb.bin?表示由xyb生成二進(jìn)制文件xyb.bin objcopy工具使用指南
objcopy Utility
objcopy [ -F bfdname | --target=bfdname ]
[ -I bfdname | --input-target=bfdname ]
[ -O bfdname | --output-target= bfdname ]
[ -S | --strip-all ] [ -g | --strip-debug ]
[ -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 ]
[ -R sectionname | --remove-section= sectionname ]
[ -p | --preserve-dates ] [ --debugging ]
[ --gap-fill= val ] [ --pad-to= address ]
[ --set-start= val ] [ --adjust-start= incr ]
[ --change-address= incr ]
[ --change-section-address= section{=,+,-} val ]
[ --change-warnings ] [ --no-change-warnings ]
[ --set-section-flags= section= flags ]
[ --add-section= sectionname= filename ]
[ --change-leading char ] [--remove-leading-char ]
[ --weaken ]
[ -v | --verbose ] [ -V | --version ] [ --help ]
input-file [ outfile ]?? GNU實(shí)用工具程序objcopy的作用是拷貝一個(gè)目標(biāo)文件的內(nèi)容到另一個(gè)目標(biāo)文件中。Objcopy使用GNU BFD庫(kù)去讀或?qū)懩繕?biāo)文件。Objcopy可以使用不同于源目標(biāo)文件的格式來(lái)寫(xiě)目的目標(biāo)文件(也即是說(shuō)可以將一種格式的目標(biāo)文件轉(zhuǎn)換成另一種格式的目標(biāo)文件)。通過(guò)以上命令行選項(xiàng)可以控制Objcopy的具體操作。
Objcopy在進(jìn)行目標(biāo)文件的轉(zhuǎn)換時(shí),將生成一個(gè)臨時(shí)文件,轉(zhuǎn)換完成后就將這個(gè)臨時(shí)文件刪掉。Objcopy使用BFD做轉(zhuǎn)換工作。如果沒(méi)有明確地格式要求,則Objcopy將訪問(wèn)所有在BFD庫(kù)中已經(jīng)描述了的并且它可以識(shí)別的格式,請(qǐng)參見(jiàn)《GNUpro Decelopment Tools》中“using ld”一章中“BFD庫(kù)”部分和“BFD庫(kù)中規(guī)范的目標(biāo)文件格式”部分。
通過(guò)使用srec作為輸出目標(biāo)(使用命令行選項(xiàng)-o srec),Objcopy可以產(chǎn)生S記錄格式文件。
通過(guò)使用binary作為輸出目標(biāo)(使用命令行選項(xiàng)-o binary),Objcopy可以產(chǎn)生原始的二進(jìn)制文件。使用Objcopy產(chǎn)生一個(gè)原始的二進(jìn)制文件,實(shí)質(zhì)上是進(jìn)行了一回輸入目標(biāo)文件內(nèi)容的內(nèi)存轉(zhuǎn)儲(chǔ)。所有的符號(hào)和重定位信息都將被丟棄。內(nèi)存轉(zhuǎn)儲(chǔ)起始于輸入目標(biāo)文件中那些將要拷貝到輸出目標(biāo)文件去的部分的最小虛地址處。
使用Objcopy生成S記錄格式文件或者原始的二進(jìn)制文件的過(guò)程中,-S選項(xiàng)和-R選項(xiàng)可能會(huì)比較有用。-S選項(xiàng)是用來(lái)刪掉包含調(diào)試信息的部分,-R選項(xiàng)是用來(lái)刪掉包含了二進(jìn)制文件不需要的內(nèi)容的那些部分。 input-file
outfile
參數(shù)input-file和outfile分別表示輸入目標(biāo)文件(源目標(biāo)文件)和輸出目標(biāo)文件(目的目標(biāo)文件)。如果在命令行中沒(méi)有明確地指定outfile,那么Objcopy將創(chuàng)建一個(gè)臨時(shí)文件來(lái)存放目標(biāo)結(jié)果,然后使用input-file的名字來(lái)重命名這個(gè)臨時(shí)文件(這時(shí)候,原來(lái)的input-file將被覆蓋)。 -I bfdname?
--input-target=bfdname
明確告訴Objcopy,源文件的格式是什么,bfdname是BFD庫(kù)中描述的標(biāo)準(zhǔn)格式名。這樣做要比“讓Objcopy自己去分析源文件的格式,然后去和BFD中描述的各種格式比較,通過(guò)而得知源文件的目標(biāo)格式名”的方法要高效得多。 -O bfdname?
--output-target= bfdname
使用指定的格式來(lái)寫(xiě)輸出文件(即目標(biāo)文件),bfdname是BFD庫(kù)中描述的標(biāo)準(zhǔn)格式名。 -F bfdname
--target= bfdname
明確告訴Objcopy,源文件的格式是什么,同時(shí)也使用這個(gè)格式來(lái)寫(xiě)輸出文件(即目標(biāo)文件),也就是說(shuō)將源目標(biāo)文件中的內(nèi)容拷貝到目的目標(biāo)文件的過(guò)程中,只進(jìn)行拷貝不做格式轉(zhuǎn)換,源目標(biāo)文件是什么格式,目的目標(biāo)文件就是什么格式。 -R sectionname
--remove-section= sectionname
從輸出文件中刪掉所有名為sectionname的段。這個(gè)選項(xiàng)可以多次使用。
注意:不恰當(dāng)?shù)厥褂眠@個(gè)選項(xiàng)可能會(huì)導(dǎo)致輸出文件不可用。 -S
--strip-all (strip 剝?nèi)ァ?#xff09;
不從源文件中拷貝重定位信息和符號(hào)信息到輸出文件(目的文件)中去。 -g
--strip-debug
不從源文件中拷貝調(diào)試符號(hào)到輸出文件(目的文件)中去。 --strip-undeeded
剝?nèi)ニ性谥囟ㄎ惶幚頃r(shí)所不需要的符號(hào)。 -K symbolname
--keep-symbol= symbolname
僅從源文件中拷貝名為symbolname的符號(hào)。這個(gè)選項(xiàng)可以多次使用。 -N symbolname
--strip-symbol= symbolname
不從源文件中拷貝名為symbolname的符號(hào)。這個(gè)選項(xiàng)可以多次使用。它可以和其他的strip選項(xiàng)聯(lián)合起來(lái)使用(除了-K symbolname | --keep-symbol= symbolname外)。 -L symbolname
--localize-symbol= symbolname
使名為symbolname的符號(hào)在文件內(nèi)局部化,以便該符號(hào)在該文件外部是不可見(jiàn)的。這個(gè)選項(xiàng)可以多次使用。 -W symbolname
-weaken-symbol= symbolname
弱化名為symbolname的符號(hào)。這個(gè)選項(xiàng)可以多次使用。 -x
--discard-all (discard 丟棄、拋棄)
不從源文件中拷貝非全局符號(hào)。 -X
--discard-locals
不從源文件中拷貝又編譯器生成的局部符號(hào)(這些符號(hào)通常是L或 . 開(kāi)頭的)。 -b byte
--byte= byte?
Keep only every 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 (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 (preserve 保存、保持)
設(shè)置輸出文件的訪問(wèn)和修改日期和輸入文件相同。 [ --debugging ]
如果可能的話,轉(zhuǎn)換調(diào)試信息。因?yàn)橹挥刑囟ǖ恼{(diào)試格式被支持,以及這個(gè)轉(zhuǎn)換過(guò)程要耗費(fèi)一定的時(shí)間,所以這個(gè)選項(xiàng)不是默認(rèn)的。
--gap-fill= val
使用內(nèi)容val填充段與段之間的空隙。通過(guò)增加段的大小,在地址較低的一段附加空間中填充內(nèi)容val來(lái)完成這一選項(xiàng)的功能。 --pad-to= address
填充輸出文件到虛擬地址address。通過(guò)增加輸出文件中最后一個(gè)段的大小,在輸出文件中最后一段的末尾和address之間的這段附加空間中,用--gap-fill= val選項(xiàng)中指定的內(nèi)容val來(lái)填充(默認(rèn)內(nèi)容是0,即沒(méi)有使用--gap-fill= val選項(xiàng)的情況下)。 --set-start= val
設(shè)置新文件(應(yīng)該是輸出文件吧?)的起始地址為val。不是所有的目標(biāo)文件格式都支持設(shè)置起始地址。 --change-start = incr
--adjust-start= incr
通過(guò)增加值incr來(lái)改變起始地址。不是所有的目標(biāo)文件格式都支持設(shè)置起始地址。 --change-addresses incr
--adjust-vma incr
Change the VMA and LMA addresses of all sections, section., as well as the
start address, by adding incr. Some object file formats do not permit section
addresses to be changed arbitrarily. 通過(guò)加上一個(gè)值incr,改變所有段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址),以及起始地址。某些目標(biāo)文件格式不允許隨便更改段的地址。 --change-section-address section{=,+,-} val
--adjust-section-vma section{=,+,-} val
設(shè)置或者改變名為section的段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)。如果這個(gè)選項(xiàng)中使用的是“=”,那么名為section的段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)將被設(shè)置成val;如果這個(gè)選項(xiàng)中使用的是“-”或者“+”,那么上述兩個(gè)地址將被設(shè)置或者改變成這兩個(gè)地址的當(dāng)前值減去或加上val后的值。如果在輸入文件中名為section的段不存在,那么Objcopy將發(fā)出一個(gè)警告,除非--no-change-warnings選項(xiàng)被使用。
這里的段地址設(shè)置和改變都是輸出文件中的段相對(duì)于輸入文件中的段而言的。例如:
(1)--change-section-address .text = 10000
這里是指將輸入文件(即源文件)中名為.text的段拷貝到輸出文件中后,輸出文件中的.text段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)將都被設(shè)置成10000。
(2)--change-section-address .text + 100
這里是指將輸入文件(即源文件)中名為.text的段拷貝到輸出文件中后,輸出文件中的.text段的VMA(Virtual Memory Address運(yùn)行時(shí)地址)和LMA(Load Memory Address裝載地址)將都被設(shè)置成以前輸入文件中.text段的地址(當(dāng)前地址)加上100后的值。 --change-section-lma section{=,+,-} val
僅設(shè)置或者改變名為section的段的LMA(Load Memory Address裝載地址)。一個(gè)段的LMA是程序被加載時(shí),該段將被加載到的一段內(nèi)存空間的首地址。通常LMA和VMA(Virtual Memory Address運(yùn)行時(shí)地址)是相同的,但是在某些系統(tǒng)中,特別是在那些程序放在ROM的系統(tǒng)中,LMA和VMA是不相同的。如果這個(gè)選項(xiàng)中使用的是“=”,那么名為section的段的LMA(Load Memory Address裝載地址)將被設(shè)置成val;如果這個(gè)選項(xiàng)中使用的是“-”或者“+”,那么LMA將被設(shè)置或者改變成這兩個(gè)地址的當(dāng)前值減去或加上val后的值。如果在輸入文件中名為section的段不存在,那么Objcopy將發(fā)出一個(gè)警告,除非--no-change-warnings選項(xiàng)被使用。 --change-section-vma section{=,+,-} val
僅設(shè)置或者改變名為section的段的VMA(Load Memory Address裝載地址)。一個(gè)段的VMA是程序運(yùn)行時(shí),該段的定位地址。通常VMA和LMA(Virtual Memory Address運(yùn)行時(shí)地址)是相同的,但是在某些系統(tǒng)中,特別是在那些程序放在ROM的系統(tǒng)中,LMA和VMA是不相同的。如果這個(gè)選項(xiàng)中使用的是“=”,那么名為section的段的LMA(Load Memory Address裝載地址)將被設(shè)置成val;如果這個(gè)選項(xiàng)中使用的是“-”或者“+”,那么LMA將被設(shè)置或者改變成這兩個(gè)地址的當(dāng)前值減去或加上val后的值。如果在輸入文件中名為section的段不存在,那么Objcopy將發(fā)出一個(gè)警告,除非--no-change-warnings選項(xiàng)被使用。 --change-warnings
--adjust-warnings
如果命令行中使用了--change-section-address section{=,+,-} val或者--adjust-section-vma section{=,+,-} val,又或者--change-section-lma section{=,+,-} val,又或者--change-section-vma section{=,+,-} val,并且輸入文件中名為section的段不存在,則Objcopy發(fā)出警告。這是默認(rèn)的選項(xiàng)。 --no-chagne-warnings
--no-adjust-warnings
如果命令行中使用了--change-section-address section{=,+,-} val或者--adjust-section-vma section{=,+,-} val,又或者--change-section-lma section{=,+,-} val,又或者--change-section-vma section{=,+,-} val,即使輸入文件中名為section的段不存在, Objcopy也不會(huì)發(fā)出警告。 --set-section-flags section=flags
為為section的段設(shè)置一個(gè)標(biāo)識(shí)。這個(gè)flags變量的可以取逗號(hào)分隔的多個(gè)標(biāo)識(shí)名字符串(這些標(biāo)識(shí)名字符串是能夠被Objcopy程序所識(shí)別的),合法的標(biāo)識(shí)名有alloc,load,readonly,code,data和rom。
You can set the contents flag for a section which does not havecontents, 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
進(jìn)行目標(biāo)文件拷貝的過(guò)程中,在輸出文件中增加一個(gè)名為sectionname的新段。這個(gè)新增加的段的內(nèi)容從文件filename得到。這個(gè)新增加的段的大小就是這個(gè)文件filename的大小。只要輸出文件的格式允許該文件的段可以有任意的段名(段名不是標(biāo)準(zhǔn)的,固定的),這個(gè)選項(xiàng)才能使用。 --change-leading-char
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 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
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. --weaken
Change all global symbols in the file to be weak. This can be useful when building
an object that will be linked against other objects using the -R option to the linker.
This option is only effective when using an object file format that supports weak
symbols. -V
--version
Show the version number of objcopy. -v
--verbose
Verbose output: list all object files modified. In the case of archives, objcopy -V
lists all members of the archive. --help
Show a summary of the options to objcopy.
總結(jié)
以上是生活随笔為你收集整理的objcopy的详细说明的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ncnn源码编译安装
- 下一篇: text段,data段,bss段,堆和栈