1 |
2 |
zero_gravi |
/* ################################################################################################# */
|
2 |
|
|
/* # << NEORV32 - RISC-V GCC Linker Script >> # */
|
3 |
|
|
/* # ********************************************************************************************* # */
|
4 |
|
|
/* # BSD 3-Clause License # */
|
5 |
|
|
/* # # */
|
6 |
|
|
/* # Copyright (c) 2020, Stephan Nolting. All rights reserved. # */
|
7 |
|
|
/* # # */
|
8 |
|
|
/* # Redistribution and use in source and binary forms, with or without modification, are # */
|
9 |
|
|
/* # permitted provided that the following conditions are met: # */
|
10 |
|
|
/* # # */
|
11 |
|
|
/* # 1. Redistributions of source code must retain the above copyright notice, this list of # */
|
12 |
|
|
/* # conditions and the following disclaimer. # */
|
13 |
|
|
/* # # */
|
14 |
|
|
/* # 2. Redistributions in binary form must reproduce the above copyright notice, this list of # */
|
15 |
|
|
/* # conditions and the following disclaimer in the documentation and/or other materials # */
|
16 |
|
|
/* # provided with the distribution. # */
|
17 |
|
|
/* # # */
|
18 |
|
|
/* # 3. Neither the name of the copyright holder nor the names of its contributors may be used to # */
|
19 |
|
|
/* # endorse or promote products derived from this software without specific prior written # */
|
20 |
|
|
/* # permission. # */
|
21 |
|
|
/* # # */
|
22 |
|
|
/* # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS # */
|
23 |
|
|
/* # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # */
|
24 |
|
|
/* # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # */
|
25 |
|
|
/* # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # */
|
26 |
|
|
/* # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # */
|
27 |
|
|
/* # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # */
|
28 |
|
|
/* # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # */
|
29 |
|
|
/* # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # */
|
30 |
|
|
/* # OF THE POSSIBILITY OF SUCH DAMAGE. # */
|
31 |
|
|
/* # ********************************************************************************************* # */
|
32 |
|
|
/* # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # */
|
33 |
|
|
/* ################################################################################################# */
|
34 |
|
|
|
35 |
|
|
/* Default linker script, for normal executables */
|
36 |
|
|
/* Copyright (C) 2014-2020 Free Software Foundation, Inc.
|
37 |
|
|
Copying and distribution of this script, with or without modification,
|
38 |
|
|
are permitted in any medium without royalty provided the copyright
|
39 |
|
|
notice and this notice are preserved. */
|
40 |
|
|
|
41 |
|
|
/* modified for the NEORV32 processor by Stephan Nolting */
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
|
45 |
|
|
OUTPUT_ARCH(riscv)
|
46 |
|
|
ENTRY(_start)
|
47 |
|
|
SEARCH_DIR("=/opt/riscv/riscv64-unknown-linux-gnu/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
|
48 |
|
|
|
49 |
|
|
/* ************************************************* */
|
50 |
|
|
/* NEORV32 memory configuration. */
|
51 |
|
|
/* Make sure this is sync with your processor/ */
|
52 |
|
|
/* memory hardware configuration. */
|
53 |
|
|
/* ************************************************* */
|
54 |
|
|
MEMORY
|
55 |
|
|
{
|
56 |
|
|
rom (rx) : ORIGIN = 0x00000000, LENGTH = 16*1024
|
57 |
|
|
ram (rwx) : ORIGIN = 0x80000000 + 2*16*4, LENGTH = 8*1024
|
58 |
|
|
/* DO NOT REMOVE THE " + 2*16*4"!! */
|
59 |
|
|
}
|
60 |
|
|
/* ************************************************* */
|
61 |
|
|
|
62 |
|
|
SECTIONS
|
63 |
|
|
{
|
64 |
|
|
|
65 |
|
|
/* start section on WORD boundary */
|
66 |
|
|
. = ALIGN(4);
|
67 |
|
|
|
68 |
|
|
.interp : { *(.interp) }
|
69 |
|
|
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
70 |
|
|
.hash : { *(.hash) }
|
71 |
|
|
.gnu.hash : { *(.gnu.hash) }
|
72 |
|
|
.dynsym : { *(.dynsym) }
|
73 |
|
|
.dynstr : { *(.dynstr) }
|
74 |
|
|
.gnu.version : { *(.gnu.version) }
|
75 |
|
|
.gnu.version_d : { *(.gnu.version_d) }
|
76 |
|
|
.gnu.version_r : { *(.gnu.version_r) }
|
77 |
|
|
.rela.init : { *(.rela.init) }
|
78 |
|
|
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
|
79 |
|
|
.rela.fini : { *(.rela.fini) }
|
80 |
|
|
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
|
81 |
|
|
.rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
|
82 |
|
|
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
|
83 |
|
|
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
|
84 |
|
|
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
|
85 |
|
|
.rela.ctors : { *(.rela.ctors) }
|
86 |
|
|
.rela.dtors : { *(.rela.dtors) }
|
87 |
|
|
.rela.got : { *(.rela.got) }
|
88 |
|
|
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
|
89 |
|
|
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
|
90 |
|
|
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
|
91 |
|
|
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
|
92 |
|
|
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
|
93 |
|
|
/* Actual instructions */
|
94 |
|
|
.text :
|
95 |
|
|
{
|
96 |
|
|
PROVIDE(__text_start = .);
|
97 |
|
|
PROVIDE(__textstart = .);
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
PROVIDE_HIDDEN (__rela_iplt_start = .);
|
102 |
|
|
*(.rela.iplt)
|
103 |
|
|
PROVIDE_HIDDEN (__rela_iplt_end = .);
|
104 |
|
|
|
105 |
|
|
*(.rela.plt)
|
106 |
|
|
|
107 |
|
|
KEEP (*(SORT_NONE(.init)))
|
108 |
|
|
|
109 |
|
|
KEEP(crt0.elf(.text)); /* NEORV32-SPECIFIC start-up code */
|
110 |
|
|
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
111 |
|
|
*(.text.exit .text.exit.*)
|
112 |
|
|
*(.text.startup .text.startup.*)
|
113 |
|
|
*(.text.hot .text.hot.*)
|
114 |
|
|
*(SORT(.text.sorted.*))
|
115 |
|
|
*(.text .stub .text.* .gnu.linkonce.t.*)
|
116 |
|
|
/* .gnu.warning sections are handled specially by elf.em. */
|
117 |
|
|
*(.gnu.warning)
|
118 |
|
|
|
119 |
|
|
KEEP (*(SORT_NONE(.fini)))
|
120 |
|
|
|
121 |
|
|
/* gcc uses crtbegin.o to find the start of
|
122 |
|
|
the constructors, so we make sure it is
|
123 |
|
|
first. Because this is a wildcard, it
|
124 |
|
|
doesn't matter if the user does not
|
125 |
|
|
actually link against crtbegin.o; the
|
126 |
|
|
linker won't look for a file to match a
|
127 |
|
|
wildcard. The wildcard also means that it
|
128 |
|
|
doesn't matter which directory crtbegin.o
|
129 |
|
|
is in. */
|
130 |
|
|
KEEP (*crtbegin.o(.ctors))
|
131 |
|
|
KEEP (*crtbegin?.o(.ctors))
|
132 |
|
|
/* We don't want to include the .ctor section from
|
133 |
|
|
the crtend.o file until after the sorted ctors.
|
134 |
|
|
The .ctor section from the crtend file contains the
|
135 |
|
|
end of ctors marker and it must be last */
|
136 |
|
|
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
|
137 |
|
|
KEEP (*(SORT(.ctors.*)))
|
138 |
|
|
KEEP (*(.ctors))
|
139 |
|
|
|
140 |
|
|
KEEP (*crtbegin.o(.dtors))
|
141 |
|
|
KEEP (*crtbegin?.o(.dtors))
|
142 |
|
|
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
|
143 |
|
|
KEEP (*(SORT(.dtors.*)))
|
144 |
|
|
KEEP (*(.dtors))
|
145 |
|
|
|
146 |
|
|
/* finish section on WORD boundary */
|
147 |
|
|
. = ALIGN(4);
|
148 |
|
|
|
149 |
|
|
PROVIDE (__etext = .);
|
150 |
|
|
PROVIDE (_etext = .);
|
151 |
|
|
PROVIDE (etext = .);
|
152 |
|
|
} > rom
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
/* read-only data, appended to text */
|
156 |
|
|
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
|
157 |
|
|
.rodata1 : { *(.rodata1) }
|
158 |
|
|
.rodata :
|
159 |
|
|
{
|
160 |
|
|
PROVIDE_HIDDEN (__init_array_start = .);
|
161 |
|
|
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
162 |
|
|
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
163 |
|
|
PROVIDE_HIDDEN (__init_array_end = .);
|
164 |
|
|
|
165 |
|
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
166 |
|
|
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
167 |
|
|
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
168 |
|
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
169 |
|
|
|
170 |
|
|
/* finish section on WORD boundary */
|
171 |
|
|
. = ALIGN(4);
|
172 |
|
|
} > rom
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
/* initialized read/write data, accessed in RAM, placed in ROM, copied during boot */
|
177 |
|
|
.jcr : { KEEP (*(.jcr)) }
|
178 |
|
|
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
|
179 |
|
|
.dynamic : { *(.dynamic) }
|
180 |
|
|
.data1 : { *(.data1) }
|
181 |
|
|
.got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
|
182 |
|
|
.data :
|
183 |
|
|
{
|
184 |
|
|
__DATA_BEGIN__ = .;
|
185 |
|
|
__SDATA_BEGIN__ = .;
|
186 |
|
|
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
187 |
|
|
|
188 |
|
|
*(.data .data.* .gnu.linkonce.d.*)
|
189 |
|
|
SORT(CONSTRUCTORS)
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
/* We want the small data sections together, so single-instruction offsets
|
193 |
|
|
can access them all, and initialized data all before uninitialized, so
|
194 |
|
|
we can shorten the on-disk segment size. */
|
195 |
|
|
|
196 |
|
|
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
|
197 |
|
|
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
198 |
|
|
|
199 |
|
|
PROVIDE_HIDDEN (__tdata_start = .);
|
200 |
|
|
*(.tdata .tdata.* .gnu.linkonce.td.*)
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
/* finish section on WORD boundary */
|
204 |
|
|
. = ALIGN(4);
|
205 |
|
|
|
206 |
|
|
_edata = .; PROVIDE (edata = .);
|
207 |
|
|
. = .;
|
208 |
|
|
|
209 |
|
|
} > ram AT > rom
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
/* zero/non-initialized read/write data placed in RAM */
|
214 |
|
|
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
|
215 |
|
|
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
|
216 |
|
|
.bss :
|
217 |
|
|
{
|
218 |
|
|
__bss_start = .;
|
219 |
|
|
*(.dynsbss)
|
220 |
|
|
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
221 |
|
|
*(.scommon)
|
222 |
|
|
|
223 |
|
|
*(.dynbss)
|
224 |
|
|
*(.bss .bss.* .gnu.linkonce.b.*)
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
228 |
|
|
KEEP (*(.preinit_array))
|
229 |
|
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
230 |
|
|
|
231 |
|
|
*(COMMON)
|
232 |
|
|
/* Align here to ensure that the .bss section occupies space up to
|
233 |
|
|
_end. Align after .bss to ensure correct alignment even if the
|
234 |
|
|
.bss section disappears because there are no input sections.
|
235 |
|
|
FIXME: Why do we need it? When there is no .bss section, we do not
|
236 |
|
|
pad the .data section. */
|
237 |
|
|
. = ALIGN(. != 0 ? 32 / 8 : 1);
|
238 |
|
|
|
239 |
|
|
. = ALIGN(32 / 8);
|
240 |
|
|
__BSS_END__ = .;
|
241 |
|
|
__global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800,
|
242 |
|
|
MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));
|
243 |
|
|
_end = .; PROVIDE (end = .);
|
244 |
|
|
} > ram
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
/* Stabs debugging sections. */
|
249 |
|
|
.stab 0 : { *(.stab) }
|
250 |
|
|
.stabstr 0 : { *(.stabstr) }
|
251 |
|
|
.stab.excl 0 : { *(.stab.excl) }
|
252 |
|
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
253 |
|
|
.stab.index 0 : { *(.stab.index) }
|
254 |
|
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
255 |
|
|
.comment 0 : { *(.comment) }
|
256 |
|
|
.gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
|
257 |
|
|
/* DWARF debug sections.
|
258 |
|
|
Symbols in the DWARF debugging sections are relative to the beginning
|
259 |
|
|
of the section so we begin them at 0. */
|
260 |
|
|
/* DWARF 1 */
|
261 |
|
|
.debug 0 : { *(.debug) }
|
262 |
|
|
.line 0 : { *(.line) }
|
263 |
|
|
/* GNU DWARF 1 extensions */
|
264 |
|
|
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
265 |
|
|
.debug_sfnames 0 : { *(.debug_sfnames) }
|
266 |
|
|
/* DWARF 1.1 and DWARF 2 */
|
267 |
|
|
.debug_aranges 0 : { *(.debug_aranges) }
|
268 |
|
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
269 |
|
|
/* DWARF 2 */
|
270 |
|
|
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
271 |
|
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
272 |
|
|
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
|
273 |
|
|
.debug_frame 0 : { *(.debug_frame) }
|
274 |
|
|
.debug_str 0 : { *(.debug_str) }
|
275 |
|
|
.debug_loc 0 : { *(.debug_loc) }
|
276 |
|
|
.debug_macinfo 0 : { *(.debug_macinfo) }
|
277 |
|
|
/* SGI/MIPS DWARF 2 extensions */
|
278 |
|
|
.debug_weaknames 0 : { *(.debug_weaknames) }
|
279 |
|
|
.debug_funcnames 0 : { *(.debug_funcnames) }
|
280 |
|
|
.debug_typenames 0 : { *(.debug_typenames) }
|
281 |
|
|
.debug_varnames 0 : { *(.debug_varnames) }
|
282 |
|
|
/* DWARF 3 */
|
283 |
|
|
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
284 |
|
|
.debug_ranges 0 : { *(.debug_ranges) }
|
285 |
|
|
/* DWARF Extension. */
|
286 |
|
|
.debug_macro 0 : { *(.debug_macro) }
|
287 |
|
|
.debug_addr 0 : { *(.debug_addr) }
|
288 |
|
|
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
|
289 |
|
|
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
/* Provide further symbols for neorv32 crt0.elf */
|
294 |
|
|
PROVIDE(__crt0_bss_start = __bss_start);
|
295 |
|
|
PROVIDE(__crt0_bss_end = __BSS_END__);
|
296 |
|
|
PROVIDE(__crt0_copy_data_src_begin = __etext + SIZEOF(.rodata));
|
297 |
|
|
PROVIDE(__crt0_copy_data_dst_begin = __DATA_BEGIN__);
|
298 |
|
|
PROVIDE(__crt0_copy_data_dst_end = __DATA_BEGIN__ + SIZEOF(.data));
|
299 |
|
|
}
|