[LinkerScript.8] 简单的链接器脚本命令: 杂项命令 - Simple Linker Script Commands : Miscellaneous Commands


There are a few other linker scripts commands.

一些的其它链接器脚本命令



ASSERT(exp, message)

------------------------------------------------------------
Ensure that exp is non-zero. If it is zero, then exit the linker with an error code, and print message. 

确保exp是非0。如果是0,那么退出链接器并输出错误码,同时打印信息.



EXTERN(symbol symbol ...)

----------------------------------------------------------
Force symbol to be entered in the output file as an undefined symbol. Doing this may, for example, trigger linking of additional modules from standard libraries. You may list several symbols for each EXTERN, and you may use EXTERN multiple times. This command has the same effect as the ‘-u’ command-line option. 

强制把符号以未定义符号的形式写入输出文件。这样做可能是,例如可以触发链接到标准库的外部模块。你可能会把一些符号列为EXTERN,并且你可以多次使用EXTERN。这个命令和使用命令行选项' -u ' 是一样的效果。



FORCE_COMMON_ALLOCATION

-----------------------------------------------------
This command has the same effect as the ‘-d’ command-line option: to make ld assign space to common symbols even if a relocatable output file is specified (‘-r’). 

这个命令和命令行选项‘ -d ’是一样的效果:无论是否指定relocatable输出文件(' -r '),都要让ld分配空间给公共的符号.



INHIBIT_COMMON_ALLOCATION

---------------------------------------------------------------------------
This command has the same effect as the ‘--no-define-common’ command-line option: to make ld omit the assignment of addresses to common symbols even for a non-relocatable output file. 

这个命令和命令行选项‘ --no-defind-common ’是一样的效果:不管是不是在一个non-relocatable的输出文件,ld都不给command symbols分配地址。



INSERT [ AFTER | BEFORE ] output_section

----------------------------------------------------------------------------------------------------
This command is typically used in a script specified by ‘-T’ to augment the default SECTIONS with, for example, overlays. It inserts all prior linker script statements after (or before) output_section, and also causes ‘-T’ to not override the default linker script. The exact insertion point is as for orphan sections. See Location Counter. The insertion happens after the linker has mapped input sections to output sections. Prior to the insertion, since ‘-T’ scripts are parsed before the default linker script, statements in the ‘-T’ script occur before the default linker script statements in the internal linker representation of the script. In particular, input section assignments will be made to ‘-T’ output sections before those in the default script. Here is an example of how a ‘-T’ script using INSERT might look:
          SECTIONS
          {
            OVERLAY :
            {
              .ov1 { ov1*(.text) }
              .ov2 { ov2*(.text) }
            }
          }
          INSERT AFTER .text;


这个命令一般用在由‘-T'指定的一个脚本中,来扩展默认的SECTIONS,比如,overlays. 它在output_section之后(或之前)插入所有优先的链接器脚本声明,也可使'-T'免去覆盖默认链接器脚本。准确的插入点如同一个单独的sections. 请看位置计数。在链接器映射输入section到输出section之后才发生了插入。优先于插入,由于'-T'脚本在默认脚本之前被解析,因此‘-T'脚本中的声明发生在默认链接器脚本的声明之前。特别是,在默认脚本的这些之前,输入section的分配将被做成'-T'输出section.有一个如何使用'-T'脚本的例子,实现INSERT功能,请看:
          SECTIONS
          {
            OVERLAY :
            {
              .ov1 { ov1*(.text) }
              .ov2 { ov2*(.text) }
            }
          }
          INSERT AFTER .text;




NOCROSSREFS(section section ...)

-------------------------------------------------------
This command may be used to tell ld to issue an error about any references among certain output sections.
In certain types of programs, particularly on embedded systems when using overlays, when one section is loaded into memory, another section will not be. Any direct references between the two sections would be errors. For example, it would be an error if code in one section called a function defined in the other section.

这个命令用于告诉 ld 发布任何引用某些输出sections的错误.

在某些类型的程序中,特别是使用overlays的嵌入式系统,当一个section被加载到存储器时,而另一个section没有加载到存储器。在这两个section之间的任何引用都将是个错误。

比如一个section中的code调用在另一个section中定义的函数。


The NOCROSSREFS command takes a list of output section names. If ld detects any cross references between the sections, it reports an error and returns a non-zero exit status. Note that the NOCROSSREFS command uses output section names, not input section names. 
NOCROSSREFS命令有一个输出section名称的列表,如果ld检测到在sections之间的任何交叉引用,它将报告一个错误并返回一个非0的退出状态。注意,NOCROSSREFS命令使用输出section名称,不是输入section名称。






OUTPUT_ARCH(bfdarch)

---------------------------------------
Specify a particular output machine architecture. The argument is one of the names used by the BFD library (see BFD). You can see the architecture of an object file by using the objdump program with the ‘-f’ option. 

指定一个具体的输出机器架构。参数是用BFD库名称。你可以使用 objdump -f 查看一个对象文件的架构。



LD_FEATURE(string)

-----------------------------------------------------

This command may be used to modify ld behavior. If string is "SANE_EXPR" then absolute symbols and numbers in a script are simply treated as numbers everywhere. See Expression Section.

这个命令可用于修改ld的行为. 如果string是"SANE_EXPR",那么绝对的符号和脚本中的数字都被简单地当作数字处理。请参考Expression这一节







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值