核心代码与注释如下:
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
...
}
编译结果如下:
.text 0x0000000060aa8000 0x63ca
0x0000000060aa8000 . = ALIGN (0x4)
0x0000000060aae3cc _stext = .
*main.o(.text*)
.text.normal_sys_init
0x0000000060aa8000 0xe /home/build/main.o
0x0000000060aa8000 normal_sys_init
*fill* 0x0000000060aa800e 0x2
.text.print_system_status
0x0000000060aa8010 0x90 /home/build/main.o
0x0000000060aa8010 print_system_status
.text.main 0x0000000060aa80a0 0x1cc /home/build/main.o
0x0000000060aa80a0 main
*clock.o(.text*)
.text.lcd_i80clk_set
0x0000000060aa826c 0x14 /home/build/clock.o
.text.osc_clk_set
0x0000000060aa8280 0x14 /home/build/clock.o
.text.get_current_clk_soucre
0x0000000060aa8294 0x20 /home/build/clock.o
......
*\libgcc.a:*()
.text 0x0000000060aad14c 0x378 /opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v8-m.main+fp/hard/libgcc.a(_arm_addsubdf3.o)
0x0000000060aad14c __aeabi_drsub
0x0000000060aad154 __aeabi_dsub
0x0000000060aad154 __subdf3
0x0000000060aad158 __adddf3
0x0000000060aad158 __aeabi_dadd
0x0000000060aad3d0 __aeabi_ui2d
0x0000000060aad3d0 __floatunsidf
0x0000000060aad3f0 __floatsidf
0x0000000060aad3f0 __aeabi_i2d
0x0000000060aad414 __extendsfdf2
0x0000000060aad414 __aeabi_f2d
0x0000000060aad458 __aeabi_ul2d
0x0000000060aad458 __floatundidf
0x0000000060aad468 __floatdidf
0x0000000060aad468 __aeabi_l2d
.debug_frame 0x0000000060aad4c4 0xac /opt/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v8-m.main+fp/hard/libgcc.a(_arm_addsubdf3.o)
......