bootloader: Remove commented support for multiple .data/.bss sections.
[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   RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 0x08000   /*  32k */
12 }
13
14 /* Library configurations */
15 GROUP(libgcc.a libc.a libm.a libnosys.a)
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  *   __Vectors_End
43  *   __Vectors_Size
44  */
45 ENTRY(Reset_Handler)
46
47 SECTIONS
48 {
49         .text :
50         {
51                 KEEP(*(.vectors))
52                 __Vectors_End = .;
53                 __Vectors_Size = __Vectors_End - __Vectors;
54                 __end__ = .;
55
56                 *(.text*)
57
58                 KEEP(*(.init))
59                 KEEP(*(.fini))
60
61                 /* .ctors */
62                 *crtbegin.o(.ctors)
63                 *crtbegin?.o(.ctors)
64                 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
65                 *(SORT(.ctors.*))
66                 *(.ctors)
67
68                 /* .dtors */
69                 *crtbegin.o(.dtors)
70                 *crtbegin?.o(.dtors)
71                 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
72                 *(SORT(.dtors.*))
73                 *(.dtors)
74
75                 *(.rodata*)
76
77                 KEEP(*(.eh_frame*))
78         } > FLASH
79
80         .ARM.extab :
81         {
82                 *(.ARM.extab* .gnu.linkonce.armextab.*)
83         } > FLASH
84
85         __exidx_start = .;
86         .ARM.exidx :
87         {
88                 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
89         } > FLASH
90         __exidx_end = .;
91
92         __etext = .;
93
94         .data : AT (__etext)
95         {
96                 __data_start__ = .;
97                 *(vtable)
98                 *(.data*)
99
100                 . = ALIGN(4);
101                 /* preinit data */
102                 PROVIDE_HIDDEN (__preinit_array_start = .);
103                 KEEP(*(.preinit_array))
104                 PROVIDE_HIDDEN (__preinit_array_end = .);
105
106                 . = ALIGN(4);
107                 /* init data */
108                 PROVIDE_HIDDEN (__init_array_start = .);
109                 KEEP(*(SORT(.init_array.*)))
110                 KEEP(*(.init_array))
111                 PROVIDE_HIDDEN (__init_array_end = .);
112
113
114                 . = ALIGN(4);
115                 /* finit data */
116                 PROVIDE_HIDDEN (__fini_array_start = .);
117                 KEEP(*(SORT(.fini_array.*)))
118                 KEEP(*(.fini_array))
119                 PROVIDE_HIDDEN (__fini_array_end = .);
120
121                 KEEP(*(.jcr*))
122                 . = ALIGN(4);
123                 /* All data end */
124                 __data_end__ = .;
125
126         } > RAM
127
128         .bss :
129         {
130                 . = ALIGN(4);
131                 __bss_start__ = .;
132                 *(.bss*)
133                 *(COMMON)
134                 . = ALIGN(4);
135                 __bss_end__ = .;
136         } > RAM
137
138         .heap (COPY):
139         {
140                 __HeapBase = .;
141                 __end__ = .;
142                 end = __end__;
143                 KEEP(*(.heap*))
144                 __HeapLimit = .;
145         } > RAM
146
147         /* .stack_dummy section doesn't contains any symbols. It is only
148          * used for linker to calculate size of stack sections, and assign
149          * values to stack symbols later */
150         .stack_dummy (COPY):
151         {
152                 KEEP(*(.stack*))
153         } > RAM
154
155         /* Set stack top to end of RAM, and stack limit move down by
156          * size of stack_dummy section */
157         __StackTop = ORIGIN(RAM) + LENGTH(RAM);
158         __StackLimit = __StackTop - SIZEOF(.stack_dummy);
159         PROVIDE(__stack = __StackTop);
160
161         /* Check if data + heap + stack exceeds RAM limit */
162         ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
163 }