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