Merge branch 'master' of https://github.com/robinkrens/cortex-from-scratch
[cortex-from-scratch] / link.ld
1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
2  * 
3  * $LOG$
4  * 2019/7/20 - ROBIN KRENS      
5  * Initial version 
6  * 
7  * $DESCRIPTION$
8  * Linker file for Cortex-M3 STM32 based boards
9  * Boards have similar FLASH and SRAM ORIGINs
10  * LENGTHs differs of course.
11  * 
12  * _start flag is the first procedure to be 
13  * executed (linked to beginning of FLASH at 
14  * 0x08000000). The procedure should do some
15  * basic things, such as set up the stack and
16  * reset and hard fault handler (see start.asm)
17  * *
18  * _endofbss flag is used to calculate the end 
19  * of .bss and the start of (a possible) kernel
20  * heap
21  *
22  * */
23
24 HEAP_SIZE = 0x100;
25
26 MEMORY
27 {
28         FLASH (xr) : ORIGIN = 0x08000000, LENGTH = 512K
29         SRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
30
31
32 ENTRY(_start) 
33
34 SECTIONS
35 {
36         . = 0x0;
37         .text : ALIGN(4)
38         {
39                 /* (.vector_table */
40                 *(.text)
41                 *(.rodata)
42         }
43         . = 0x20000000; 
44         .data :  
45         {
46                 *(.data)
47         } 
48         .bss : ALIGN(4) 
49         {
50                 *(.bss)
51         }
52         _endofbss = .;  
53         _beginofheap = .;
54         . = . + HEAP_SIZE;
55         . = ALIGN(8);
56         _endofheap = .;
57 }