/* -------------------------------------------------------------------------
* File: conf/default.dld
*
* This is the linker command file which dld uses by default if no linker
* command file is specified.
*
* It specifies how the object files in a build will be linked and located.
* Combined with other linker command files provided with the compiler, it
* provides a base to build your own file for your particular system.
*
* For a description of the different statements in this file, please refer
* to the D-LD section of the User's Guide
* ------------------------------------------------------------------------ */
/* The MEMORY command defines a single memory area using a name intended
* to suggest its purpose:
*
* 32k RAM at address 0xA0000000
* Bootstrap is loaded from offet 0 and can be 3800 in length
* The remainer is used for uninitialized data and stacks.
* ------------------------------------------------------------------------ */
MEMORY /* memory map of Soc init sram */
{
boot (rw): org = 0xA0000000, len = 0x3800
ram (rw): org = 0xA0003800, len = 0x4800
}
/* The sizes of the stacks used by the application. NOTE: you need to adjust */
LOG_SIZE = 2048; //这段用来保存bootloader 的 log
C_STACK_SIZE = 4096; //堆栈大小
IRQ_STACK_SIZE = 32; //各种异常模式的堆栈大小
FIQ_STACK_SIZE = 32;
SVC_STACK_SIZE = 32;
ABT_STACK_SIZE = 32;
UND_STACK_SIZE = 32;
SECTIONS //段的具体结构
{
/* The first GROUP contains code and constant data.
*/
GROUP : { //第一个group用来放代码和常量数据
/* Take all code from all objects and libraries. */
.text (TEXT) : {
crt0.o /* make sure this is first */
*(.text)
*(.rdata)
*(.rodata)
*(.frame_info)
*(.j_class_table)
*(.init)
*(.fini)
. = ALIGN(4); //4字节对齐
}
.sdata2 (TEXT) : {} /* small CONST area for some targets */
} > boot
/* The second GROUP allocates space for the initialized data and
* uninitialized data in the "ram" section.
*/
GROUP BLOCK(4) : { //第二个group
__DATA_ROM = .;
__DATA_RAM = .;
.data (DATA) : {}
.j_pdata (DATA) : {}
/* constructor and destructor function ptrs */
.ctors ALIGN(4) : { ctordtor.o(.ctors) *(.ctors) }
.dtors ALIGN(4) : { ctordtor.o(.dtors) *(.dtors) }
/* .sdata is the "small data area" for some targets. */
.sdata ALIGN(4) (DATA) : { *(.sdata) *(.j_spdata) }
__DATA_END = .;
} > boot
GROUP : { //第三个group
__LOG_START = .; //LOG 区
. += LOG_SIZE;
__LOG_END = .;
/* Allocate uninitialized sections. */
__BSS_START = .; //BSS 区 紧接着 LOG 区
.sbss (BSS) : {}
.bss (BSS) : {}
.tibss (BSS) : {}
__BSS_END = .;
/* Special stacks which shouldn't normally be used */
. += IRQ_STACK_SIZE; //然后是各种 异常堆栈区
. = ALIGN (4);
__IRQ_STACK_INIT = . ;
. += FIQ_STACK_SIZE;
. = ALIGN (4);
__FIQ_STACK_INIT = . ;
. += SVC_STACK_SIZE;
. = ALIGN (4);
__SVC_STACK_INIT = . ;
. += ABT_STACK_SIZE;
. = ALIGN (4);
__ABT_STACK_INIT = . ;
. += UND_STACK_SIZE;
. = ALIGN (4);
__UND_STACK_INIT = . ;
/* Any remaining space will be used as a heap. */
__HEAP_START = .; //最后是堆
} > ram
}
__SP_END = ADDR(ram)+SIZEOF(ram); //堆栈结束地址
__SP_START = __SP_END-C_STACK_SIZE; //堆栈起始地址 /* Stack size (defined above). */
__HEAP_END = __SP_START; //堆结束地址,刚好是堆栈的起始地址 /* Heap contiguous with stack. */
一段链接文件code
最新推荐文章于 2022-02-11 17:20:11 发布