source: rtems/c/src/lib/libbsp/riscv/riscv_generic/startup/linkcmds @ 8fa827c

5
Last change on this file since 8fa827c was 8fa827c, checked in by Hesham Almatary <heshamelmatary@…>, on 10/26/17 at 22:51:09

bsp: Make riscv_generic work for both riscv32 and riscv64 - v2

Update #3109

  • Property mode set to 100644
File size: 13.8 KB
Line 
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
36OUTPUT_ARCH (riscv)
37
38ENTRY (_start)
39
40MEMORY
41{
42  RAM    : ORIGIN = 0x0000000010000000, LENGTH = 0x10000000
43}
44
45REGION_ALIAS ("REGION_VECTOR", RAM);
46REGION_ALIAS ("REGION_START", RAM);
47REGION_ALIAS ("REGION_TEXT", RAM);
48REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
49REGION_ALIAS ("REGION_RODATA", RAM);
50REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
51REGION_ALIAS ("REGION_DATA", RAM);
52REGION_ALIAS ("REGION_DATA_LOAD", RAM);
53REGION_ALIAS ("REGION_HTIF", RAM);
54REGION_ALIAS ("REGION_HTIF_LOAD", RAM);
55REGION_ALIAS ("REGION_FAST_DATA", RAM);
56REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
57REGION_ALIAS ("REGION_BSS", RAM);
58REGION_ALIAS ("REGION_WORK", RAM);
59REGION_ALIAS ("REGION_STACK", RAM);
60
61/*
62 * Global symbols that may be defined externally
63 */
64bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size : 64;
65
66bsp_section_xbarrier_align  = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1;
67bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;
68bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;
69
70bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 16;
71
72bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 4096;
73bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
74
75_bsp_processor_count = DEFINED (_bsp_processor_count) ? _bsp_processor_count : 1;
76
77SECTIONS {
78
79  .vector :
80  {
81    . = ALIGN(8);
82    bsp_section_vector_begin = .;
83    *(.vector)
84    . = ALIGN(bsp_vector_table_size);
85    bsp_section_vector_end = .;
86  } > REGION_VECTOR AT > REGION_VECTOR
87  bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin;
88  bsp_vector_table_begin = bsp_section_vector_begin;
89  bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size;
90
91  .start :
92  {
93    . = ALIGN(8);
94    bsp_section_start_begin = .;
95    KEEP (*(.bsp_start_text))
96    KEEP (*(.bsp_start_data))
97    bsp_section_start_end = .;
98  } > REGION_START AT > REGION_START
99  bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin;
100
101.xbarrier :   {
102    . = ALIGN (bsp_section_xbarrier_align);
103  } > REGION_VECTOR AT > REGION_VECTOR
104
105.text :   {
106    . = ALIGN(8);
107    bsp_section_text_begin = .;
108    *(.text.unlikely .text.*_unlikely)
109    *(.text .stub .text.* .gnu.linkonce.t.*)
110    /* .gnu.warning sections are handled specially by elf32.em.  */
111    *(.gnu.warning)
112    *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
113  } > REGION_TEXT AT > REGION_TEXT_LOAD
114  .init :   {
115    KEEP (*(.init))
116  } > REGION_TEXT AT > REGION_TEXT_LOAD
117  .fini :   {
118    KEEP (*(.fini))
119    . = ALIGN(8);
120    bsp_section_text_end = .;
121  } > REGION_TEXT AT > REGION_TEXT_LOAD
122  bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;
123  bsp_section_text_load_begin = LOADADDR (.text);
124  bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size;
125
126.robarrier :   {
127    . = ALIGN (bsp_section_robarrier_align);
128  } > REGION_RODATA AT > REGION_RODATA
129
130.rodata :   {
131    . = ALIGN(8);
132    bsp_section_rodata_begin = .;
133    *(.rodata .rodata.* .gnu.linkonce.r.*)
134  } > REGION_RODATA AT > REGION_RODATA_LOAD
135.eh_frame :   {
136               KEEP (*(.eh_frame))
137       } > REGION_RODATA AT > REGION_RODATA_LOAD
138       .gcc_except_table :   {
139               *(.gcc_except_table .gcc_except_table.*)
140       } > REGION_RODATA AT > REGION_RODATA_LOAD
141       .tdata :   {
142               _TLS_Data_begin = .;
143               *(.tdata .tdata.* .gnu.linkonce.td.*)
144               _TLS_Data_end = .;
145       } > REGION_RODATA AT > REGION_RODATA_LOAD
146       .tbss :   {
147               _TLS_BSS_begin = .;
148               *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
149               _TLS_BSS_end = .;
150       } > REGION_RODATA AT > REGION_RODATA_LOAD
151       _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
152       _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;
153       _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;
154       _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
155       _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
156       _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
157       .preinit_array :   {
158               PROVIDE_HIDDEN (__preinit_array_start = .);
159               KEEP (*(.preinit_array))
160               PROVIDE_HIDDEN (__preinit_array_end = .);
161       } > REGION_RODATA AT > REGION_RODATA_LOAD
162       .init_array :   {
163               PROVIDE_HIDDEN (__init_array_start = .);
164               KEEP (*(SORT(.init_array.*)))
165               KEEP (*(.init_array))
166               PROVIDE_HIDDEN (__init_array_end = .);
167       } > REGION_RODATA AT > REGION_RODATA_LOAD
168       .fini_array :   {
169               PROVIDE_HIDDEN (__fini_array_start = .);
170               KEEP (*(.fini_array))
171               KEEP (*(SORT(.fini_array.*)))
172               PROVIDE_HIDDEN (__fini_array_end = .);
173       } > REGION_RODATA AT > REGION_RODATA_LOAD
174       .ctors :   {
175               /* gcc uses crtbegin.o to find the start of
176                  the constructors, so we make sure it is
177                  first.  Because this is a wildcard, it
178                  doesn't matter if the user does not
179                  actually link against crtbegin.o; the
180                  linker won't look for a file to match a
181                  wildcard.  The wildcard also means that it
182                  doesn't matter which directory crtbegin.o
183                  is in.  */
184               KEEP (*crtbegin.o(.ctors))
185               KEEP (*crtbegin?.o(.ctors))
186               /* We don't want to include the .ctor section from
187                  the crtend.o file until after the sorted ctors.
188                  The .ctor section from the crtend file contains the
189                  end of ctors marker and it must be last */
190               KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
191               KEEP (*(SORT(.ctors.*)))
192               KEEP (*(.ctors))
193       } > REGION_RODATA AT > REGION_RODATA_LOAD
194       .dtors :   {
195               KEEP (*crtbegin.o(.dtors))
196               KEEP (*crtbegin?.o(.dtors))
197               KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
198               KEEP (*(SORT(.dtors.*)))
199               KEEP (*(.dtors))
200       } > REGION_RODATA AT > REGION_RODATA_LOAD
201       .data.rel.ro :   {
202               *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
203               *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*)
204       } > REGION_RODATA AT > REGION_RODATA_LOAD
205       .jcr :   {
206               KEEP (*(.jcr))
207       } > REGION_RODATA AT > REGION_RODATA_LOAD
208       .interp :   {
209               *(.interp)
210       } > REGION_RODATA AT > REGION_RODATA_LOAD
211       .note.gnu.build-id :   {
212               *(.note.gnu.build-id)
213       } > REGION_RODATA AT > REGION_RODATA_LOAD
214       .hash :   {
215               *(.hash)
216       } > REGION_RODATA AT > REGION_RODATA_LOAD
217       .gnu.hash :   {
218               *(.gnu.hash)
219       } > REGION_RODATA AT > REGION_RODATA_LOAD
220       .dynsym :   {
221               *(.dynsym)
222       } > REGION_RODATA AT > REGION_RODATA_LOAD
223       .dynstr :   {
224               *(.dynstr)
225       } > REGION_RODATA AT > REGION_RODATA_LOAD
226       .gnu.version :   {
227               *(.gnu.version)
228       } > REGION_RODATA AT > REGION_RODATA_LOAD
229       .gnu.version_d :   {
230               *(.gnu.version_d)
231       } > REGION_RODATA AT > REGION_RODATA_LOAD
232       .gnu.version_r :   {
233               *(.gnu.version_r)
234       } > REGION_RODATA AT > REGION_RODATA_LOAD
235       .rel.dyn :   {
236               *(.rel.init)
237               *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
238               *(.rel.fini)
239               *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
240               *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
241               *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
242               *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
243               *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
244               *(.rel.ctors)
245               *(.rel.dtors)
246               *(.rel.got)
247               *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
248               PROVIDE_HIDDEN (__rel_iplt_start = .);
249               *(.rel.iplt)
250               PROVIDE_HIDDEN (__rel_iplt_end = .);
251               PROVIDE_HIDDEN (__rela_iplt_start = .);
252               PROVIDE_HIDDEN (__rela_iplt_end = .);
253       } > REGION_RODATA AT > REGION_RODATA_LOAD
254       .rela.dyn :   {
255               *(.rela.init)
256               *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
257               *(.rela.fini)
258               *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
259               *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
260               *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
261               *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
262               *(.rela.ctors)
263               *(.rela.dtors)
264               *(.rela.got)
265               *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
266               PROVIDE_HIDDEN (__rel_iplt_start = .);
267               PROVIDE_HIDDEN (__rel_iplt_end = .);
268               PROVIDE_HIDDEN (__rela_iplt_start = .);
269               *(.rela.iplt)
270               PROVIDE_HIDDEN (__rela_iplt_end = .);
271       } > REGION_RODATA AT > REGION_RODATA_LOAD
272       .rel.plt :   {
273               *(.rel.plt)
274       } > REGION_RODATA AT > REGION_RODATA_LOAD
275       .rela.plt :   {
276               *(.rela.plt)
277       } > REGION_RODATA AT > REGION_RODATA_LOAD
278       .plt :   {
279               *(.plt)
280       } > REGION_RODATA AT > REGION_RODATA_LOAD
281       .iplt :   {
282               *(.iplt)
283       } > REGION_RODATA AT > REGION_RODATA_LOAD
284       .dynamic :   {
285               *(.dynamic)
286       } > REGION_RODATA AT > REGION_RODATA_LOAD
287       .got :   {
288               *(.got.plt) *(.igot.plt) *(.got) *(.igot)
289       } > REGION_RODATA AT > REGION_RODATA_LOAD
290       .rtemsroset :   {
291               /* Special FreeBSD linker set sections */
292               __start_set_sysctl_set = .;
293               *(set_sysctl_*);
294               __stop_set_sysctl_set = .;
295               *(set_domain_*);
296               *(set_pseudo_*);
297
298               KEEP (*(SORT(.rtemsroset.*)))
299               . = ALIGN(8);
300               bsp_section_rodata_end = .;
301       } > REGION_RODATA AT > REGION_RODATA_LOAD
302  bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
303  bsp_section_rodata_load_begin = LOADADDR (.rodata);
304  bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;
305
306  /*--------------------------------------------------------------------*/
307  /* HTIF, isolated onto separate page                                  */
308  /*--------------------------------------------------------------------*/
309  .htif :
310  {
311    . = ALIGN(0x1000);
312    *(.htif)
313    . = ALIGN(0x1000);
314  } > REGION_HTIF AT > REGION_HTIF_LOAD
315
316
317.rwbarrier :   {
318    . = ALIGN(8);
319    . = ALIGN (bsp_section_rwbarrier_align);
320  } > REGION_DATA AT > REGION_DATA
321
322.data :   {
323    . = ALIGN(8);
324    bsp_section_data_begin = .;
325    *(.data .data.* .gnu.linkonce.d.*)
326    SORT(CONSTRUCTORS)
327  } > REGION_DATA AT > REGION_DATA_LOAD
328  .data1 :   {
329    *(.data1)
330  } > REGION_DATA AT > REGION_DATA_LOAD
331  .rtemsrwset :   {
332    KEEP (*(SORT(.rtemsrwset.*)))
333    . = ALIGN(8);
334    bsp_section_data_end = .;
335  } > REGION_DATA AT > REGION_DATA_LOAD
336  bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
337  bsp_section_data_load_begin = LOADADDR (.data);
338  bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
339
340  .bss :   {
341    . = ALIGN(8);
342    bsp_section_bss_begin = .;
343    *(.dynbss)
344    *(.bss .bss.* .gnu.linkonce.b.*)
345    *(COMMON)
346    . = ALIGN(8);
347    bsp_section_bss_end = .;
348  } > REGION_BSS AT > REGION_BSS
349  bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
350
351.work :   {
352    /*
353     * The work section will occupy the remaining REGION_WORK region and
354     * contains the RTEMS work space and heap.
355     */
356    . = ALIGN(8);
357    bsp_section_work_begin = .;
358    . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
359    . = ALIGN(8);
360    bsp_section_work_end = .;
361  } > REGION_WORK AT > REGION_WORK
362  bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
363
364  .stack :   {
365    . = ALIGN(8);
366    bsp_section_stack_begin = .;
367    . += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.);
368    . = ALIGN(8);
369    bsp_section_stack_end = .;
370  } > REGION_STACK AT > REGION_STACK
371  bsp_section_stack_size = bsp_section_stack_begin - bsp_section_stack_end;
372
373  RamBase = ORIGIN (REGION_WORK);
374  RamSize = LENGTH (REGION_WORK);
375  WorkAreaBase = bsp_section_work_begin;
376  HeapSize = 0;
377}
Note: See TracBrowser for help on using the repository browser.