source: rtems/c/src/lib/libbsp/riscv32/riscv_generic/startup/linkcmds @ 6d85e05

5
Last change on this file since 6d85e05 was 6d85e05, checked in by Hesham Almatary <hesham@…>, on 10/21/17 at 07:06:44

bsp: Add new riscv_generic bsp v3

  • Only runs/tested on simulator/spike.
  • Ticker, hello, capture work proprely
  • Tested via RTEMS Tester, Passed: 525/565 (92%)

Update #3109

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