如何解决在gnu链接器脚本中使用ALIGN命令
为什么在链接描述文件的每个输出节的开头和结尾使用ALIGN(4)语句? 是否在每个部分之间创建某种间距?
SECTIONS
{
/* The startup code goes first into internal flash */
.interrupts :
{
__VECTOR_TABLE = .;
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} > m_interrupts
.flash_config :
{
. = ALIGN(4);
KEEP(*(.FlashConfig)) /* Flash Configuration Field (FCF) */
. = ALIGN(4);
} > m_flash_config
/* The program code and other data goes into internal flash */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants,strings,etc.) */
*(.rodata*) /* .rodata* sections (constants,etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} > m_text
解决方法
免责声明:我不是编译器或链接程序开发人员,这只是我的印象和经验。
完成对齐后,对32位处理器的内存访问要快得多,其中某些处理器甚至无法访问未对齐的宽字。 ARM不是那种AFAIK。
但是,编译器会在布局其代码和数据时假定各节正确对齐,最后将它们链接起来。因此,链接描述文件必须满足该假定。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。