关于 ld 连接对齐函数 ALIGN() 和 NEXT()
时间:2006-07-18
来源:互联网
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
cpu/pxa/start.o (.text)
*(.text)
}
. = ALIGN(4);
.rodata : { *(.rodata) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
.got : { *(.got) }
. = ALIGN(4);
.bss : { *(.bss) }
}
上面是典型的 linker script 的片段,对于 ALIGN( ) 函数在这里的意义,
请哪位概念清晰的大侠详细说明一下!
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
cpu/pxa/start.o (.text)
*(.text)
}
. = ALIGN(4);
.rodata : { *(.rodata) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
.got : { *(.got) }
. = ALIGN(4);
.bss : { *(.bss) }
}
上面是典型的 linker script 的片段,对于 ALIGN( ) 函数在这里的意义,
请哪位概念清晰的大侠详细说明一下!
作者: robinswan 发布时间: 2006-07-18
估计应该是指定每个section按多少字节对齐
作者: kj501 发布时间: 2006-07-19
from `info ld`:
`ALIGN(EXP)'
Return the location counter (`.') aligned to the next EXP boundary.
`ALIGN' doesn't change the value of the location counter--it just
does arithmetic on it. Here is an example which aligns the output
`.data' section to the next `0x2000' byte boundary after the
preceding section and sets a variable within the section to the
next `0x8000' boundary after the input sections:
SECTIONS { ...
.data ALIGN(0x2000): {
*(.data)
variable = ALIGN(0x8000);
}
... }
The first use of `ALIGN' in this example specifies the location of
a section because it is used as the optional ADDRESS attribute of
a section definition (*note Output Section Address::). The second
use of `ALIGN' is used to defines the value of a symbol.
The builtin function `NEXT' is closely related to `ALIGN'.
`ALIGN(EXP)'
Return the location counter (`.') aligned to the next EXP boundary.
`ALIGN' doesn't change the value of the location counter--it just
does arithmetic on it. Here is an example which aligns the output
`.data' section to the next `0x2000' byte boundary after the
preceding section and sets a variable within the section to the
next `0x8000' boundary after the input sections:
SECTIONS { ...
.data ALIGN(0x2000): {
*(.data)
variable = ALIGN(0x8000);
}
... }
The first use of `ALIGN' in this example specifies the location of
a section because it is used as the optional ADDRESS attribute of
a section definition (*note Output Section Address::). The second
use of `ALIGN' is used to defines the value of a symbol.
The builtin function `NEXT' is closely related to `ALIGN'.
作者: crquan 发布时间: 2006-07-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28