[LinkerScript.13] SECTION命令

本文详细解释了链接器脚本中SECTIONS命令的用途,包括其格式、命令类型以及如何在链接器脚本中使用ENTRY命令和符号赋值来优化内存布局。


The SECTIONS command tells the linker how to map input sections into output sections, and how to place the output sections in memory.

SECTION命令用于告诉链接器如何去映射输入section到输出section,以及如何把输出section放置到内存中.


The format of the SECTIONS command is:

SECTION命令的格式如下:

     SECTIONS
     {
       sections-command
       sections-command
       ...
     }

Each sections-command may of be one of the following:

每个section-command可能是如下其中一种:

  • an ENTRY command (see Entry command)
  • a symbol assignment (see Assignments)
  • an output section description
  • an overlay description

The ENTRY command and symbol assignments are permitted inside the SECTIONS command for convenience in using the location counter in those commands. This can also make the linker script easier to understand because you can use those commands at meaningful points in the layout of the output file.

为了方便使用在这些命令里的位置计数, ENITRY命令和符号赋值只允许在SECTION命令之内.这样也可以更加容易地理解链接器脚本,因为你是在输出文件的有意义的位置上使用这些命令.


Output section descriptions and overlay descriptions are described below.

输出section描述和叠加描述在下面介绍.


If you do not use a SECTIONS command in your linker script, the linker will place each input section into an identically named output section in the order that the sections are first encountered in the input files. If all input sections are present in the first file, for example, the order of sections in the output file will match the order in the first input file. The first section will be at address zero.

如果在你的链接器脚本中没有使用SECTION命令,那么链接器将按照顺序,把输入文件中先出现的每个输入section放入一个有同样名称的输出section中.  例如, 如果所有输入section都是在第一个文件中的, 那么在输出文件中的section的顺序就是第一个输入文件中的顺序. 第一个section的地址被设置为0.


























评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值