[LinkerScript.9] 符号赋值: 简单分配 - Assigning Values to Symbols: Simple Assignments


You may assign a value to a symbol in a linker script. This will define the symbol and place it into the symbol table with a global scope.

你可以在链接脚本中给符号赋值. 这将定义这个符号并把它放入到一个全局性的符号表.


Simple Assignments

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

You may assign to a symbol using any of the C assignment operators:

symbol = expression ; symbol += expression ; symbol -= expression ; symbol *= expression ; symbol /= expression ; symbol <<= expression ; symbol >>= expression ; symbol &= expression ; symbol |= expression ;
你可以使用C赋值操作的任何一种完成符号赋值.

symbol = expression ; symbol += expression ; symbol -= expression ; symbol *= expression ; symbol /= expression ; symbol <<= expression ; symbol >>= expression ; symbol &= expression ; symbol |= expression ;


The first case will define symbol to the value of expression. In the other cases, symbol must already be defined, and the value will be adjusted accordingly.
第一方式是定义符号为一个表达式的值. 在其它方式中,符号必须已经定义过了,并且它的值将被相应地调整.


The special symbol name ‘.’ indicates the location counter. You may only use this within a SECTIONS command. See Location Counter.
特殊的符号'.'表示位置计数.你可能仅仅在一个SECTIONS命令里使用它.



The semicolon after expression is required.
在表达式之后的必须要有分号


Expressions are defined below; see Expressions.
表达式被定义在后面;请看'表达式'这一节.

You may write symbol assignments as commands in their own right, or as statements within a SECTIONS command, or as part of an output section description in a SECTIONS command.
你可能把符号赋值作为有效的命令,或SECTION命令中的一个声明,又或者是SECTION命令中一个输出section描述.


The section of the symbol will be set from the section of the expression; for more information, see Expression Section.
在表达式的section中设置符号的section;详细的信息,可以参考'表达式'这一节.

Here is an example showing the three different places that symbol assignments may be used:
举一个使用在三个不同地方给符号赋值的例子:

     floating_point = 0;
     SECTIONS
     {
       .text :
         {
           *(.text)
           _etext = .;
         }
       _bdata = (. + 3) & ~ 3;
       .data : { *(.data) }
     }

In this example, the symbol ‘floating_point’ will be defined as zero. The symbol ‘_etext’ will be defined as the address following the last ‘.text’ input section. The symbol ‘_bdata’ will be defined as the address following the ‘.text’ output section aligned upward to a 4 byte boundary.

在这个例子中,符号'floating_point'将被定义为0. 符号'_etext'将被设置为前一个'.text'输入section之后的地址.

符号'_bdata'将被设置为'.text'输出section之后对齐4字节的地址.










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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值