Output Section Description
section [address] [(type)] :
[AT(lma)]
[ALIGN(section_align)]
[SUBALIGN(subsection_align)]
[constraint]
{
output-section-command
output-section-command
…
} [>region] [AT>lma_region] [:phdr :phdr …] [=fillexp]
每个“可加载的”或“可分配的”输出section通常包含两个地址:
VMA(virtual memory address虚拟内存地址或程序地址空间地址)和LMA(load memory address加载内存地址或进程地址空间地址).
LMA对齐手段:
强制LMA地址按照某一特定的字节对齐使用下面的方式
.text ALIGN(0x10) : { *(.text) }
VMA对齐方法
如果要强制VMA的地址按照某一特定的格式去对齐,则需要按照下面的格式去处理:
.text : {
. = ALIGN(8); /该操作是为了让.text段的VMA地址按照8字节对齐/
*(.text)
}
or
. = ALIGN(8); /该操作是为了让.text段的VMA地址按照8字节对齐/
.text : {
*(.text)
}