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

Subversion Repositories neorv32

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

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

powered by: WebSVN 2.1.0

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