blob: 26a43e8f9c8d229f363b6c2f7f7ca0fdd268e467 [file] [log] [blame]
Brian Silverman5020be62013-12-06 19:09:07 -08001GROUP(libgcc.a libc.a libm.a)
Brian Silverman2bf644d2013-12-06 16:54:59 -08002
3/* Linker script to place sections and symbol values. Should be used together
4 * with other linker script that defines memory regions FLASH and RAM.
5 * It references following symbols, which must be defined in code:
6 * Reset_Handler : Entry of reset handler
7 *
8 * It defines following symbols, which code can use without definition:
9 * __exidx_start
10 * __exidx_end
11 * __etext
12 * __data_start__
13 * __preinit_array_start
14 * __preinit_array_end
15 * __init_array_start
16 * __init_array_end
17 * __fini_array_start
18 * __fini_array_end
19 * __data_end__
20 * __bss_start__
21 * __bss_end__
22 * __end__
23 * end
24 * __HeapLimit
25 * __StackLimit
26 * __StackTop
27 * __stack
28 */
29ENTRY(Reset_Handler)
30
31SECTIONS
32{
33 .text :
34 {
Brian Silverman2bf644d2013-12-06 16:54:59 -080035 *(.text*)
36
37 KEEP(*(.init))
38 KEEP(*(.fini))
39
40 /* .ctors */
41 *crtbegin.o(.ctors)
42 *crtbegin?.o(.ctors)
43 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
44 *(SORT(.ctors.*))
45 *(.ctors)
46
47 /* .dtors */
48 *crtbegin.o(.dtors)
49 *crtbegin?.o(.dtors)
50 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
51 *(SORT(.dtors.*))
52 *(.dtors)
53
54 *(.rodata*)
55
56 KEEP(*(.eh_frame*))
57 } > FLASH
58
Brian Silverman2bf644d2013-12-06 16:54:59 -080059 .ARM.extab :
60 {
61 *(.ARM.extab* .gnu.linkonce.armextab.*)
62 } > FLASH
63
64 __exidx_start = .;
65 .ARM.exidx :
66 {
67 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
68 } > FLASH
69 __exidx_end = .;
70
71 __etext = .;
72
73 .data : AT (__etext)
74 {
75 __data_start__ = .;
Brian Silverman44311d62013-12-06 22:03:29 -080076
77 /* bootloader.ld sticks this at the beginning of FLASH before here */
78 KEEP(*(.vectors))
79
Brian Silverman2bf644d2013-12-06 16:54:59 -080080 *(vtable)
81 *(.data*)
82
83 . = ALIGN(4);
84 /* preinit data */
85 PROVIDE_HIDDEN (__preinit_array_start = .);
86 KEEP(*(.preinit_array))
87 PROVIDE_HIDDEN (__preinit_array_end = .);
88
89 . = ALIGN(4);
90 /* init data */
91 PROVIDE_HIDDEN (__init_array_start = .);
92 KEEP(*(SORT(.init_array.*)))
93 KEEP(*(.init_array))
94 PROVIDE_HIDDEN (__init_array_end = .);
95
96
97 . = ALIGN(4);
98 /* finit data */
99 PROVIDE_HIDDEN (__fini_array_start = .);
100 KEEP(*(SORT(.fini_array.*)))
101 KEEP(*(.fini_array))
102 PROVIDE_HIDDEN (__fini_array_end = .);
103
104 KEEP(*(.jcr*))
105 . = ALIGN(4);
106 /* All data end */
107 __data_end__ = .;
108
109 } > RAM
110
111 .bss :
112 {
113 . = ALIGN(4);
114 __bss_start__ = .;
115 *(.bss*)
116 *(COMMON)
117 . = ALIGN(4);
118 __bss_end__ = .;
119 } > RAM
120
121 .heap (COPY):
122 {
123 __end__ = .;
124 end = __end__;
125 *(.heap*)
126 __HeapLimit = .;
127 } > RAM
128
129 /* .stack_dummy section doesn't contains any symbols. It is only
130 * used for linker to calculate size of stack sections, and assign
131 * values to stack symbols later */
132 .stack_dummy (COPY):
133 {
134 *(.stack*)
135 } > RAM
136
137 /* Set stack top to end of RAM, and stack limit move down by
138 * size of stack_dummy section */
139 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
140 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
141 PROVIDE(__stack = __StackTop);
142
143 /* Check if data + heap + stack exceeds RAM limit */
144 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
Brian Silverman87e430c2014-03-26 17:06:34 -0700145
146 .flash_end :
147 {
148 __flash_end = .;
149 } > FLASH
Brian Silverman2bf644d2013-12-06 16:54:59 -0800150}