1 /* ****************************************************************************************************** */
2 /* demo_at91sam7_blink_flash.cmd LINKER SCRIPT */
5 /* The Linker Script defines how the code and data emitted by the GNU C compiler and assembler are */
6 /* to be loaded into memory (code goes into FLASH, variables go into RAM). */
8 /* Any symbols defined in the Linker Script are automatically global and available to the rest of the */
11 /* To force the linker to use this LINKER SCRIPT, just add the -T demo_at91sam7_blink_flash.cmd */
12 /* directive to the linker flags in the makefile. For example, */
14 /* LFLAGS = -Map main.map -nostartfiles -T demo_at91sam7_blink_flash.cmd */
17 /* The order that the object files are listed in the makefile determines what .text section is */
20 /* For example: $(LD) $(LFLAGS) -o main.out crt.o main.o lowlevelinit.o */
22 /* crt.o is first in the list of objects, so it will be placed at address 0x00000000 */
25 /* The top of the stack (_stack_end) is (last_byte_of_ram +1) - 4 */
27 /* Therefore: _stack_end = (0x00020FFFF + 1) - 4 = 0x00021000 - 4 = 0x0020FFFC */
29 /* Note that this symbol (_stack_end) is automatically GLOBAL and will be used by the crt.s */
30 /* startup assembler routine to specify all stacks for the various ARM modes */
34 /* .-------->|---------------------------------|0x00210000 */
35 /* . | |0x0020FFFC <---------- _stack_end */
36 /* . | UDF Stack 16 bytes | */
38 /* . |---------------------------------|0x0020FFEC */
40 /* . | ABT Stack 16 bytes | */
42 /* . |---------------------------------|0x0020FFDC */
45 /* . | FIQ Stack 128 bytes | */
48 /* RAM |---------------------------------|0x0020FF5C */
51 /* . | IRQ Stack 128 bytes | */
54 /* . |---------------------------------|0x0020FEDC */
56 /* . | SVC Stack 16 bytes | */
58 /* . |---------------------------------|0x0020FECC */
60 /* . | stack area for user program | */
66 /* . |.................................|0x002006D8 <---------- _bss_end */
68 /* . | .bss uninitialized variables | */
69 /* . |.................................|0x002006D0 <---------- _bss_start, _edata */
71 /* . | .data initialized variables | */
73 /* .-------->|_________________________________|0x00200000 */
76 /* .-------->|---------------------------------|0x00100000 */
79 /* . | free flash | */
82 /* . |.................................|0x000006D0 <---------- _bss_start, _edata */
84 /* . | .data initialized variables | */
86 /* . |---------------------------------|0x000006C4 <----------- _etext */
91 /* . |---------------------------------|0x00000118 main() */
93 /* . | Startup Code (crt.s) | */
94 /* . | (assembler) | */
96 /* . |---------------------------------|0x00000020 */
98 /* . | Interrupt Vector Table | */
100 /* .-------->|---------------------------------|0x00000000 _vec_reset *
103 /* Author: James P. Lynch */
105 /* ****************************************************************************************************** */
108 /* identify the Entry Point (_vec_reset is defined in file crt.s) */
111 /* specify the LPC2106 memory areas */
113 /* if you find this file hard to understand, this may help: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_chapter/ld_3.html#SEC5 */
117 flash : ORIGIN = 0, LENGTH = 256K /* FLASH EPROM */
118 ram : ORIGIN = 0x00200000, LENGTH = 64K /* static RAM area */
122 /* define a global symbol _stack_end (see analysis in annotation above) */
123 _stack_end = 0x20FFFC;
125 /* now define the output sections */
128 . = 0; /* set location counter to address zero */
132 *(.zeropage) /* the .zeropage section put at the beginning */
135 .text : /* collect all sections that should go into FLASH after startup */
137 *(.text) /* all .text sections (code) */
138 *(.rodata) /* all .rodata sections (constants, strings, etc.) */
139 *(.rodata*) /* all .rodata* sections (constants, strings, etc.) */
140 *(.glue_7) /* all .glue_7 sections (no idea what these are) */
141 *(.glue_7t) /* all .glue_7t sections (no idea what these are) */
142 _etext = .; /* define a global symbol _etext just after the last code byte */
143 } >flash /* put all the above into FLASH */
145 .data : /* collect all initialized .data sections that go into RAM */
147 _data = .; /* create a global symbol marking the start of the .data section */
148 *(.data) /* all .data sections */
149 _edata = .; /* define a global symbol marking the end of the .data section */
150 } >ram AT >flash /* put all the above into RAM (but load the LMA initializer copy into FLASH) */
152 .bss : /* collect all uninitialized .bss sections that go into RAM */
154 _bss_start = .; /* define a global symbol marking the start of the .bss section */
155 *(.bss) /* all .bss sections */
156 } >ram /* put all the above in RAM (it will be cleared in the startup code */
158 . = ALIGN(4); /* advance location counter to the next 32-bit boundary */
159 _bss_end = . ; /* define a global symbol marking the end of the .bss section */
161 _end = .; /* define a global symbol marking the end of application RAM */