8083a7e40a6c1014c24700ce5d280b8b9ddbae21
[gps-watch.git] / src / bootloader / bootloader.ld
1 /* This is a copy of
2  *   CMSIS/Device/ARM/ARMCM0plus/Source/GCC/gcc_arm.ld
3  * taken from
4  *   git://github.com/ARM-software/CMSIS
5  */
6
7 /* Linker script to configure memory regions. */
8 MEMORY
9 {
10   FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000   /* 256k */
11
12   RAM (rwx)
13     : ORIGIN = 0x1fffe000, LENGTH = 0x08000
14 }
15
16 /* Library configurations */
17 GROUP(libgcc.a libc.a libm.a libnosys.a)
18
19 /* Linker script to place sections and symbol values. Should be used together
20  * with other linker script that defines memory regions FLASH and RAM.
21  * It references following symbols, which must be defined in code:
22  *   Reset_Handler : Entry of reset handler
23  *
24  * It defines following symbols, which code can use without definition:
25  *   __exidx_start
26  *   __exidx_end
27  *   __etext
28  *   __data_start__
29  *   __preinit_array_start
30  *   __preinit_array_end
31  *   __init_array_start
32  *   __init_array_end
33  *   __fini_array_start
34  *   __fini_array_end
35  *   __data_end__
36  *   __bss_start__
37  *   __bss_end__
38  *   __end__
39  *   end
40  *   __HeapLimit
41  *   __StackLimit
42  *   __StackTop
43  *   __stack
44  */
45 ENTRY(Reset_Handler)
46
47 SECTIONS
48 {
49         .text :
50         {
51                 KEEP(*(.vectors))
52                 __end__ = .;
53
54                 *(.text*)
55
56                 KEEP(*(.init))
57                 KEEP(*(.fini))
58
59                 /* .ctors */
60                 *crtbegin.o(.ctors)
61                 *crtbegin?.o(.ctors)
62                 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
63                 *(SORT(.ctors.*))
64                 *(.ctors)
65
66                 /* .dtors */
67                 *crtbegin.o(.dtors)
68                 *crtbegin?.o(.dtors)
69                 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
70                 *(SORT(.dtors.*))
71                 *(.dtors)
72
73                 *(.rodata*)
74
75                 KEEP(*(.eh_frame*))
76         } > FLASH
77
78         .ARM.extab :
79         {
80                 *(.ARM.extab* .gnu.linkonce.armextab.*)
81         } > FLASH
82
83         __exidx_start = .;
84         .ARM.exidx :
85         {
86                 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
87         } > FLASH
88         __exidx_end = .;
89
90         __etext = .;
91
92         .data : AT (__etext)
93         {
94                 __data_start__ = .;
95                 *(vtable)
96                 *(.data*)
97
98                 . = ALIGN(4);
99                 /* preinit data */
100                 PROVIDE_HIDDEN (__preinit_array_start = .);
101                 KEEP(*(.preinit_array))
102                 PROVIDE_HIDDEN (__preinit_array_end = .);
103
104                 . = ALIGN(4);
105                 /* init data */
106                 PROVIDE_HIDDEN (__init_array_start = .);
107                 KEEP(*(SORT(.init_array.*)))
108                 KEEP(*(.init_array))
109                 PROVIDE_HIDDEN (__init_array_end = .);
110
111
112                 . = ALIGN(4);
113                 /* finit data */
114                 PROVIDE_HIDDEN (__fini_array_start = .);
115                 KEEP(*(SORT(.fini_array.*)))
116                 KEEP(*(.fini_array))
117                 PROVIDE_HIDDEN (__fini_array_end = .);
118
119                 KEEP(*(.jcr*))
120                 . = ALIGN(4);
121                 /* All data end */
122                 __data_end__ = .;
123
124         } > RAM
125
126         .bss :
127         {
128                 . = ALIGN(4);
129                 __bss_start__ = .;
130                 *(.bss*)
131                 *(COMMON)
132                 . = ALIGN(4);
133                 __bss_end__ = .;
134         } > RAM
135
136         .heap (COPY):
137         {
138                 __HeapBase = .;
139                 __end__ = .;
140                 end = __end__;
141                 KEEP(*(.heap*))
142                 __HeapLimit = .;
143         } > RAM
144
145         /* .stack_dummy section doesn't contains any symbols. It is only
146          * used for linker to calculate size of stack sections, and assign
147          * values to stack symbols later */
148         .stack_dummy (COPY):
149         {
150                 KEEP(*(.stack*))
151         } > RAM
152
153         /* Set stack top to end of RAM, and stack limit move down by
154          * size of stack_dummy section */
155         __StackTop = ORIGIN(RAM) + LENGTH(RAM);
156         __StackLimit = __StackTop - SIZEOF(.stack_dummy);
157         PROVIDE(__stack = __StackTop);
158
159         /* Check if data + heap + stack exceeds RAM limit */
160         ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
161 }