1 | /* Linker script to configure memory regions.
|
---|
2 | * Need modifying for a specific board.
|
---|
3 | * FLASH.ORIGIN: starting address of flash
|
---|
4 | * FLASH.LENGTH: length of flash
|
---|
5 | * RAM.ORIGIN: starting address of RAM bank 0
|
---|
6 | * RAM.LENGTH: length of RAM bank 0
|
---|
7 | */
|
---|
8 | MEMORY
|
---|
9 | {
|
---|
10 | FLASH (rx) : ORIGIN = 0x00000000+0x4000, LENGTH = 0x00040000-0x4000
|
---|
11 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
|
---|
12 | }
|
---|
13 |
|
---|
14 | /* Linker script to place sections and symbol values. Should be used together
|
---|
15 | * with other linker script that defines memory regions FLASH and RAM.
|
---|
16 | * It references following symbols, which must be defined in code:
|
---|
17 | * Reset_Handler : Entry of reset handler
|
---|
18 | *
|
---|
19 | * It defines following symbols, which code can use without definition:
|
---|
20 | * __exidx_start
|
---|
21 | * __exidx_end
|
---|
22 | * __copy_table_start__
|
---|
23 | * __copy_table_end__
|
---|
24 | * __zero_table_start__
|
---|
25 | * __zero_table_end__
|
---|
26 | * __etext
|
---|
27 | * __data_start__
|
---|
28 | * __preinit_array_start
|
---|
29 | * __preinit_array_end
|
---|
30 | * __init_array_start
|
---|
31 | * __init_array_end
|
---|
32 | * __fini_array_start
|
---|
33 | * __fini_array_end
|
---|
34 | * __data_end__
|
---|
35 | * __bss_start__
|
---|
36 | * __bss_end__
|
---|
37 | * __end__
|
---|
38 | * end
|
---|
39 | * __HeapLimit
|
---|
40 | * __StackLimit
|
---|
41 | * __StackTop
|
---|
42 | * __stack
|
---|
43 | */
|
---|
44 | ENTRY(Reset_Handler)
|
---|
45 |
|
---|
46 | SECTIONS
|
---|
47 | {
|
---|
48 | .text :
|
---|
49 | {
|
---|
50 | KEEP(*(.isr_vector))
|
---|
51 | *(.text*)
|
---|
52 |
|
---|
53 | KEEP(*(.init))
|
---|
54 | KEEP(*(.fini))
|
---|
55 |
|
---|
56 | /* .ctors */
|
---|
57 | *crtbegin.o(.ctors)
|
---|
58 | *crtbegin?.o(.ctors)
|
---|
59 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
---|
60 | *(SORT(.ctors.*))
|
---|
61 | *(.ctors)
|
---|
62 |
|
---|
63 | /* .dtors */
|
---|
64 | *crtbegin.o(.dtors)
|
---|
65 | *crtbegin?.o(.dtors)
|
---|
66 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
---|
67 | *(SORT(.dtors.*))
|
---|
68 | *(.dtors)
|
---|
69 |
|
---|
70 | *(.rodata*)
|
---|
71 |
|
---|
72 | KEEP(*(.eh_frame*))
|
---|
73 | } > FLASH
|
---|
74 |
|
---|
75 | .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 | /* To copy multiple ROM to RAM sections,
|
---|
88 | * uncomment .copy.table section and,
|
---|
89 | * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
|
---|
90 | /*
|
---|
91 | .copy.table :
|
---|
92 | {
|
---|
93 | . = ALIGN(4);
|
---|
94 | __copy_table_start__ = .;
|
---|
95 | LONG (__etext)
|
---|
96 | LONG (__data_start__)
|
---|
97 | LONG (__data_end__ - __data_start__)
|
---|
98 | LONG (__etext2)
|
---|
99 | LONG (__data2_start__)
|
---|
100 | LONG (__data2_end__ - __data2_start__)
|
---|
101 | __copy_table_end__ = .;
|
---|
102 | } > FLASH
|
---|
103 | */
|
---|
104 |
|
---|
105 | /* To clear multiple BSS sections,
|
---|
106 | * uncomment .zero.table section and,
|
---|
107 | * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
|
---|
108 | /*
|
---|
109 | .zero.table :
|
---|
110 | {
|
---|
111 | . = ALIGN(4);
|
---|
112 | __zero_table_start__ = .;
|
---|
113 | LONG (__bss_start__)
|
---|
114 | LONG (__bss_end__ - __bss_start__)
|
---|
115 | LONG (__bss2_start__)
|
---|
116 | LONG (__bss2_end__ - __bss2_start__)
|
---|
117 | __zero_table_end__ = .;
|
---|
118 | } > FLASH
|
---|
119 | */
|
---|
120 |
|
---|
121 | __etext = .;
|
---|
122 |
|
---|
123 | .data : AT (__etext)
|
---|
124 | {
|
---|
125 | __data_start__ = .;
|
---|
126 | *(vtable)
|
---|
127 | *(.data*)
|
---|
128 |
|
---|
129 | . = ALIGN(4);
|
---|
130 | /* preinit data */
|
---|
131 | PROVIDE_HIDDEN (__preinit_array_start = .);
|
---|
132 | KEEP(*(.preinit_array))
|
---|
133 | PROVIDE_HIDDEN (__preinit_array_end = .);
|
---|
134 |
|
---|
135 | . = ALIGN(4);
|
---|
136 | /* init data */
|
---|
137 | PROVIDE_HIDDEN (__init_array_start = .);
|
---|
138 | KEEP(*(SORT(.init_array.*)))
|
---|
139 | KEEP(*(.init_array))
|
---|
140 | PROVIDE_HIDDEN (__init_array_end = .);
|
---|
141 |
|
---|
142 |
|
---|
143 | . = ALIGN(4);
|
---|
144 | /* finit data */
|
---|
145 | PROVIDE_HIDDEN (__fini_array_start = .);
|
---|
146 | KEEP(*(SORT(.fini_array.*)))
|
---|
147 | KEEP(*(.fini_array))
|
---|
148 | PROVIDE_HIDDEN (__fini_array_end = .);
|
---|
149 |
|
---|
150 | KEEP(*(.jcr*))
|
---|
151 | . = ALIGN(4);
|
---|
152 | /* All data end */
|
---|
153 | __data_end__ = .;
|
---|
154 |
|
---|
155 | } > RAM
|
---|
156 |
|
---|
157 | .bss :
|
---|
158 | {
|
---|
159 | . = ALIGN(4);
|
---|
160 | __bss_start__ = .;
|
---|
161 | *(.bss*)
|
---|
162 | *(COMMON)
|
---|
163 | . = ALIGN(4);
|
---|
164 | __bss_end__ = .;
|
---|
165 | } > RAM
|
---|
166 |
|
---|
167 | .heap (COPY):
|
---|
168 | {
|
---|
169 | __end__ = .;
|
---|
170 | PROVIDE(end = .);
|
---|
171 | *(.heap*)
|
---|
172 | __HeapLimit = .;
|
---|
173 | } > RAM
|
---|
174 |
|
---|
175 | /* .stack_dummy section doesn't contains any symbols. It is only
|
---|
176 | * used for linker to calculate size of stack sections, and assign
|
---|
177 | * values to stack symbols later */
|
---|
178 | .stack_dummy (COPY):
|
---|
179 | {
|
---|
180 | *(.stack*)
|
---|
181 | } > RAM
|
---|
182 |
|
---|
183 | /* Set stack top to end of RAM, and stack limit move down by
|
---|
184 | * size of stack_dummy section */
|
---|
185 | __StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
---|
186 | __StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
---|
187 | PROVIDE(__stack = __StackTop);
|
---|
188 |
|
---|
189 | __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ;
|
---|
190 |
|
---|
191 | /* Check if data + heap + stack exceeds RAM limit */
|
---|
192 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
---|
193 | }
|
---|