[LinkerScript.16] SECTION命令: Output Section Address


The address is an expression for the VMA (the virtual memory address) of the output section. This address is optional, but if it is provided then the output address will be set exactly as specified.

address是表示输出section的VMA(虚拟内存地址)的一个表达式. 这个address是可选的,但如果有指定address,则必须按规范实现精确地设置输出地址.


If the output address is not specified then one will be chosen for the section, based on the heuristic below. This address will be adjusted to fit the alignment requirement of the output section. The alignment requirement is the strictest alignment of any input section contained within the output section.

如果输出地址没有指定, 那么将基于如下搜索选择其中一个进行设置地址. 这个地址将通过填充, 满足输出section的对齐要求.  在输出section中的任何输入section, 都需要严格地满足对齐的需求.


The output section address heuristic is as follows:

输出section地址的搜索如下:

  • If an output memory region is set for the section then it is added to this region and its address will be the next free address in that region.
  • 如果这个section有设置了一个输出存储区域, 那么它将加到这个区域并且它的地址是那个区域的下个空闲地址.

  • If the MEMORY command has been used to create a list of memory regions then the first region which has attributes compatible with the section is selected to contain it. The section's output address will be the next free address in that region; MEMORY.
  • 如果MEMORY命令被用于创建一组存储区域,那么选择属性与section相兼容的第一个区域包含它. 该section的输出地址将是在那个区域里的下个空闲地址. 

注: MEMORY命令会象如下一样定义输出存储区域:

      MEMORY 

      {

         rom(rx) : ORIGIN = 0, LENGTH = 256K

         ram(!rx) : org = 0x40000000, l = 4M

      }


      .text :
 {
*(.text*)

       } > rom

      .hello :

      {

           *(.text*)

      } > rom

这时,选择MEMORY定义的rom区域, 放入hello输出section. 而hello输出section地址,将会被分配到rom中text输出section之后.

  • If no memory regions were specified, or none match the section then the output address will be based on the current value of the location counter.
  如果没有指定存储区域,或者也没匹配的section,那么输出地址基于位置计数的当前值.


For example:

比如

     .text . : { *(.text) }

and

     .text : { *(.text) }

are subtly different. The first will set the address of the ‘.text’ output section to the current value of the location counter. The second will set it to the current value of the location counter aligned to the strictest alignment of any of the ‘.text’ input sections.

是很不一样的.第一个将设置'.text'输出section的地址为位置计数的当前值. 第二个将设置位置计数的当前值,它的地址与所有'.text'输入section严格对齐的.


The address may be an arbitrary expression; Expressions. For example, if you want to align the section on a 0x10 byte boundary, so that the lowest four bits of the section address are zero, you could do something like this:

地址可能是任意表达式;参看Expressions.比如,如果你想要section与0x10字节对齐,结果是section地址的最低4位为0, 你可以象这样做:

     .text ALIGN(0x10) : { *(.text) }

This works because ALIGN returns the current location counter aligned upward to the specified value.

Specifying address for a section will change the value of the location counter, provided that the section is non-empty. (Empty sections are ignored).

这是因为ALIGN返回与指定值实现向上对齐的当前位置计数.

假设一个section是非空的, 指定一个section地址将会改变位置计数的值. (空section会被忽略).



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值