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