• arm-none-eabi-objcopy 使用说明


    译文

    NAME

           objcopy - copy and translate object files
    
    

    概要

           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]
                   [--dump-section sectionname=filename]
                   [--update-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]
                   [--add-symbol name=[section:]value[,flags]
                   [--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]
                   [--elf-stt-common=val]
                   [-v|--verbose]
                   [-V|--version]
                   [--help] [--info]
                   infile [outfile]

    描述

           GNU objcopy实用程序将一个对象文件的内容复制到另一个文件中。  objcopy使用
           GNU BFD库读取和写入目标文件。它可以写目的地
           目标文件的格式与源目标文件的格式不同。确切行为objcopy把由命令行选项来控制。请注意,objcopy应该能够
           在任何两种格式之间复制完全链接的文件。但是,复制可重定位的对象
           两种格式之间的文件可能无法正常工作。
    
           objcopy创建临时文件以进行翻译,然后将其删除。
           objcopy使用BFD进行所有翻译工作;它可以访问所有格式
           在BFD中进行了描述,因此无需明确说明就可以识别大多数格式。
    
           objcopy可用于通过使用srec的输出目标(例如,使用-O 
           srec来生成S记录
    
           objcopy可用于通过使用二进制输出目标
           (例如,使用-O  binary来生成原始二进制文件objcopy生成原始二进制文件时,它将基本上
           产生输入目标文件内容的内存转储。所有符号和
           重定位信息将被丢弃。内存转储将从加载地址开始
           复制到输出文件的最低部分的。
    
           生成S记录或原始二进制文件时,使用-S删除可能会有所帮助
           包含调试信息的部分。在某些情况下,-R对删除很有用
           包含二进制文件不需要的信息的部分。
    
           注意--- objcopy无法更改其输入文件的字节序。如果输入
           格式具有字节序(某些格式没有),objcopy只能将输入复制到文件中
           具有相同字节序或不具有字节序的格式(例如srec)。(然而,
           请参阅--reverse-bytes选项。)
    
    

    选项

           infile 
           outfile
               分别是输入文件和输出文件。如果未指定outfile,则objcopy将
               创建一个临时文件,并以infile的名称破坏性地重命名结果
    
           -I  bfdname 
           --input-target = bfdname
               认为源文件的对象格式为bfdname,而不是尝试
               推论它。
    
           -O  bfdname 
           --output-target = bfdname
               使用对象格式bfdname写入输出文件
    
           -F  bfdname 
           --target = bfdname
               使用bfdname作为输入文件和输出文件的对象格式;即,简单地
               无需翻译即可将数据从源传输到目标。
    
           -B  bfdarch 
           --binary-architecture = bfdarch
               将无架构的输入文件转换为目标文件时很有用。在这个
               可以将输出体系结构设置为bfdarch的情况如果此选项将被忽略
               输入文件具有已知的bfdarch您可以在程序中访问此二进制数据
               通过引用转换过程中创建的特殊符号。这些
               符号称为_binary_ objfile _start,_binary_ objfile _end和
               _binary_ objfile _size。例如,您可以将图片文件转换为目标文件,然后
               然后使用这些符号在您的代码中对其进行访问。
    
           -j  sectionpattern 
           --only-section = sectionpattern
               仅将指示的部分从输入文件复制到输出文件。这个选项
               可能会被多次给予。请注意,不当使用此选项可能会使
               输出文件不可用。sectionpattern中接受通配符
    
           -R  sectionpattern 
           --remove截面= sectionpattern
               删除任何部分匹配sectionpattern从输出文件。此选项可能是
               给予不止一次。请注意,不当使用此选项可能会使输出
               文件无法使用。sectionpattern中接受通配符同时使用-j-R选项会导致未定义的行为。
    
           -S-
           全部
               不要从源文件复制重定位和符号信息。
    
           -g 
           --strip-调试
               不要从源文件中复制调试符号或节。
    
           -不需要条纹
               去除重定位处理不需要的所有符号。
    
           -K  symbolname 
           --keep-symbol = symbolname
               剥离符号时,即使通常会剥离,也要保留符号symbolname
               可以多次给此选项。
    
           -N  symbolname 
           --strip-symbol = symbolname
               不复制源文件中的symbol symbolname可以给这个选项更多
               不止一次。
    
           --strip-unneeded-symbol = symbolname除非源文件需要,否则
               不要从源文件中复制符号symbolname
               搬迁。可以多次给此选项。
    
           -G  symbolname 
           --keep-global-symbol = symbolname保留全局符号symbolname使所有其他符号位于文件本地,以便
               它们在外部不可见。可以多次给此选项。
    
           --localize-hidden
               在ELF对象中,将所有具有隐藏或内部可见性的符号标记为局部。
               此选项适用于特定于符号的本地化选项(例如-L)
    
           -L  symbolname 
           --localize-symbol = symbolname
               将符号symbolname设置为文件本地,以使其在外部不可见。
               选项可能会多次给出。
    
           -W  symbolname 
           --weaken-symbol = symbolname
               使符号symbolname变弱。可以多次给此选项。
    
           --globalize-symbol = symbolname
               赋予符号symbolname全局作用域,以便在文件的外部可见
               它是定义的。可以多次给此选项。
    
           -w 
           --wildcard
               允许在其他命令行选项中使用的symbolname中正则表达式
               问号(?),星号(*),反斜杠()和方括号([])运算符可以
               可在符号名称中的任何位置使用。如果符号名称的第一个字符是
               感叹号(!),则该符号的开关方向相反。为了
               例子:
    
                         -w -W!foo -W fo *
    
               会导致objcopy削弱所有以“ fo”开头的符号,除了该符号
               “ foo”。
    
           -x 
           --discard,所有
               不要从源文件复制非全局符号。
    
           -X 
           --discard-locals
               不要复制编译器生成的本地符号。(这些通常以L开头。)
    
           -b 字节
           --byte =字节
               如果通过--interleave选项启用了交错,则开始范围
               字节保持在字节个字节。  字节的范围可以从0到宽度-1,其中
               宽度--interleave选项给出的值
    
           -i  [广度] 
           --interleave [=广度]
               只复制的范围超出每广度字节。(标题数据不受影响)。选择
               范围中的哪个字节以--byte选项开始复制选择宽度--interleave-width选项
               的范围
    
               此选项对于创建要编程ROM的文件很有用。通常与
               “ srec”输出目标。请注意,如果您也未指定--byte选项,则objcopy将抱怨
               
    
               默认的交错宽度为4,因此当--byte设置为0时,objcopy将复制
               从输入到输出的每四个字节中的第一个字节。
    
           --interleave-width = width--interleave选项一起使用时,一次复制宽度字节。的开始
               要复制的字节范围由--byte选项设置,范围的范围
               使用--interleave选项设置
    
               此选项的默认值是1的值宽度加上字节值集合通过--byte选项必须不被超过交错广度集--interleave
               选项。
    
               此选项可用于为两个交错的16位闪光灯创建图像。
               通过将-b  0  -i  4  --interleave-width = 2-b  2  -i  4 
               --interleave-width = 2传递给两个objcopy命令来实现32位总线如果输入为“ 12345678”,则
               输出分别为“ 1256”和“ 3478”。
    
           -p 
           --preserve-日期
               将输出文件的访问和修改日期设置为与
               输入文件。
    
           -D-
           启用确定性归档确定性模式运行。复制档案成员并写入档案时
               索引,将UID,GID,时间戳记为零,并将所有文件使用一致的文件模式
               文件。
    
               如果binutils配置了--enable-deterministic-archives,则此模式为开
               默认情况下。可以使用下面-U选项禁用它
    
           -U 
           --disable确定性的存档
               千万不能在运行确定性模式。这与上面-D选项相反。
               复制存档成员并写入存档索引时,请使用其实际的UID,GID,
               时间戳记和文件模式值。
    
               这是默认设置,除非binutils配置了
               --enable-deterministic-archives
    
           - 调试
               尽可能转换调试信息。这不是默认值,因为
               支持某些调试格式,转换过程可能很耗时
               消耗。
    
           --gap填充 VAL
               与段之间填补空白VAL此操作适用于加载 地址(LMA)
               部分。这是通过增加该部分的大小来降低的
               地址,并填充使用val创建的额外空间
    
           --pad-to  address
               将输出文件填充到加载地址address这是通过增加
               最后一节的大小。多余的空间用以下值指定
               --gap-fill(默认为零)。
    
           --set-start  val
               将新文件的起始地址设置为val并非所有目标文件格式都支持
               设置起始地址。
    
           --change-start  incr 
           --adjust-start  incr
               通过添加incr更改起始地址并非所有目标文件格式都支持设置
               起始地址。
    
           --change-  addresss增量
           --adjust-vma 增量
               通过以下方法更改所有部分的VMA和LMA地址以及起始地址
               添加incr某些目标文件格式不允许更改节地址
               任意地。请注意,这不会重定位这些部分;如果程序期望
               节将加载到某个地址,并且此选项用于更改
               如果将它们装入不同的地址,则程序可能会失败。
    
           --change-section-address  sectionpattern {=,+,-} val 
           --adjust-section-vma  sectionpattern {=,+,-} val
               设置或更改任何匹配部分的VMA地址和LMA地址
               节模式如果使用=,则段地址设置为val否则,val
               添加到节地址或从节地址中减去。请参阅下面的评论
               --change-addresses,上面。如果sectionpattern与输入中的任何部分都不匹配
               文件,将发出警告,除非使用--no-change-warnings
    
           --change-section-lma  sectionpattern {=,+,-} val
               设置或更改与sectionpattern匹配的任何节的LMA地址LMA
               address是在程序加载时该段将被加载到内存中的地址
               时间。通常,这与VMA地址相同,即VMA的地址。
               部分在程序运行时进行,但在某些系统上,尤其是在其中有程序的系统
               保存在ROM中,两者可以不同。如果使用=,则段地址设置为
               val否则,将val添加到节地址或从节地址中减去。上面--change-addresses
               下的注释如果sectionpattern不匹配
               输入文件中的节,将发出警告,除非--no-change-warnings
               用过的。
    
           --change-section-vma  sectionpattern {=,+,-} val
               设置或更改任何与sectionpattern匹配的节的VMA地址VMA地址
               是程序启动后该部分将位于的地址
               执行。通常,这与LMA地址相同,即
               该部分将被加载到内存中,但是在某些系统上,尤其是那些
               程序保存在ROM中,两者可以不同。如果使用=,则段地址
               设置为val否则,将val添加到节地址或从节地址中减去。
               请参阅上方--change-addresses下的注释如果sectionpattern不匹配
               输入文件中的任何部分,都会发出警告,除非--no-change-warnings
               用来。
    
           --change-warnings 
           --adjust-warnings
               如果使用--change-section-address--change-section-lma--change-section-vma
               并且节模式与任何节都不匹配,请发出警告。这是
               默认。
    
           --no-change-warnings 
           --no-adjust-warnings
               如果使用--change-section-address--adjust-section-lma--adjust-section-vma,即使该节位于模式与任何部分都不匹配。
    
           --set-section-flags  sectionpattern =标志
               设置与sectionpattern匹配的任何部分的标志标志参数是一个逗号
               标记名称的分隔字符串。可识别的名称是alloc内容loadnoloadreadonly代码dataromsharedebug您可以设置内容标志
               对于没有内容的部分,但清除该部分没有意义
               具有内容的部分的内容标志-只需删除该部分即可。
               并非所有标志对于所有目标文件格式都有意义。
    
           --add-section  sectionname = filename复制文件时
               添加一个名为sectionname的新部分新内容
               部分取自文件filename该部分的大小将是
               文件。此选项仅适用于支持以下格式的文件格式:
               任意名称。注意-可能需要使用--set-section-flags选项
               设置新创建的部分的属性。
    
           --dump-section  sectionname = filename
               将名为sectionname的节的内容放入文件filename中,覆盖
               以前可能在那里的任何内容。此选项是
               --add-section该选项类似于--only-section选项,除了它
               不创建格式化文件,它只是将内容转储为原始二进制数据,
               而不应用任何重定位。可以多次指定该选项。
    
           --update截面 sectionname =文件名
               替换已命名的节中的现有内容sectionname与文件的内容
               的文件名该部分的大小将调整为文件的大小。sectionname的
               section标志将保持不变。对于ELF格式的文件,请参阅
               段映射也将保持不变,这是无法使用的
               --remove-section--add-section该选项可以指定多个
               一次。
    
               注意-可以使用--rename-section--update-section来更新和
               从一个命令行重命名节。在这种情况下,请传递原始节名称--update-section,原始和新的部分名称到--rename-section
    
           --add-symbol  name = [ section :] value [,flags ]在复制文件时
               添加一个名为name的新符号可以指定此选项
               多次。如果给出了部分,则该符号将与和
               相对于该部分,否则将是ABS符号。指定一个未定义
               部分将导致致命错误。没有检查该值,它将是
               按指定采取。可以指定符号标志,并非所有标志都可以
               对于所有目标文件格式都有意义。默认情况下,该符号为全局符号。
               特殊标志'before = othersym '将在指定的elseym之前插入新符号
               ,否则将在符号表的末尾添加符号。
               他们出现的顺序。
    
           --rename-section  oldname = newname [,flags ]
               将一个节从oldname重命名newname,可以选择在此过程中将该节的标志更改为
               flags与使用链接程序脚本执行以下操作相比,这具有优势
               重命名,因为输出将保留为目标文件,并且不会成为链接文件
               可执行文件。
    
               当输入格式为二进制时,此选项特别有用,因为它将
               始终创建一个名为.data的节。例如,如果您想创建一个
               包含二进制数据的名为.rodata的部分,您可以使用以下命令行
               实现它:
    
                         objcopy -I二进制-O <输出格式> -B <体系结构> 
                          --rename-section .data = .rodata,alloc,load,readonly,data,contents 
                          <输入二进制文件> <输出对象文件>
    
           --long-section-names  {启用,禁用,保留}
               处理“ COFF”和“ PE-COFF”时控制长节名称的处理
               对象格式。默认行为keep,是保留长节名称(如果有)
               在输入文件中。启用禁用选项强制启用或
               禁止在输出对象中使用长节名称;禁用生效时,
               输入对象中的任何长节名称都将被截断。启用选项
               如果输入中存在长节名,则仅发出长节名;这大致相同keep一样,但是使能选项是否可能强制创建仍未定义
               输出文件中的空字符串表。
    
           --change-lead-char
               某些目标文件格式在符号开头使用特殊字符。最多
               下划线通常是此类字符,编译器通常在每个符号前添加下划线。
               此选项告诉objcopy更改每个符号的前导字符
               在目标文件格式之间转换。如果目标文件格式使用相同的前导
               字符,此选项无效。否则,它将添加一个字符,或删除一个
               字符,或酌情更改字符。
    
           -删除领先的字符
               如果全局符号的第一个字符是使用的特殊符号前导字符
               通过目标文件格式,删除字符。最常见的符号领先
               字符是下划线。此选项将从全球范围内删除领先的下划线
               符号。如果要将不同文件的对象链接在一起,这将很有用。
               符号名称使用不同约定的格式。这不同于
               --change-leading-char,因为它总是在适当的时候更改符号名称,
               无论输出文件的目标文件格式如何。
    
           --reverse-bytes = num
               反转具有输出内容的节中的字节。截面长度必须均匀
               被给定值整除以便能够进行交换。倒车
               发生在执行交织之前。
    
               此选项通常用于为有问题的目标系统生成ROM映像。
               例如,在某些目标板上,将从8位ROM读取的32位字重新
               不论CPU字节顺序如何,都以低位字节顺序汇编。根据
               在编程模型中,可能需要修改ROM​​的字节序。
    
               考虑一个简单的文件,该文件的节包含以下八个字节:12345678。
    对于上面的示例,
               使用--reverse-bytes = 2,输出文件中的字节为
               订购21436587。
    对于上面的示例,
               使用--reverse-bytes = 4,输出文件中的字节为
               订购43218765。
    
               通过使用--reverse字节= 2的以上示例中,接着--reverse字节= 4上的
               输出文件,第二个输出文件中的字节将被排序34127856。
    
           --srec-len = ival
               仅对srec输出有意义。设置Srecords的最大长度为
               生产到节日该长度涵盖地址,数据和crc字段。
    
           --srec-forceS3
               仅对srec输出有意义。避免生成S1 / S2记录,仅创建S3
               记录格式。
    
           --redefine-sym  old = new
               将符号old的名称更改new当人们尝试链接时,这可能会很有用
               两件事在一起,你没有源头,并且有名字冲突。
    
           --redefine-SYMS =文件名
               应用--redefine -均每个符号对“ ”的文件中列出的文件名filename是简单的平面文件,每行一对符号。行注释可能是
               由井号字符引入。可以多次给此选项。
    
           - 削弱
               将文件中的所有全局符号更改为弱。在构建一个
               使用链接器-R选项与其他对象链接的对象
               仅当使用支持弱文件格式的目标文件格式时,此选项才有效。
               符号。
    
           --keep-symbols = filename--keep-symbol选项应用于文件filename中列出的每个符号文件名
               只是一个平面文件,每行一个符号名称。行注释可以通过以下方式引入
               哈希字符。可以多次给此选项。
    
           --strip-symbols = filename--strip-symbol选项应用于文件filename中列出的每个符号文件名
               只是一个平面文件,每行一个符号名称。行注释可以通过以下方式引入
               哈希字符。可以多次给此选项。
    
           --strip-unneeded-symbols = filename--strip-unneeded-symbol选项应用于文件filename中列出的每个符号filename是简单的平面文件,每行一个符号名称。行注释可能是
               由井号字符引入。可以多次给此选项。
    
           --keep-global-symbols = filename--keep-global-symbol选项应用于文件filename中列出的每个符号filename是简单的平面文件,每行一个符号名称。行注释可能是
               由井号字符引入。可以多次给此选项。
    
           --localize-symbols = filename--localize-symbol选项应用于文件filename中列出的每个符号文档名称
               只是一个平面文件,每行一个符号名称。可能会引入行注释
               通过井号字符。可以多次给此选项。
    
           --globalize-symbols = filename--globalize-symbol选项应用于文件filename中列出的每个符号文档名称
               只是一个平面文件,每行一个符号名称。可能会引入行注释
               通过井号字符。可以多次给此选项。
    
           --weaken-symbols = filename--weaken-symbol选项应用于文件filename中列出的每个符号文件名
               只是一个平面文件,每行一个符号名称。行注释可以通过以下方式引入
               哈希字符。可以多次给此选项。
    
           --alt-machine-code = index
               如果输出体系结构具有备用机器代码,请改用index th代码
               默认之一。如果为机器分配了官方代码,并且
               工具链采用了新代码,但其他应用程序仍依赖于
               正在使用原始代码。对于基于ELF的体系结构,如果使用索引替代项
               不存在,则将该值视为要存储在
               ELF标头的e_machine字段。
    
           -可写文本
               将输出文本标记为可写。此选项对所有目标文件都没有意义
               格式。
    
           --readonly-text
               使输出文本具有写保护。此选项对所有对象都没有意义
               文件格式。
    
           - 纯的
               将输出文件标记为按需分页。此选项对所有对象都没有意义
               文件格式。
    
           -不纯
               将输出文件标记为不纯。此选项对所有目标文件都没有意义
               格式。
    
           --prefix符号=
               前缀与输出文件中的所有符号
    
           --prefix-sections = string
               使用string将输出文件中的所有节名称前缀
    
           --prefix-alloc-sections = string
               使用string将输出文件中所有已分配节的所有名称前缀
    
           --add-gnu-debuglink =文件路径
               创建一个.gnu_debuglink节,其中包含对文件路径的引用并添加
               它到输出文件。注意:指向文件路径的文件必须存在。的一部分
               添加.gnu_debuglink节的过程涉及嵌入以下文件的校验和:
               将调试信息文件的内容放入该部分。
    
               如果调试信息文件建在一个位置,但要安装在一个位置
               稍后进入另一个位置,则不要使用安装路径
               地点。--add-GNU-debuglink因为安装文件执行选项将失败
               还不存在。而是将调试信息文件放在当前目录中,并使用
               --add-gnu-debuglink选项,不包含任何目录组件,例如:
    
                        objcopy --add-gnu-debuglink = foo.debug
    
               在调试时,调试器将尝试在以下位置查找单独的调试信息文件:
               一组已知位置。这些位置的确切集合取决于
               使用的发行版,但通常包括:
    
               “ *与可执行文件相同的目录。”
               “ *包含可执行文件的目录的子目录”
                   叫做.debug
    
               “ *全局调试目录,例如/ usr / lib / debug。
    
               只要之前将调试信息文件安装到这些位置之一中,
               调试器正在运行,一切应该正常工作。
    
           --keep-file-symbols
               剥离文件时,可能使用--strip-debug--strip-unneeded时,保留任何
               指定源文件名的符号,否则将被剥离。
    
           --only-keep-debug
               剥离文件,删除不会被剥离的任何节的内容
               --strip-debug并保持调试部分完整无缺。在ELF文件中,此保留
               输出中的所有注释部分。
    
               注意-保留已删除部分的部分标题,包括它们的标题
               大小,但该部分的内容将被丢弃。节标题是
               保留,以便其他工具可以将debuginfo文件与实际
               可执行文件,即使该可执行文件已重定位到其他地址空间。
    
               目的是将此选项与--add-gnu-debuglink结合使用
               创建一个两部分的可执行文件。一个剥离的二进制文件,它将占用较少的空间
               在RAM和分发中,第二个是调试信息文件
               如果需要调试功能,则需要。建议的程序来创建这些
               文件如下:
    
               1. <正常链接可执行文件。假设被称为>
                   然后是“ foo”
    
               1. <运行“ objcopy --only-keep-debug foo foo.dbg”到>
                   创建一个包含调试信息的文件。
    
               1. <运行“ objcopy --strip-debug foo”创建一个>
                   剥离的可执行文件。
    
               1. <运行“ objcopy --add-gnu-debuglink = foo.dbg foo”>
                   将调试信息的链接添加到剥离的可执行文件中。
    
               注意---选择“ .dbg”作为调试信息文件的扩展名是任意的。
               同样,“-only-keep-debug”步骤是可选的。您可以改为:
    
               1. <正常链接可执行文件。
               1. <将“ foo”复制到“ foo.full”
               1. <运行“ objcopy --strip-debug foo”>
               1. <运行“ objcopy --add-gnu-debuglink = foo.full foo”>
    
               即,-- add-gnu-debuglink指向的文件可以是完整的可执行文件。
               不必是--only-keep-debug开关创建的文件
    
               注意-此开关仅适用于完全链接的文件。它不会
               在调试信息可能不完整的目标文件上使用它是有意义的。
               此外,gnu_debuglink功能目前仅支持存在一个文件名
               包含调试信息,而不是每个对象一个文件包含多个文件名
               基础。
    
           --strip-dwo
               删除所有DWARF .dwo节的内容,保留其余调试信息
               部分和所有符号完整无缺。此选项供编译器使用-gsplit-dwarf选项的
               一部分,该选项在.o文件之间拆分调试信息
               和一个单独的.dwo文件。编译器在同一时间生成所有调试信息
               文件,然后使用--extract-dwo选项将.dwo部分复制到.dwo文件中,
               然后使用--strip-dwo选项从原始.o文件中删除这些部分。
    
           --extract-dwo
               提取所有DWARF .dwo节的内容。有关更多信息,请参见--strip-dwo选项
               信息。
    
           --file-alignment  num
               指定文件对齐方式。文件中的节将始终以文件偏移量开始
               是此数字的倍数。默认值为512。[此选项特定
               PE目标。]
    
           --heap  reserve 
           --heap  reserve 提交
               指定要保留(和可选地)用作的内存字节数
               该程序的堆。[此选项特定于PE目标。]
    
           --image-base  value
               使用value作为程序或dll的基址。这是最低的内存
               加载程序或dll时将使用的位置。减少需要
               迁移并提高dll的性能,每个dll都应具有唯一的基址
               并且不与任何其他dll重叠。可执行文件的默认值为0x400000,并且
               dll为0x10000000。[此选项特定于PE目标。]
    
           --section-alignment  num
               设置截面对齐方式。内存中的部分将始终从以下地址开始
               是此数字的倍数。预设为0x1000。[此选项特定于PE
               目标。]
    
           --stack 储备
           --stack 储备提交
               指定要保留(和可选地)用作的内存字节数
               该程序的堆栈。[此选项特定于PE目标。]
    
           --subsystem 其中
           --subsystem 其中major 
           --subsystem 其中major 次要的
               指定程序将在其下执行的子系统。的法律价值
               分别是“本机”,“窗口”,“控制台”,“ posix”,“ efi-app”,“ efi-bsd”,“ efi-rtd”,
               “ sal-rtd”和“ xbox”。您也可以选择设置子系统版本。数字
               还接受其中的[此选项特定于PE目标。]
    
           --extract-符号
               保留文件的节标记和符号,但删除所有节数据。具体来说,
               选项:
    
               * <删除所有部分的内容;>
               * <将每个部分的大小设置为零;和>
               * <将文件的起始地址设置为零。
    
               此选项用于为VxWorks内核构建.sym文件。也可以是
               减小--just-symbols链接器输入文件大小的有用方法
    
           --compress-debug-sections
               使用zlib和ELF ABI的SHF_COMPRESSED压缩DWARF调试节。笔记 -
               如果压缩实际上会使一个部分变大,则它不会被压缩。
    
           --compress-debug-sections =无
           --compress-debug-sections = zlib 
           --compress-debug-sections = zlib-gnu 
           --compress-debug-sections = zlib-gabi
               对于ELF文件,这些选项控制DWARF调试节的压缩方式。
               --compress-debug-sections = none等效于--decompress-debug-sections--compress-debug-sections = zlib--compress-debug-sections = zlib-gabi是等效的--compress调试截面--compress-debug-sections = zlib-gnu压缩DWARF
               使用zlib调试部分。将调试部分重命名为以.zdebug
               而不是.debug开头注意-如果压缩实际上会使部分变大,则
               它没有压缩也没有重命名。
    
           --decompress-debug-sections
               使用zlib解压缩DWARF调试部分。的原始部分名称
               压缩的节将恢复。
    
           --elf-stt-common =是
           --elf-stt-common =否
               对于ELF文件,这些选项控制是否应将通用符号转换为
               “ STT_COMMON”或“ STT_OBJECT”类型。  --elf-stt-common = yes转换常用符号类型
               到“ STT_COMMON”。--elf-stt-common = no将常用符号类型转换为“ STT_OBJECT”。
    
           -V 
           --version
               显示objcopy的版本号
    
           -v 
           --verbose
               详细输出:列出所有已修改的目标文件。对于档案,使用objcopy  -V
               列出存档的所有成员。
    
           --help
               显示objcopy选项的摘要
    
           - 信息
               显示一个列表,其中列出了所有可用的体系结构和对象格式。
    
           @ filefile中读取命令行选项读取的选项将插入
               原始@文件选项。如果文件不存在或无法读取,则该选项
               将按字面意义处理,并且不会删除。
    文件中的
               选项用空格分隔。可能包含空格字符
               在选项中将整个选项括在单引号或双引号中。任何
               字符(包括反斜杠)可以通过在字符前面加上
               包含反斜杠。文件本身可能包含其他@文件选项;任何
               这样的选项将被递归处理。
    
    

    另请参见

           ld(1), objdump(1)和binutils的Info条目
    
    
           版权所有(c)1991-2016 Free Software Foundation,Inc.
    
           根据以下条款授予复制,分发和/或修改本文档的权限
           GNU Free Documentation License版本1.3或Free发布的任何更高版本
           软件基础;没有不变的部分,没有封面的文本,也没有
           封底文本。许可证的副本包含在标题为“ GNU Free
           文档许可证”。

    原文

    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]
                   [--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]
                   [--globalize-symbol=symbolname]
                   [--globalize-symbols=filename]
                   [-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]
                   [--keep-section=sectionpattern]
                   [--remove-relocations=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]
                   [--set-section-alignment sectionpattern=align]
                   [--add-section sectionname=filename]
                   [--dump-section sectionname=filename]
                   [--update-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]
                   [--weaken-symbols=filename]
                   [--add-symbol name=[section:]value[,flags]]
                   [--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]
                   [--elf-stt-common=val]
                   [--merge-notes]
                   [--no-merge-notes]
                   [--verilog-data-width=val]
                   [-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 sectionpattern
           --only-section=sectionpattern
               Copy only the indicated sections 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.  Wildcard characters are accepted in sectionpattern.
    
               If the first character of sectionpattern is the exclamation point (!) then matching
               sections will not be copied, even if earlier use of --only-section on the same command
               line would otherwise copy it.  For example:
    
                         --only-section=.text.* --only-section=!.text.foo
    
               will copy all sectinos maching '.text.*' but not the section '.text.foo'.
    
           -R sectionpattern
           --remove-section=sectionpattern
               Remove any section matching sectionpattern from the output file.  This option may be
               given more than once.  Note that using this option inappropriately may make the output
               file unusable.  Wildcard characters are accepted in sectionpattern.  Using both the -j
               and -R options together results in undefined behaviour.
    
               If the first character of sectionpattern is the exclamation point (!) then matching
               sections will not be removed even if an earlier use of --remove-section on the same
               command line would otherwise remove it.  For example:
    
                         --remove-section=.text.* --remove-section=!.text.foo
    
               will remove all sections matching the pattern '.text.*', but will not remove the
               section '.text.foo'.
    
           --keep-section=sectionpattern
               When removing sections from the output file, keep sections that match sectionpattern.
    
           --remove-relocations=sectionpattern
               Remove non-dynamic relocations from the output file for any section matching
               sectionpattern.  This option may be given more than once.  Note that using this option
               inappropriately may make the output file unusable, and attempting to remove a dynamic
               relocation section such as .rela.plt from an executable or shared library with
               --remove-relocations=.plt will not work.  Wildcard characters are accepted in
               sectionpattern.  For example:
    
                         --remove-relocations=.text.*
    
               will remove the relocations for all sections matching the pattern '.text.*'.
    
               If the first character of sectionpattern is the exclamation point (!) then matching
               sections will not have their relocation removed even if an earlier use of
               --remove-relocations on the same command line would otherwise cause the relocations to
               be removed.  For example:
    
                         --remove-relocations=.text.* --remove-relocations=!.text.foo
    
               will remove all relocations for sections matching the pattern '.text.*', but will not
               remove relocations for the section '.text.foo'.
    
           -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.  Note: this
               option cannot be used in conjunction with the --globalize-symbol or
               --globalize-symbols options.
    
           --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
               Convert a global or weak symbol called symbolname into a local symbol, so that it is
               not visible externally.  This option may be given more than once.  Note - unique
               symbols are not converted.
    
           -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.  Note: this option
               cannot be used in conjunction with the -G or --keep-global-symbol options.
    
           -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
               If interleaving has been enabled via the --interleave option then start the range of
               bytes to keep at the byteth byte.  byte can be in the range from 0 to breadth-1, where
               breadth is the value given by the --interleave option.
    
           -i [breadth]
           --interleave[=breadth]
               Only copy a range out of every breadth bytes.  (Header data is not affected).  Select
               which byte in the range begins the copy with the --byte option.  Select the width of
               the range with the --interleave-width option.
    
               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
               When used with the --interleave option, copy width bytes at a time.  The start of the
               range of bytes to be copied is set by the --byte option, and the extent of the range
               is set with the --interleave option.
    
               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
               Set the access and modification dates of the output file to be the same as those of
               the input file.
    
           -D
           --enable-deterministic-archives
               Operate in deterministic mode.  When copying archive members and writing the archive
               index, use zero for UIDs, GIDs, timestamps, and use consistent file modes for all
               files.
    
               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
               Do not operate in deterministic mode.  This is the inverse of the -D option, above:
               when copying archive members and writing the archive index, use their actual UID, GID,
               timestamp, and file mode values.
    
               This is the default unless binutils was configured with
               --enable-deterministic-archives.
    
           --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 sectionpattern{=,+,-}val
           --adjust-section-vma sectionpattern{=,+,-}val
               Set or change both the VMA address and the LMA address of any section matching
               sectionpattern.  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 sectionpattern does not match any sections in the input
               file, a warning will be issued, unless --no-change-warnings is used.
    
           --change-section-lma sectionpattern{=,+,-}val
               Set or change the LMA address of any sections matching sectionpattern.  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 sectionpattern does not match any
               sections in the input file, a warning will be issued, unless --no-change-warnings is
               used.
    
           --change-section-vma sectionpattern{=,+,-}val
               Set or change the VMA address of any section matching sectionpattern.  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 sectionpattern does not match
               any sections 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 section pattern does not match any sections, 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 section pattern does not match any sections.
    
           --set-section-flags sectionpattern=flags
               Set the flags for any sections matching sectionpattern.  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.
    
           --set-section-alignment sectionpattern=align
               Set the alignment for any sections matching sectionpattern.  align specifies the
               alignment in bytes and must be a power of two, i.e. 1, 2, 4, 8....
    
           --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.  Note - it may be necessary to use the --set-section-flags option to
               set the attributes of the newly created section.
    
           --dump-section sectionname=filename
               Place the contents of section named sectionname into the file filename, overwriting
               any contents that may have been there previously.  This option is the inverse of
               --add-section.  This option is similar to the --only-section option except that it
               does not create a formatted file, it just dumps the contents as raw binary data,
               without applying any relocations.  The option can be specified more than once.
    
           --update-section sectionname=filename
               Replace the existing contents of a section named sectionname with the contents of file
               filename.  The size of the section will be adjusted to the size of the file.  The
               section flags for sectionname will be unchanged.  For ELF format files the section to
               segment mapping will also remain unchanged, something which is not possible using
               --remove-section followed by --add-section.  The option can be specified more than
               once.
    
               Note - it is possible to use --rename-section and --update-section to both update and
               rename a section from one command line.  In this case, pass the original section name
               to --update-section, and the original and new section names to --rename-section.
    
           --add-symbol name=[section:]value[,flags]
               Add a new symbol named name while copying the file.  This option may be specified
               multiple times.  If the section is given, the symbol will be associated with and
               relative to that section, otherwise it will be an ABS symbol.  Specifying an undefined
               section will result in a fatal error.  There is no check for the value, it will be
               taken as specified.  Symbol flags can be specified and not all flags will be
               meaningful for all object file formats.  By default, the symbol will be global.  The
               special flag 'before=othersym' will insert the new symbol in front of the specified
               othersym, otherwise the symbol(s) will be added at the end of the symbol table in the
               order they appear.
    
           --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 using 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 <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}
               Controls the handling of long section names when processing "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
               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.  This is different from
               --change-leading-char because it always changes the symbol name when appropriate,
               regardless of the object file format of the output file.
    
           --reverse-bytes=num
               Reverse the bytes in a section with output contents.  A section length must be evenly
               divisible by the value given in order for the swap to be able to take place. Reversing
               takes place before the interleaving is performed.
    
               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
               Meaningful only for srec output.  Set the maximum length of the Srecords being
               produced to ival.  This length covers both address, data and crc fields.
    
           --srec-forceS3
               Meaningful only for srec output.  Avoid generation of S1/S2 records, creating S3-only
               record format.
    
           --redefine-sym old=new
               Change the name of a symbol old, to new.  This can be useful when one is trying link
               two things together for which you have no source, and there are name collisions.
    
           --redefine-syms=filename
               Apply --redefine-sym to each symbol pair "old new" listed in the file filename.
               filename 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.
    
           --weaken
               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 -R option to the linker.
               This option is only effective when using an object file format which supports weak
               symbols.
    
           --keep-symbols=filename
               Apply --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
               Apply --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.
    
           --strip-unneeded-symbols=filename
               Apply --strip-unneeded-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
               Apply --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
               Apply --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.
    
           --globalize-symbols=filename
               Apply --globalize-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.  Note: this option
               cannot be used in conjunction with the -G or --keep-global-symbol options.
    
           --weaken-symbols=filename
               Apply --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
               If the output architecture has alternate machine codes, use the indexth 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.  For ELF based architectures if the index alternative does
               not exist then the value is treated as an absolute number to be stored in the
               e_machine field of the ELF header.
    
           --writable-text
               Mark the output text as writable.  This option isn't meaningful for all object file
               formats.
    
           --readonly-text
               Make the output text write protected.  This option isn't meaningful for all object
               file formats.
    
           --pure
               Mark the output file as demand paged.  This option isn't meaningful for all object
               file formats.
    
           --impure
               Mark the output file as impure.  This option isn't meaningful for all object file
               formats.
    
           --prefix-symbols=string
               Prefix all symbols in the output file with string.
    
           --prefix-sections=string
               Prefix all section names in the output file with string.
    
           --prefix-alloc-sections=string
               Prefix all the names of all allocated sections in the output file with string.
    
           --add-gnu-debuglink=path-to-file
               Creates a .gnu_debuglink section which contains a reference to path-to-file and adds
               it to the output file.  Note: the file at path-to-file must exist.  Part of the
               process of adding the .gnu_debuglink section involves embedding a checksum of the
               contents of the debug info file into the section.
    
               If the debug info file is built in one location but it is going to be installed at a
               later time into a different location then do not use the path to the installed
               location.  The --add-gnu-debuglink option will fail because the installed file does
               not exist yet.  Instead put the debug info file in the current directory and use the
               --add-gnu-debuglink option without any directory components, like this:
    
                        objcopy --add-gnu-debuglink=foo.debug
    
               At debug time the debugger will attempt to look for the separate debug info file in a
               set of known locations.  The exact set of these locations varies depending upon the
               distribution being used, but it typically includes:
    
               "* The same directory as the executable."
               "* A sub-directory of the directory containing the executable"
                   called .debug
    
               "* A global debug directory such as /usr/lib/debug."
    
               As long as the debug info file has been installed into one of these locations before
               the debugger is run everything should work correctly.
    
           --keep-file-symbols
               When stripping a file, perhaps with --strip-debug or --strip-unneeded, retain any
               symbols specifying source file names, which would otherwise get stripped.
    
           --only-keep-debug
               Strip a file, removing contents of any sections that would not be stripped by
               --strip-debug and leaving the debugging sections intact.  In ELF files, this preserves
               all note sections in the output.
    
               Note - the section headers of the stripped sections are preserved, including their
               sizes, but the contents of the section are discarded.  The section headers are
               preserved so that other tools can match up the debuginfo file with the real
               executable, even if that executable has been relocated to a different address space.
    
               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:
    
               1.<Link the executable as normal.  Assuming that it is called>
                   "foo" then...
    
               1.<Run "objcopy --only-keep-debug foo foo.dbg" to>
                   create a file containing the debugging info.
    
               1.<Run "objcopy --strip-debug foo" to create a>
                   stripped executable.
    
               1.<Run "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:
    
               1.<Link the executable as normal.>
               1.<Copy "foo" to  "foo.full">
               1.<Run "objcopy --strip-debug foo">
               1.<Run "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
               Remove the contents of all DWARF .dwo sections, leaving the remaining debugging
               sections and all symbols intact.  This option is intended for use by the compiler as
               part of the -gsplit-dwarf option, which splits debug information between the .o file
               and a separate .dwo file.  The compiler generates all debug information in the same
               file, then uses the --extract-dwo option to copy the .dwo sections to the .dwo file,
               then the --strip-dwo option to remove those sections from the original .o file.
    
           --extract-dwo
               Extract the contents of all DWARF .dwo sections.  See the --strip-dwo option for more
               information.
    
           --file-alignment num
               Specify the file alignment.  Sections in the file will always begin at file offsets
               which are multiples of this number.  This defaults to 512.  [This option is specific
               to PE targets.]
    
           --heap reserve
           --heap reserve,commit
               Specify the number of bytes of memory to reserve (and optionally commit) to be used as
               heap for this program.  [This option is specific to PE targets.]
    
           --image-base value
               Use value as the base address of your program or dll.  This is the lowest memory
               location that will be used when your program or dll is loaded.  To reduce the need to
               relocate and improve performance of your dlls, each should have a unique base address
               and not overlap any other dlls.  The default is 0x400000 for executables, and
               0x10000000 for dlls.  [This option is specific to PE targets.]
    
           --section-alignment num
               Sets the section alignment field in the PE header.  Sections in memory will always
               begin at addresses which are a multiple of this number.  Defaults to 0x1000.  [This
               option is specific to PE targets.]
    
           --stack reserve
           --stack reserve,commit
               Specify the number of bytes of memory to reserve (and optionally commit) to be used as
               stack for this program.  [This option is specific to PE targets.]
    
           --subsystem which
           --subsystem which:major
           --subsystem which:major.minor
               Specifies the subsystem under which your program will execute.  The legal values for
               which are "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
               Keep the file's section flags and symbols but remove all section data.  Specifically,
               the option:
    
               *<removes the contents of all sections;>
               *<sets the size of every section to zero; and>
               *<sets the file's start address to zero.>
    
               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
               Compress DWARF debug sections using zlib with SHF_COMPRESSED from the ELF ABI.  Note -
               if compression would actually make a section larger, then it is not compressed.
    
           --compress-debug-sections=none
           --compress-debug-sections=zlib
           --compress-debug-sections=zlib-gnu
           --compress-debug-sections=zlib-gabi
               For ELF files, these options control how DWARF debug sections are compressed.
               --compress-debug-sections=none is equivalent to --decompress-debug-sections.
               --compress-debug-sections=zlib and --compress-debug-sections=zlib-gabi are equivalent
               to --compress-debug-sections.  --compress-debug-sections=zlib-gnu compresses DWARF
               debug sections using zlib.  The debug sections are renamed to begin with .zdebug
               instead of .debug.  Note - if compression would actually make a section larger, then
               it is not compressed nor renamed.
    
           --decompress-debug-sections
               Decompress DWARF debug sections using zlib.  The original section names of the
               compressed sections are restored.
    
           --elf-stt-common=yes
           --elf-stt-common=no
               For ELF files, these options control whether common symbols should be converted to the
               "STT_COMMON" or "STT_OBJECT" type.  --elf-stt-common=yes converts common symbol type
               to "STT_COMMON". --elf-stt-common=no converts common symbol type to "STT_OBJECT".
    
           --merge-notes
           --no-merge-notes
               For ELF files, attempt (or do not attempt) to reduce the size of any SHT_NOTE type
               sections by removing duplicate notes.
    
           -V
           --version
               Show the version number of objcopy.
    
           --verilog-data-width=bytes
               For Verilog output, this options controls the number of bytes converted for each
               output data element.  The input target controls the endianness of the conversion.
    
           -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.
    
           --info
               Display a list showing all architectures and object formats available.
    
           @file
               Read command-line options from file.  The options read are inserted in place of the
               original @file option.  If file does not exist, or cannot be read, then the option
               will be treated literally, and not removed.
    
               Options in file are separated by whitespace.  A whitespace character may be included
               in an option by surrounding the entire option in either single or double quotes.  Any
               character (including a backslash) may be included by prefixing the character to be
               included with a backslash.  The file may itself contain additional @file options; any
               such options will be processed recursively.
    
    

    SEE ALSO

           ld(1), objdump(1), and the Info entries for binutils.
    
    
           Copyright (c) 1991-2020 Free Software Foundation, Inc.
    
           Permission is granted to copy, distribute and/or modify this document under the terms of
           the GNU Free Documentation License, Version 1.3 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".

    来源
    再牛逼的梦想也架不住傻逼似的坚持
  • 相关阅读:
    (转)下拉刷新组合控件的制作小结
    ActivityGroup的子activity响应back事件的顺序问题
    用CSS实现竖向圆角效果的折叠菜单代码
    蓝色风格的JS+CSS个性菜单代码
    用CSS实现WinVista风格的菜单代码
    div+css+js打造的一款菜单的收缩与展开代码
    五颜六色的弹性下拉导航菜单代码
    【荐】鼠标放上弹出下拉菜单的代码
    网页顶部隐藏css菜单代码
    【教程】简单滑动门代码
  • 原文地址:https://www.cnblogs.com/skullboyer/p/14413457.html
Copyright © 2020-2023  润新知