1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup bsp_linker |
---|
5 | * |
---|
6 | * @brief Memory map |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * |
---|
11 | * Copyright (c) 2015 University of York. |
---|
12 | * Hesham ALMatary <hmka501@york.ac.uk> |
---|
13 | * |
---|
14 | * Redistribution and use in source and binary forms, with or without |
---|
15 | * modification, are permitted provided that the following conditions |
---|
16 | * are met: |
---|
17 | * 1. Redistributions of source code must retain the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer. |
---|
19 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer in the |
---|
21 | * documentation and/or other materials provided with the distribution. |
---|
22 | * |
---|
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
---|
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
---|
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
33 | * SUCH DAMAGE. |
---|
34 | */ |
---|
35 | |
---|
36 | OUTPUT_ARCH (riscv) |
---|
37 | |
---|
38 | ENTRY (_start) |
---|
39 | STARTUP (start.o) |
---|
40 | |
---|
41 | MEMORY |
---|
42 | { |
---|
43 | RAM : ORIGIN = 0x0000000010000000, LENGTH = 0x10000000 |
---|
44 | } |
---|
45 | |
---|
46 | REGION_ALIAS ("REGION_VECTOR", RAM); |
---|
47 | REGION_ALIAS ("REGION_START", RAM); |
---|
48 | REGION_ALIAS ("REGION_TEXT", RAM); |
---|
49 | REGION_ALIAS ("REGION_TEXT_LOAD", RAM); |
---|
50 | REGION_ALIAS ("REGION_RODATA", RAM); |
---|
51 | REGION_ALIAS ("REGION_RODATA_LOAD", RAM); |
---|
52 | REGION_ALIAS ("REGION_DATA", RAM); |
---|
53 | REGION_ALIAS ("REGION_DATA_LOAD", RAM); |
---|
54 | REGION_ALIAS ("REGION_HTIF", RAM); |
---|
55 | REGION_ALIAS ("REGION_HTIF_LOAD", RAM); |
---|
56 | REGION_ALIAS ("REGION_FAST_DATA", RAM); |
---|
57 | REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM); |
---|
58 | REGION_ALIAS ("REGION_BSS", RAM); |
---|
59 | REGION_ALIAS ("REGION_WORK", RAM); |
---|
60 | REGION_ALIAS ("REGION_STACK", RAM); |
---|
61 | |
---|
62 | /* |
---|
63 | * Global symbols that may be defined externally |
---|
64 | */ |
---|
65 | bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size : 64; |
---|
66 | |
---|
67 | bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1; |
---|
68 | bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1; |
---|
69 | bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1; |
---|
70 | |
---|
71 | bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 16; |
---|
72 | |
---|
73 | bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 4096; |
---|
74 | bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align); |
---|
75 | |
---|
76 | SECTIONS { |
---|
77 | |
---|
78 | .vector : |
---|
79 | { |
---|
80 | . = ALIGN(8); |
---|
81 | bsp_section_vector_begin = .; |
---|
82 | *(.vector) |
---|
83 | . = ALIGN(bsp_vector_table_size); |
---|
84 | bsp_section_vector_end = .; |
---|
85 | } > REGION_VECTOR AT > REGION_VECTOR |
---|
86 | bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin; |
---|
87 | bsp_vector_table_begin = bsp_section_vector_begin; |
---|
88 | bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size; |
---|
89 | |
---|
90 | .start : |
---|
91 | { |
---|
92 | . = ALIGN(8); |
---|
93 | bsp_section_start_begin = .; |
---|
94 | KEEP (*(.bsp_start_text)) |
---|
95 | KEEP (*(.bsp_start_data)) |
---|
96 | bsp_section_start_end = .; |
---|
97 | } > REGION_START AT > REGION_START |
---|
98 | bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin; |
---|
99 | |
---|
100 | .xbarrier : { |
---|
101 | . = ALIGN (bsp_section_xbarrier_align); |
---|
102 | } > REGION_VECTOR AT > REGION_VECTOR |
---|
103 | |
---|
104 | .text : { |
---|
105 | . = ALIGN(8); |
---|
106 | bsp_section_text_begin = .; |
---|
107 | *(.text.unlikely .text.*_unlikely) |
---|
108 | *(.text .stub .text.* .gnu.linkonce.t.*) |
---|
109 | /* .gnu.warning sections are handled specially by elf32.em. */ |
---|
110 | *(.gnu.warning) |
---|
111 | *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) |
---|
112 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
113 | .init : { |
---|
114 | KEEP (*(.init)) |
---|
115 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
116 | .fini : { |
---|
117 | KEEP (*(.fini)) |
---|
118 | . = ALIGN(8); |
---|
119 | bsp_section_text_end = .; |
---|
120 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
121 | bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin; |
---|
122 | bsp_section_text_load_begin = LOADADDR (.text); |
---|
123 | bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size; |
---|
124 | |
---|
125 | .robarrier : { |
---|
126 | . = ALIGN (bsp_section_robarrier_align); |
---|
127 | } > REGION_RODATA AT > REGION_RODATA |
---|
128 | |
---|
129 | .rodata : { |
---|
130 | . = ALIGN(8); |
---|
131 | bsp_section_rodata_begin = .; |
---|
132 | *(.rodata .rodata.* .gnu.linkonce.r.*) |
---|
133 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
134 | .eh_frame : { |
---|
135 | KEEP (*(.eh_frame)) |
---|
136 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
137 | .gcc_except_table : { |
---|
138 | *(.gcc_except_table .gcc_except_table.*) |
---|
139 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
140 | .tdata : { |
---|
141 | _TLS_Data_begin = .; |
---|
142 | *(.tdata .tdata.* .gnu.linkonce.td.*) |
---|
143 | _TLS_Data_end = .; |
---|
144 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
145 | .tbss : { |
---|
146 | _TLS_BSS_begin = .; |
---|
147 | *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) |
---|
148 | _TLS_BSS_end = .; |
---|
149 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
150 | _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; |
---|
151 | _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; |
---|
152 | _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; |
---|
153 | _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; |
---|
154 | _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; |
---|
155 | _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); |
---|
156 | .preinit_array : { |
---|
157 | PROVIDE_HIDDEN (__preinit_array_start = .); |
---|
158 | KEEP (*(.preinit_array)) |
---|
159 | PROVIDE_HIDDEN (__preinit_array_end = .); |
---|
160 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
161 | .init_array : { |
---|
162 | PROVIDE_HIDDEN (__init_array_start = .); |
---|
163 | KEEP (*(SORT(.init_array.*))) |
---|
164 | KEEP (*(.init_array)) |
---|
165 | PROVIDE_HIDDEN (__init_array_end = .); |
---|
166 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
167 | .fini_array : { |
---|
168 | PROVIDE_HIDDEN (__fini_array_start = .); |
---|
169 | KEEP (*(.fini_array)) |
---|
170 | KEEP (*(SORT(.fini_array.*))) |
---|
171 | PROVIDE_HIDDEN (__fini_array_end = .); |
---|
172 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
173 | .ctors : { |
---|
174 | /* gcc uses crtbegin.o to find the start of |
---|
175 | the constructors, so we make sure it is |
---|
176 | first. Because this is a wildcard, it |
---|
177 | doesn't matter if the user does not |
---|
178 | actually link against crtbegin.o; the |
---|
179 | linker won't look for a file to match a |
---|
180 | wildcard. The wildcard also means that it |
---|
181 | doesn't matter which directory crtbegin.o |
---|
182 | is in. */ |
---|
183 | KEEP (*crtbegin.o(.ctors)) |
---|
184 | KEEP (*crtbegin?.o(.ctors)) |
---|
185 | /* We don't want to include the .ctor section from |
---|
186 | the crtend.o file until after the sorted ctors. |
---|
187 | The .ctor section from the crtend file contains the |
---|
188 | end of ctors marker and it must be last */ |
---|
189 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) |
---|
190 | KEEP (*(SORT(.ctors.*))) |
---|
191 | KEEP (*(.ctors)) |
---|
192 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
193 | .dtors : { |
---|
194 | KEEP (*crtbegin.o(.dtors)) |
---|
195 | KEEP (*crtbegin?.o(.dtors)) |
---|
196 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) |
---|
197 | KEEP (*(SORT(.dtors.*))) |
---|
198 | KEEP (*(.dtors)) |
---|
199 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
200 | .data.rel.ro : { |
---|
201 | *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) |
---|
202 | *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) |
---|
203 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
204 | .jcr : { |
---|
205 | KEEP (*(.jcr)) |
---|
206 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
207 | .interp : { |
---|
208 | *(.interp) |
---|
209 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
210 | .note.gnu.build-id : { |
---|
211 | *(.note.gnu.build-id) |
---|
212 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
213 | .hash : { |
---|
214 | *(.hash) |
---|
215 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
216 | .gnu.hash : { |
---|
217 | *(.gnu.hash) |
---|
218 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
219 | .dynsym : { |
---|
220 | *(.dynsym) |
---|
221 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
222 | .dynstr : { |
---|
223 | *(.dynstr) |
---|
224 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
225 | .gnu.version : { |
---|
226 | *(.gnu.version) |
---|
227 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
228 | .gnu.version_d : { |
---|
229 | *(.gnu.version_d) |
---|
230 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
231 | .gnu.version_r : { |
---|
232 | *(.gnu.version_r) |
---|
233 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
234 | .rel.dyn : { |
---|
235 | *(.rel.init) |
---|
236 | *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) |
---|
237 | *(.rel.fini) |
---|
238 | *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) |
---|
239 | *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) |
---|
240 | *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) |
---|
241 | *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) |
---|
242 | *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) |
---|
243 | *(.rel.ctors) |
---|
244 | *(.rel.dtors) |
---|
245 | *(.rel.got) |
---|
246 | *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) |
---|
247 | PROVIDE_HIDDEN (__rel_iplt_start = .); |
---|
248 | *(.rel.iplt) |
---|
249 | PROVIDE_HIDDEN (__rel_iplt_end = .); |
---|
250 | PROVIDE_HIDDEN (__rela_iplt_start = .); |
---|
251 | PROVIDE_HIDDEN (__rela_iplt_end = .); |
---|
252 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
253 | .rela.dyn : { |
---|
254 | *(.rela.init) |
---|
255 | *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) |
---|
256 | *(.rela.fini) |
---|
257 | *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) |
---|
258 | *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) |
---|
259 | *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) |
---|
260 | *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) |
---|
261 | *(.rela.ctors) |
---|
262 | *(.rela.dtors) |
---|
263 | *(.rela.got) |
---|
264 | *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) |
---|
265 | PROVIDE_HIDDEN (__rel_iplt_start = .); |
---|
266 | PROVIDE_HIDDEN (__rel_iplt_end = .); |
---|
267 | PROVIDE_HIDDEN (__rela_iplt_start = .); |
---|
268 | *(.rela.iplt) |
---|
269 | PROVIDE_HIDDEN (__rela_iplt_end = .); |
---|
270 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
271 | .rel.plt : { |
---|
272 | *(.rel.plt) |
---|
273 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
274 | .rela.plt : { |
---|
275 | *(.rela.plt) |
---|
276 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
277 | .plt : { |
---|
278 | *(.plt) |
---|
279 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
280 | .iplt : { |
---|
281 | *(.iplt) |
---|
282 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
283 | .dynamic : { |
---|
284 | *(.dynamic) |
---|
285 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
286 | .got : { |
---|
287 | *(.got.plt) *(.igot.plt) *(.got) *(.igot) |
---|
288 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
289 | .rtemsroset : { |
---|
290 | /* Special FreeBSD linker set sections */ |
---|
291 | __start_set_sysctl_set = .; |
---|
292 | *(set_sysctl_*); |
---|
293 | __stop_set_sysctl_set = .; |
---|
294 | *(set_domain_*); |
---|
295 | *(set_pseudo_*); |
---|
296 | |
---|
297 | KEEP (*(SORT(.rtemsroset.*))) |
---|
298 | . = ALIGN(8); |
---|
299 | bsp_section_rodata_end = .; |
---|
300 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
301 | bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin; |
---|
302 | bsp_section_rodata_load_begin = LOADADDR (.rodata); |
---|
303 | bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size; |
---|
304 | |
---|
305 | /*--------------------------------------------------------------------*/ |
---|
306 | /* HTIF, isolated onto separate page */ |
---|
307 | /*--------------------------------------------------------------------*/ |
---|
308 | .htif : |
---|
309 | { |
---|
310 | . = ALIGN(0x1000); |
---|
311 | *(.htif) |
---|
312 | . = ALIGN(0x1000); |
---|
313 | } > REGION_HTIF AT > REGION_HTIF_LOAD |
---|
314 | |
---|
315 | |
---|
316 | .rwbarrier : { |
---|
317 | . = ALIGN(8); |
---|
318 | . = ALIGN (bsp_section_rwbarrier_align); |
---|
319 | } > REGION_DATA AT > REGION_DATA |
---|
320 | |
---|
321 | .data : { |
---|
322 | . = ALIGN(8); |
---|
323 | bsp_section_data_begin = .; |
---|
324 | *(.data .data.* .gnu.linkonce.d.*) |
---|
325 | SORT(CONSTRUCTORS) |
---|
326 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
327 | .data1 : { |
---|
328 | *(.data1) |
---|
329 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
330 | .rtemsrwset : { |
---|
331 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
332 | . = ALIGN(8); |
---|
333 | bsp_section_data_end = .; |
---|
334 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
335 | bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin; |
---|
336 | bsp_section_data_load_begin = LOADADDR (.data); |
---|
337 | bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size; |
---|
338 | |
---|
339 | .bss : { |
---|
340 | . = ALIGN(8); |
---|
341 | bsp_section_bss_begin = .; |
---|
342 | *(.dynbss) |
---|
343 | *(.bss .bss.* .gnu.linkonce.b.*) |
---|
344 | *(COMMON) |
---|
345 | . = ALIGN(8); |
---|
346 | bsp_section_bss_end = .; |
---|
347 | } > REGION_BSS AT > REGION_BSS |
---|
348 | bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin; |
---|
349 | |
---|
350 | .rtemsstack (NOLOAD) : { |
---|
351 | *(SORT(.rtemsstack.*)) |
---|
352 | } > REGION_WORK AT > REGION_WORK |
---|
353 | |
---|
354 | .work : { |
---|
355 | /* |
---|
356 | * The work section will occupy the remaining REGION_WORK region and |
---|
357 | * contains the RTEMS work space and heap. |
---|
358 | */ |
---|
359 | . = ALIGN(8); |
---|
360 | bsp_section_work_begin = .; |
---|
361 | . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.); |
---|
362 | . = ALIGN(8); |
---|
363 | bsp_section_work_end = .; |
---|
364 | } > REGION_WORK AT > REGION_WORK |
---|
365 | bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin; |
---|
366 | |
---|
367 | .stack : { |
---|
368 | . = ALIGN(8); |
---|
369 | bsp_section_stack_begin = .; |
---|
370 | . += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.); |
---|
371 | . = ALIGN(8); |
---|
372 | bsp_section_stack_end = .; |
---|
373 | } > REGION_STACK AT > REGION_STACK |
---|
374 | bsp_section_stack_size = bsp_section_stack_begin - bsp_section_stack_end; |
---|
375 | |
---|
376 | RamBase = ORIGIN (REGION_WORK); |
---|
377 | RamSize = LENGTH (REGION_WORK); |
---|
378 | WorkAreaBase = bsp_section_work_begin; |
---|
379 | HeapSize = 0; |
---|
380 | } |
---|