Jay*_*lya 14 linker linker-scripts
ALIGN关键字在链接描述文件中的作用是什么?我阅读了很多关于链接器脚本的教程,但是我无法理解ALIGN真正做了什么.任何人都可以简单解释一下.谢谢!
Emp*_*ian 21
典型的用法是
. = ALIGN(8);
Run Code Online (Sandbox Code Playgroud)
这意味着:插入填充字节,直到当前位置在8字节边界上对齐.那是:
while ((current_location & 7) != 0)
*current_location++ = padding_value;
Run Code Online (Sandbox Code Playgroud)
小智 5
ALIGN() 指令告诉链接器 section(bss, text) 应该如此对齐。
一个典型的思路可以看这里(4.6.3“输出段说明”)
例如
//.data is aligned by word size on the 32-bit architecture and direct it to the data section
For a 32-bit machine, it typically needs to be word aligned
.data : ALIGN(4)
{
*(.data*)
} > data_sdram
Run Code Online (Sandbox Code Playgroud)