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