source: rtems/bsps/riscv/shared/start/linkcmds.base @ d3d4e77

5
Last change on this file since d3d4e77 was d3d4e77, checked in by Jiri Gaisler <jiri@…>, on 01/18/19 at 11:37:55

riscv: add griscv bsp

Update #3678.

  • Property mode set to 100644
File size: 14.3 KB
Line 
1/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
2   Copying and distribution of this script, with or without modification,
3   are permitted in any medium without royalty provided the copyright
4   notice and this notice are preserved.  */
5
6/*
7 * Copyright (c) 2018 embedded brains GmbH.
8 *
9 * Copyright (c) 2015 University of York.
10 * Hesham ALMatary <hmka501@york.ac.uk>
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34OUTPUT_ARCH(riscv)
35ENTRY(_start)
36STARTUP(start.o)
37
38bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;
39bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;
40
41MEMORY {
42        UNEXPECTED_SECTIONS : ORIGIN = 0xffffffff, LENGTH = 0
43}
44
45SECTIONS {
46        .start : ALIGN_WITH_INPUT {
47                bsp_section_start_begin = .;
48                KEEP (*(.bsp_start_text))
49                KEEP (*(.bsp_start_data))
50                bsp_section_start_end = .;
51        } > REGION_START AT > REGION_START
52        bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin;
53
54        .text : ALIGN_WITH_INPUT {
55                bsp_section_text_begin = .;
56                *(.text.unlikely .text.*_unlikely .text.unlikely.*)
57                *(.text.exit .text.exit.*)
58                *(.text.startup .text.startup.*)
59                *(.text.hot .text.hot.*)
60                *(.text .stub .text.* .gnu.linkonce.t.*)
61                /* .gnu.warning sections are handled specially by elf32.em.     */
62                *(.gnu.warning)
63        } > REGION_TEXT AT > REGION_TEXT_LOAD
64        .init : ALIGN_WITH_INPUT {
65                KEEP (*(SORT_NONE(.init)))
66        } > REGION_TEXT AT > REGION_TEXT_LOAD
67        .fini : ALIGN_WITH_INPUT {
68                KEEP (*(SORT_NONE(.fini)))
69                bsp_section_text_end = .;
70        } > REGION_TEXT AT > REGION_TEXT_LOAD
71        bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;
72        bsp_section_text_load_begin = LOADADDR (.text);
73        bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size;
74
75        .robarrier : ALIGN_WITH_INPUT {
76                . = ALIGN (bsp_section_robarrier_align);
77        } > REGION_RODATA AT > REGION_RODATA
78
79        .rodata : ALIGN_WITH_INPUT {
80                bsp_section_rodata_begin = .;
81                *(.rodata .rodata.* .gnu.linkonce.r.*)
82        } > REGION_RODATA AT > REGION_RODATA_LOAD
83        .rodata1 : ALIGN_WITH_INPUT {
84                *(.rodata1)
85        } > REGION_RODATA AT > REGION_RODATA_LOAD
86        .sdata2 : ALIGN_WITH_INPUT {
87                *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
88        } > REGION_RODATA AT > REGION_RODATA_LOAD
89        .sbss2 : ALIGN_WITH_INPUT {
90                *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
91        } > REGION_RODATA AT > REGION_RODATA_LOAD
92        .eh_frame_hdr : ALIGN_WITH_INPUT {
93                *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*)
94        } > REGION_RODATA AT > REGION_RODATA_LOAD
95        .eh_frame : ALIGN_WITH_INPUT {
96                KEEP (*(.eh_frame)) *(.eh_frame.*)
97        } > REGION_RODATA AT > REGION_RODATA_LOAD
98        .gcc_except_table : ALIGN_WITH_INPUT {
99                *(.gcc_except_table .gcc_except_table.*)
100        } > REGION_RODATA AT > REGION_RODATA_LOAD
101        .gnu_extab : ALIGN_WITH_INPUT {
102                *(.gnu_extab*)
103        } > REGION_RODATA AT > REGION_RODATA_LOAD
104        .tdata : ALIGN_WITH_INPUT {
105                _TLS_Data_begin = .;
106                *(.tdata .tdata.* .gnu.linkonce.td.*)
107                _TLS_Data_end = .;
108        } > REGION_RODATA AT > REGION_RODATA_LOAD
109        .tbss : ALIGN_WITH_INPUT {
110                _TLS_BSS_begin = .;
111                *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
112                _TLS_BSS_end = .;
113        } > REGION_RODATA AT > REGION_RODATA_LOAD
114        _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
115        _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;
116        _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;
117        _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
118        _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
119        _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
120        .preinit_array : ALIGN_WITH_INPUT {
121                PROVIDE_HIDDEN (__preinit_array_start = .);
122                KEEP (*(.preinit_array))
123                PROVIDE_HIDDEN (__preinit_array_end = .);
124        } > REGION_RODATA AT > REGION_RODATA_LOAD
125        .init_array : ALIGN_WITH_INPUT {
126                PROVIDE_HIDDEN (__init_array_start = .);
127                KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
128                KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
129                PROVIDE_HIDDEN (__init_array_end = .);
130        } > REGION_RODATA AT > REGION_RODATA_LOAD
131        .fini_array : ALIGN_WITH_INPUT {
132                PROVIDE_HIDDEN (__fini_array_start = .);
133                KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
134                KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
135                PROVIDE_HIDDEN (__fini_array_end = .);
136        } > REGION_RODATA AT > REGION_RODATA_LOAD
137        .ctors : ALIGN_WITH_INPUT {
138                /* gcc uses crtbegin.o to find the start of
139                         the constructors, so we make sure it is
140                         first. Because this is a wildcard, it
141                         doesn't matter if the user does not
142                         actually link against crtbegin.o; the
143                         linker won't look for a file to match a
144                         wildcard.      The wildcard also means that it
145                         doesn't matter which directory crtbegin.o
146                         is in. */
147                KEEP (*crtbegin.o(.ctors))
148                KEEP (*crtbegin?.o(.ctors))
149                /* We don't want to include the .ctor section from
150                         the crtend.o file until after the sorted ctors.
151                         The .ctor section from the crtend file contains the
152                         end of ctors marker and it must be last */
153                KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
154                KEEP (*(SORT(.ctors.*)))
155                KEEP (*(.ctors))
156        } > REGION_RODATA AT > REGION_RODATA_LOAD
157        .dtors : ALIGN_WITH_INPUT {
158                KEEP (*crtbegin.o(.dtors))
159                KEEP (*crtbegin?.o(.dtors))
160                KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
161                KEEP (*(SORT(.dtors.*)))
162                KEEP (*(.dtors))
163        } > REGION_RODATA AT > REGION_RODATA_LOAD
164        .data.rel.ro : ALIGN_WITH_INPUT {
165                *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
166                *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
167        } > REGION_RODATA AT > REGION_RODATA_LOAD
168        .jcr : ALIGN_WITH_INPUT {
169                KEEP (*(.jcr))
170        } > REGION_RODATA AT > REGION_RODATA_LOAD
171        .interp : ALIGN_WITH_INPUT {
172                *(.interp)
173        } > REGION_RODATA AT > REGION_RODATA_LOAD
174        .note.gnu.build-id : { *(.note.gnu.build-id)
175        } > REGION_RODATA AT > REGION_RODATA_LOAD
176        .hash : ALIGN_WITH_INPUT {
177                *(.hash)
178        } > REGION_RODATA AT > REGION_RODATA_LOAD
179        .gnu.hash : ALIGN_WITH_INPUT {
180                *(.gnu.hash)
181        } > REGION_RODATA AT > REGION_RODATA_LOAD
182        .dynsym : ALIGN_WITH_INPUT {
183                *(.dynsym)
184        } > REGION_RODATA AT > REGION_RODATA_LOAD
185        .dynstr : ALIGN_WITH_INPUT {
186                *(.dynstr)
187        } > REGION_RODATA AT > REGION_RODATA_LOAD
188        .gnu.version : ALIGN_WITH_INPUT {
189                *(.gnu.version)
190        } > REGION_RODATA AT > REGION_RODATA_LOAD
191        .gnu.version_d : ALIGN_WITH_INPUT {
192                *(.gnu.version_d)
193        } > REGION_RODATA AT > REGION_RODATA_LOAD
194        .gnu.version_r : ALIGN_WITH_INPUT {
195                *(.gnu.version_r)
196        } > REGION_RODATA AT > REGION_RODATA_LOAD
197        .rela.dyn : ALIGN_WITH_INPUT {
198                *(.rela.init)
199                *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
200                *(.rela.fini)
201                *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
202                *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
203                *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
204                *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
205                *(.rela.ctors)
206                *(.rela.dtors)
207                *(.rela.got)
208                *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
209                *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
210                *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
211                *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
212                *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
213                PROVIDE_HIDDEN (__rela_iplt_start = .);
214                *(.rela.iplt)
215                PROVIDE_HIDDEN (__rela_iplt_end = .);
216        } > REGION_RODATA AT > REGION_RODATA_LOAD
217        .rela.plt : ALIGN_WITH_INPUT {
218                        *(.rela.plt)
219        } > REGION_RODATA AT > REGION_RODATA_LOAD
220        .plt : ALIGN_WITH_INPUT {
221                *(.plt)
222        } > REGION_RODATA AT > REGION_RODATA_LOAD
223        .iplt : ALIGN_WITH_INPUT {
224                *(.iplt)
225        } > REGION_RODATA AT > REGION_RODATA_LOAD
226        .dynamic : ALIGN_WITH_INPUT {
227                *(.dynamic)
228        } > REGION_RODATA AT > REGION_RODATA_LOAD
229        .tm_clone_table : ALIGN_WITH_INPUT {
230                *(.tm_clone_table)
231        } > REGION_RODATA AT > REGION_RODATA_LOAD
232        .got : ALIGN_WITH_INPUT {
233                *(.got.plt) *(.igot.plt) *(.got) *(.igot)
234        } > REGION_RODATA AT > REGION_RODATA_LOAD
235        .rtemsroset : ALIGN_WITH_INPUT {
236                /* Special FreeBSD linker set sections */
237                __start_set_sysctl_set = .;
238                *(set_sysctl_*);
239                __stop_set_sysctl_set = .;
240                *(set_domain_*);
241                *(set_pseudo_*);
242
243                KEEP (*(SORT(.rtemsroset.*)))
244                bsp_section_rodata_end = .;
245        } > REGION_RODATA AT > REGION_RODATA_LOAD
246        bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
247        bsp_section_rodata_load_begin = LOADADDR (.rodata);
248        bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;
249
250        .rwbarrier : ALIGN_WITH_INPUT {
251                . = ALIGN (bsp_section_rwbarrier_align);
252        } > REGION_DATA AT > REGION_DATA
253
254        .fast_text : ALIGN_WITH_INPUT {
255                bsp_section_fast_text_begin = .;
256                *(.bsp_fast_text)
257                bsp_section_fast_text_end = .;
258        } > REGION_FAST_TEXT AT > REGION_FAST_TEXT_LOAD
259        bsp_section_fast_text_size = bsp_section_fast_text_end - bsp_section_fast_text_begin;
260        bsp_section_fast_text_load_begin = LOADADDR (.fast_text);
261        bsp_section_fast_text_load_end = bsp_section_fast_text_load_begin + bsp_section_fast_text_size;
262
263        .fast_data : ALIGN_WITH_INPUT {
264                bsp_section_fast_data_begin = .;
265                *(.bsp_fast_data)
266                bsp_section_fast_data_end = .;
267        } > REGION_FAST_DATA AT > REGION_FAST_DATA_LOAD
268        bsp_section_fast_data_size = bsp_section_fast_data_end - bsp_section_fast_data_begin;
269        bsp_section_fast_data_load_begin = LOADADDR (.fast_data);
270        bsp_section_fast_data_load_end = bsp_section_fast_data_load_begin + bsp_section_fast_data_size;
271
272        .data : ALIGN_WITH_INPUT {
273                bsp_section_data_begin = .;
274                *(.data .data.* .gnu.linkonce.d.*)
275                SORT(CONSTRUCTORS)
276        } > REGION_DATA AT > REGION_DATA_LOAD
277        .data1 : ALIGN_WITH_INPUT {
278                *(.data1)
279        } > REGION_DATA AT > REGION_DATA_LOAD
280        .rtemsrwset : ALIGN_WITH_INPUT {
281                KEEP (*(SORT(.rtemsrwset.*)))
282        } > REGION_DATA AT > REGION_DATA_LOAD
283        .htif ALIGN(4096) : ALIGN_WITH_INPUT {
284                *(.htif)
285        } > REGION_DATA AT > REGION_DATA_LOAD
286        .sdata : ALIGN_WITH_INPUT {
287                __global_pointer$ = . + 0x800;
288                *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
289                *(.sdata .sdata.* .gnu.linkonce.s.*)
290                bsp_section_data_end = .;
291        } > REGION_DATA AT > REGION_DATA_LOAD
292        bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
293        bsp_section_data_load_begin = LOADADDR (.data);
294        bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
295
296        .sbss : ALIGN_WITH_INPUT {
297                bsp_section_bss_begin = .;
298                *(.dynsbss)
299                *(.sbss .sbss.* .gnu.linkonce.sb.*)
300                *(.scommon)
301        } > REGION_DATA AT > REGION_DATA
302        .bss : ALIGN_WITH_INPUT {
303                *(.dynbss)
304                *(.bss .bss.* .gnu.linkonce.b.*)
305                *(COMMON)
306                bsp_section_bss_end = .;
307        } > REGION_DATA AT > REGION_DATA
308        bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
309
310        .rtemsstack (NOLOAD) : ALIGN_WITH_INPUT {
311                bsp_section_rtemsstack_begin = .;
312                *(SORT(.rtemsstack.*))
313                bsp_section_rtemsstack_end = .;
314        } > REGION_RTEMSSTACK AT > REGION_RTEMSSTACK
315        bsp_section_rtemsstack_size = bsp_section_rtemsstack_end - bsp_section_rtemsstack_begin;
316
317        .work : ALIGN_WITH_INPUT {
318                /*
319                 * The work section will occupy the remaining REGION_WORK region and
320                 * contains the RTEMS work space and heap.
321                 */
322                bsp_section_work_begin = .;
323                . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
324                bsp_section_work_end = .;
325        } > REGION_WORK AT > REGION_WORK
326        bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
327
328        /* FIXME */
329        RamBase = ORIGIN (REGION_WORK);
330        RamSize = LENGTH (REGION_WORK);
331        WorkAreaBase = bsp_section_work_begin;
332        HeapSize = 0;
333
334        /* Stabs debugging sections.    */
335        .stab                                   0 : { *(.stab) }
336        .stabstr                         0 : { *(.stabstr) }
337        .stab.excl               0 : { *(.stab.excl) }
338        .stab.exclstr   0 : { *(.stab.exclstr) }
339        .stab.index             0 : { *(.stab.index) }
340        .stab.indexstr 0 : { *(.stab.indexstr) }
341        .comment                         0 : { *(.comment) }
342        /* DWARF debug sections.
343                 Symbols in the DWARF debugging sections are relative to the beginning
344                 of the section so we begin them at 0.  */
345        /* DWARF 1 */
346        .debug                                  0 : { *(.debug) }
347        .line                                    0 : { *(.line) }
348        /* GNU DWARF 1 extensions */
349        .debug_srcinfo  0 : { *(.debug_srcinfo) }
350        .debug_sfnames  0 : { *(.debug_sfnames) }
351        /* DWARF 1.1 and DWARF 2 */
352        .debug_aranges  0 : { *(.debug_aranges) }
353        .debug_pubnames 0 : { *(.debug_pubnames) }
354        /* DWARF 2 */
355        .debug_info              0 : { *(.debug_info .gnu.linkonce.wi.*) }
356        .debug_abbrev    0 : { *(.debug_abbrev) }
357        .debug_line              0 : { *(.debug_line .debug_line.* .debug_line_end ) }
358        .debug_frame            0 : { *(.debug_frame) }
359        .debug_str                      0 : { *(.debug_str) }
360        .debug_loc                      0 : { *(.debug_loc) }
361        .debug_macinfo  0 : { *(.debug_macinfo) }
362        /* SGI/MIPS DWARF 2 extensions */
363        .debug_weaknames 0 : { *(.debug_weaknames) }
364        .debug_funcnames 0 : { *(.debug_funcnames) }
365        .debug_typenames 0 : { *(.debug_typenames) }
366        .debug_varnames 0 : { *(.debug_varnames) }
367        /* DWARF 3 */
368        .debug_pubtypes 0 : { *(.debug_pubtypes) }
369        .debug_ranges    0 : { *(.debug_ranges) }
370        /* DWARF Extension.     */
371        .debug_macro            0 : { *(.debug_macro) }
372        .debug_addr              0 : { *(.debug_addr) }
373        .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
374        /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
375
376        /*
377         * This is a RTEMS specific section to catch all unexpected input
378         * sections.  In case you get an error like
379         *   "section `.unexpected_sections' will not fit in region
380         *   `UNEXPECTED_SECTIONS'"
381         * you have to figure out the offending input section and add it to the
382         * appropriate output section definition above.
383         */
384        .unexpected_sections : { *(*) } > UNEXPECTED_SECTIONS
385}
Note: See TracBrowser for help on using the repository browser.