build: Don't link libraries we don't need.
[gps-watch.git] / src / bootloader / bootloader-final.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 = 0x00000000, LENGTH = 0x08000
12
13   RAM (rwx)
14     : ORIGIN = 0x1fffe000, LENGTH = 0x08000
15 }
16
17 /* Library configurations */
18 GROUP(libgcc.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                 /* The flash configuration field: */
56                 . = ALIGN(0x400);
57                 LONG(0x001a0933);
58                 LONG(0xffffffff);
59                 LONG(0xffffffff);
60                 LONG(0xfffffb7e);
61
62                 /* Don't put any other code in there so we may avoid
63                  * erasing and re-programming it.
64                  */
65                 . = ALIGN(0x800);
66
67                 *(.text*)
68
69                 KEEP(*(.init))
70                 KEEP(*(.fini))
71
72                 /* .ctors */
73                 *crtbegin.o(.ctors)
74                 *crtbegin?.o(.ctors)
75                 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
76                 *(SORT(.ctors.*))
77                 *(.ctors)
78
79                 /* .dtors */
80                 *crtbegin.o(.dtors)
81                 *crtbegin?.o(.dtors)
82                 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
83                 *(SORT(.dtors.*))
84                 *(.dtors)
85
86                 *(.rodata*)
87
88                 KEEP(*(.eh_frame*))
89         } > FLASH =0xff
90
91         .ARM.extab :
92         {
93                 *(.ARM.extab* .gnu.linkonce.armextab.*)
94         } > FLASH
95
96         __exidx_start = .;
97         .ARM.exidx :
98         {
99                 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
100         } > FLASH
101         __exidx_end = .;
102
103         __etext = .;
104
105         .data : AT (__etext)
106         {
107                 __data_start__ = .;
108                 *(vtable)
109                 *(.data*)
110
111                 . = ALIGN(4);
112                 /* preinit data */
113                 PROVIDE_HIDDEN (__preinit_array_start = .);
114                 KEEP(*(.preinit_array))
115                 PROVIDE_HIDDEN (__preinit_array_end = .);
116
117                 . = ALIGN(4);
118                 /* init data */
119                 PROVIDE_HIDDEN (__init_array_start = .);
120                 KEEP(*(SORT(.init_array.*)))
121                 KEEP(*(.init_array))
122                 PROVIDE_HIDDEN (__init_array_end = .);
123
124
125                 . = ALIGN(4);
126                 /* finit data */
127                 PROVIDE_HIDDEN (__fini_array_start = .);
128                 KEEP(*(SORT(.fini_array.*)))
129                 KEEP(*(.fini_array))
130                 PROVIDE_HIDDEN (__fini_array_end = .);
131
132                 KEEP(*(.jcr*))
133                 . = ALIGN(4);
134                 /* All data end */
135                 __data_end__ = .;
136
137         } > RAM
138
139         .bss :
140         {
141                 . = ALIGN(4);
142                 __bss_start__ = .;
143                 *(.bss*)
144                 *(COMMON)
145                 . = ALIGN(4);
146                 __bss_end__ = .;
147         } > RAM
148
149         .heap (COPY):
150         {
151                 __HeapBase = .;
152                 __end__ = .;
153                 end = __end__;
154                 KEEP(*(.heap*))
155                 __HeapLimit = .;
156         } > RAM
157
158         /* .stack_dummy section doesn't contains any symbols. It is only
159          * used for linker to calculate size of stack sections, and assign
160          * values to stack symbols later */
161         .stack_dummy (COPY):
162         {
163                 KEEP(*(.stack*))
164         } > RAM
165
166         /* Set stack top to end of RAM, and stack limit move down by
167          * size of stack_dummy section */
168         __StackTop = ORIGIN(RAM) + LENGTH(RAM);
169         __StackLimit = __StackTop - SIZEOF(.stack_dummy);
170         PROVIDE(__stack = __StackTop);
171
172         /* Check if data + heap + stack exceeds RAM limit */
173         ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
174 }