核心代码与注释如下:
MEMORY
{
...
ARM_SECT0 (rx) : ORIGIN = 0x60aa8000, LENGTH = 0x58000
ARM_SECT1 (rx) : ORIGIN = 0x20800000, LENGTH = 0x180000 /* 1.5M */
...
}
ENTRY(Reset_Handler)
SECTIONS
{
...
.text :
{
. = ALIGN(4);
_stext = .;
/* 将main.c和clock.c文件编译出来的text指定到ARM_SECT0 */
*main.o(.text*)
*clock.o(.text*)
/* 将libgcc.a的text指定到ARM_SECT0 */
*\libgcc.a:*
_etext = .;
} > ARM_SECT0
.text_xip :
{
. = ALIGN(4);
_stext = .;
/* 将main.c和clock.c文件编译出来的text从ARM_SECT1移除 */
*(EXCLUDE_FILE(*main.o
*clock.o)
.text*)
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
. = ALIGN(4);
} > ARM_SECT1
...
}
编译结果

本文介绍了一个具体的ARM系统内存布局配置示例,详细展示了如何通过链接脚本定义不同内存区域,并指定了特定文件如main.c、clock.c及libgcc.a中代码段的位置。此配置对于理解嵌入式系统启动过程中的内存分配至关重要。
最低0.47元/天 解锁文章
1382

被折叠的 条评论
为什么被折叠?



