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

Subversion Repositories neorv32

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

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

powered by: WebSVN 2.1.0

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