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