OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [common/] [neorv32.ld] - Blame information for rev 58

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zero_gravi
/* ################################################################################################# */
2
/* # << NEORV32 - RISC-V GCC Linker Script >>                                                      # */
3
/* # ********************************************************************************************* # */
4
/* # BSD 3-Clause License                                                                          # */
5
/* #                                                                                               # */
6 58 zero_gravi
/* # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     # */
7 2 zero_gravi
/* #                                                                                               # */
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 36 zero_gravi
SEARCH_DIR("/opt/riscv/riscv32-unknown-elf/lib"); SEARCH_DIR("=/opt/riscv/riscv64-unknown-linux-gnu/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
48 2 zero_gravi
 
49 23 zero_gravi
/* ************************************************************************* */
50
/* NEORV32 memory configuration.                                             */
51 58 zero_gravi
/* Make sure this is sync with your processor/memory hardware configuration! */
52 23 zero_gravi
/* ************************************************************************* */
53 58 zero_gravi
/* "rom"   : instruction memory (IMEM) / bootloader ROM                      */
54
/* "ram"   : data memory (DMEM)                                              */
55
/* "iodev" : peripheral/IO devices (not used here; passed to crt0)           */
56
/* ************************************************************************* */
57 2 zero_gravi
MEMORY
58
{
59 58 zero_gravi
/* "rom" section: first value of ORIGIN/LENGTH => bootloader ROM; second value of ORIGIN/LENGTH => instruction memory */
60 23 zero_gravi
 
61 58 zero_gravi
  rom  (rx)  : ORIGIN = DEFINED(make_bootloader) ? 0xFFFF0000 : 0x00000000, LENGTH = DEFINED(make_bootloader) ? 4*1024 : 16*1024
62
  ram (rwx)  : ORIGIN = 0x80000000, LENGTH = 8*1024
63
  iodev (rw) : ORIGIN = 0xFFFFFF00, LENGTH = 256
64
 
65 2 zero_gravi
}
66 23 zero_gravi
/* ************************************************************************* */
67 2 zero_gravi
 
68
SECTIONS
69
{
70 23 zero_gravi
  /* stack pointer init: last 32-bit entry in data memory */
71
  __crt0_stack_begin = (ORIGIN(ram) + LENGTH(ram)) - 4;
72 2 zero_gravi
 
73
  /* start section on WORD boundary */
74
  . = ALIGN(4);
75
 
76
  .interp         : { *(.interp) }
77
  .note.gnu.build-id  : { *(.note.gnu.build-id) }
78
  .hash           : { *(.hash) }
79
  .gnu.hash       : { *(.gnu.hash) }
80
  .dynsym         : { *(.dynsym) }
81
  .dynstr         : { *(.dynstr) }
82
  .gnu.version    : { *(.gnu.version) }
83
  .gnu.version_d  : { *(.gnu.version_d) }
84
  .gnu.version_r  : { *(.gnu.version_r) }
85
  .rela.init      : { *(.rela.init) }
86
  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
87
  .rela.fini      : { *(.rela.fini) }
88
  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
89
  .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
90
  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
91
  .rela.tdata     : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
92
  .rela.tbss      : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
93
  .rela.ctors     : { *(.rela.ctors) }
94
  .rela.dtors     : { *(.rela.dtors) }
95
  .rela.got       : { *(.rela.got) }
96
  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
97
  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
98
  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
99
  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
100
  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
101
  /* Actual instructions */
102
  .text :
103
  {
104
    PROVIDE(__text_start = .);
105
    PROVIDE(__textstart = .);
106
 
107
    PROVIDE_HIDDEN (__rela_iplt_start = .);
108
    *(.rela.iplt)
109
    PROVIDE_HIDDEN (__rela_iplt_end = .);
110
 
111
    *(.rela.plt)
112
 
113 22 zero_gravi
    KEEP(*(.text.boot)); /* keep start-up code at the beginning of rom */
114 21 zero_gravi
 
115 2 zero_gravi
    KEEP (*(SORT_NONE(.init)))
116
 
117
    *(.text.unlikely .text.*_unlikely .text.unlikely.*)
118
    *(.text.exit .text.exit.*)
119
    *(.text.startup .text.startup.*)
120
    *(.text.hot .text.hot.*)
121
    *(SORT(.text.sorted.*))
122
    *(.text .stub .text.* .gnu.linkonce.t.*)
123
    /* .gnu.warning sections are handled specially by elf.em.  */
124
    *(.gnu.warning)
125
 
126
    KEEP (*(SORT_NONE(.fini)))
127
 
128
    /* gcc uses crtbegin.o to find the start of
129
       the constructors, so we make sure it is
130
       first.  Because this is a wildcard, it
131
       doesn't matter if the user does not
132
       actually link against crtbegin.o; the
133
       linker won't look for a file to match a
134
       wildcard.  The wildcard also means that it
135
       doesn't matter which directory crtbegin.o
136
       is in.  */
137
    KEEP (*crtbegin.o(.ctors))
138
    KEEP (*crtbegin?.o(.ctors))
139
    /* We don't want to include the .ctor section from
140
       the crtend.o file until after the sorted ctors.
141
       The .ctor section from the crtend file contains the
142
       end of ctors marker and it must be last */
143
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
144
    KEEP (*(SORT(.ctors.*)))
145
    KEEP (*(.ctors))
146
 
147
    KEEP (*crtbegin.o(.dtors))
148
    KEEP (*crtbegin?.o(.dtors))
149
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
150
    KEEP (*(SORT(.dtors.*)))
151
    KEEP (*(.dtors))
152
 
153
    /* finish section on WORD boundary */
154
    . = ALIGN(4);
155
 
156
    PROVIDE (__etext = .);
157
    PROVIDE (_etext = .);
158
    PROVIDE (etext = .);
159
  } > rom
160
 
161
 
162
  /* read-only data, appended to text */
163
  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
164
  .rodata1        : { *(.rodata1) }
165
  .rodata :
166
  {
167
    PROVIDE_HIDDEN (__init_array_start = .);
168
    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
169
    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
170
    PROVIDE_HIDDEN (__init_array_end = .);
171
 
172
    PROVIDE_HIDDEN (__fini_array_start = .);
173
    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
174
    KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
175
    PROVIDE_HIDDEN (__fini_array_end = .);
176
 
177
    /* finish section on WORD boundary */
178
    . = ALIGN(4);
179
  } > rom
180
 
181
 
182
  /* initialized read/write data, accessed in RAM, placed in ROM, copied during boot */
183
  .jcr            : { KEEP (*(.jcr)) }
184
  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
185
  .dynamic        : { *(.dynamic) }
186
  .data1          : { *(.data1) }
187
  .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
188
  .data :
189
  {
190
    __DATA_BEGIN__ = .;
191
    __SDATA_BEGIN__ = .;
192
    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
193
 
194
    *(.data .data.* .gnu.linkonce.d.*)
195
    SORT(CONSTRUCTORS)
196
 
197
    /* We want the small data sections together, so single-instruction offsets
198
       can access them all, and initialized data all before uninitialized, so
199
       we can shorten the on-disk segment size.  */
200
 
201
    *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
202
    *(.sdata .sdata.* .gnu.linkonce.s.*)
203
 
204
     PROVIDE_HIDDEN (__tdata_start = .);
205
     *(.tdata .tdata.* .gnu.linkonce.td.*)
206
 
207
 
208
    /* finish section on WORD boundary */
209
    . = ALIGN(4);
210
 
211
    _edata = .; PROVIDE (edata = .);
212
    . = .;
213
 
214
  } > ram AT > rom
215
 
216
 
217
  /* zero/non-initialized read/write data placed in RAM */
218
  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
219
  .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
220 21 zero_gravi
  .bss (NOLOAD):
221 2 zero_gravi
  {
222
    __bss_start = .;
223
    *(.dynsbss)
224
    *(.sbss .sbss.* .gnu.linkonce.sb.*)
225
    *(.scommon)
226
 
227
    *(.dynbss)
228
    *(.bss .bss.* .gnu.linkonce.b.*)
229
 
230
    PROVIDE_HIDDEN (__preinit_array_start = .);
231
    KEEP (*(.preinit_array))
232
    PROVIDE_HIDDEN (__preinit_array_end = .);
233
 
234
    *(COMMON)
235
    /* Align here to ensure that the .bss section occupies space up to
236
       _end.  Align after .bss to ensure correct alignment even if the
237
       .bss section disappears because there are no input sections.
238
       FIXME: Why do we need it? When there is no .bss section, we do not
239
       pad the .data section.  */
240
    . = ALIGN(. != 0 ? 32 / 8 : 1);
241
 
242
    . = ALIGN(32 / 8);
243
    __BSS_END__ = .;
244
    __global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800,
245
                            MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));
246
    _end = .; PROVIDE (end = .);
247
  } > ram
248
 
249
 
250
  /* Stabs debugging sections.  */
251
  .stab          0 : { *(.stab) }
252
  .stabstr       0 : { *(.stabstr) }
253
  .stab.excl     0 : { *(.stab.excl) }
254
  .stab.exclstr  0 : { *(.stab.exclstr) }
255
  .stab.index    0 : { *(.stab.index) }
256
  .stab.indexstr 0 : { *(.stab.indexstr) }
257
  .comment       0 : { *(.comment) }
258
  .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
259
  /* DWARF debug sections.
260
     Symbols in the DWARF debugging sections are relative to the beginning
261
     of the section so we begin them at 0.  */
262
  /* DWARF 1 */
263
  .debug          0 : { *(.debug) }
264
  .line           0 : { *(.line) }
265
  /* GNU DWARF 1 extensions */
266
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
267
  .debug_sfnames  0 : { *(.debug_sfnames) }
268
  /* DWARF 1.1 and DWARF 2 */
269
  .debug_aranges  0 : { *(.debug_aranges) }
270
  .debug_pubnames 0 : { *(.debug_pubnames) }
271
  /* DWARF 2 */
272
  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
273
  .debug_abbrev   0 : { *(.debug_abbrev) }
274
  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end) }
275
  .debug_frame    0 : { *(.debug_frame) }
276
  .debug_str      0 : { *(.debug_str) }
277
  .debug_loc      0 : { *(.debug_loc) }
278
  .debug_macinfo  0 : { *(.debug_macinfo) }
279
  /* SGI/MIPS DWARF 2 extensions */
280
  .debug_weaknames 0 : { *(.debug_weaknames) }
281
  .debug_funcnames 0 : { *(.debug_funcnames) }
282
  .debug_typenames 0 : { *(.debug_typenames) }
283
  .debug_varnames  0 : { *(.debug_varnames) }
284
  /* DWARF 3 */
285
  .debug_pubtypes 0 : { *(.debug_pubtypes) }
286
  .debug_ranges   0 : { *(.debug_ranges) }
287
  /* DWARF Extension.  */
288
  .debug_macro    0 : { *(.debug_macro) }
289
  .debug_addr     0 : { *(.debug_addr) }
290
  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
291
  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
292
 
293
 
294 58 zero_gravi
  /* Provide further symbols for neorv32 crt0 */
295 23 zero_gravi
  PROVIDE(__crt0_bss_start   = __bss_start);
296
  PROVIDE(__crt0_bss_end     = __BSS_END__);
297 2 zero_gravi
  PROVIDE(__crt0_copy_data_src_begin = __etext + SIZEOF(.rodata));
298
  PROVIDE(__crt0_copy_data_dst_begin = __DATA_BEGIN__);
299
  PROVIDE(__crt0_copy_data_dst_end   = __DATA_BEGIN__ + SIZEOF(.data));
300 58 zero_gravi
  PROVIDE(__ctr0_io_space_begin = ORIGIN(iodev));
301
  PROVIDE(__ctr0_io_space_end   = ORIGIN(iodev) + LENGTH(iodev));
302 2 zero_gravi
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.