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

Subversion Repositories neorv32

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

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 72 zero_gravi
/* # Copyright (c) 2022, 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 72 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 72 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 72 zero_gravi
/* 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 61 zero_gravi
 
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 72 zero_gravi
  /* default heap size: we can use up to 1/4 of available data memory (RAM) by default
79
   * WARNING! the heap will collide with the stack if allocating too much memory! */
80
  __heap_size = DEFINED(__heap_size) ? __heap_size : LENGTH(ram) / 4;
81 62 zero_gravi
 
82 72 zero_gravi
 
83
  /* First part of the actual executable file: actual instructions */
84 2 zero_gravi
  .text :
85
  {
86
    PROVIDE(__text_start = .);
87
    PROVIDE(__textstart = .);
88
 
89 72 zero_gravi
    KEEP(*(.text.crt0)); /* keep start-up code crt0 right at the beginning of rom */
90 2 zero_gravi
 
91
    *(.text.unlikely .text.*_unlikely .text.unlikely.*)
92
    *(.text.exit .text.exit.*)
93
    *(.text.startup .text.startup.*)
94
    *(.text.hot .text.hot.*)
95
    *(SORT(.text.sorted.*))
96
    *(.text .stub .text.* .gnu.linkonce.t.*)
97
    /* .gnu.warning sections are handled specially by elf.em.  */
98
    *(.gnu.warning)
99
 
100
    /* finish section on WORD boundary */
101
    . = ALIGN(4);
102
 
103
    PROVIDE (__etext = .);
104
    PROVIDE (_etext = .);
105
    PROVIDE (etext = .);
106
  } > rom
107
 
108
 
109 72 zero_gravi
  /* Second part of the actual executable: read-only data, placed right next to .text */
110 2 zero_gravi
  .rodata :
111
  {
112 72 zero_gravi
    /* these are a list of 32-bit pointers that point to functions
113
     * that are called before/after executing "main". */
114 2 zero_gravi
 
115
 
116 72 zero_gravi
    /* constructors are not supported by default. */
117
 
118
    /* __init_array_start = .;
119
     * KEEP (*(.preinit_array))
120
     * KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
121
     * KEEP (*(.rodata EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
122
     * __init_array_end = .;
123
     */
124
 
125
 
126
    /* main should never return, hence there is no default support for deconstructors!
127
     * however, if main return, the "after_main_handler" will be called by crt0, which can be used to implement
128
     * _minimal_ deconstructor support or to call __libc_fini_array is really really required. */
129
 
130
    /*
131
     * __fini_array_start = .;
132
     * KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
133
     * KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
134
     * __fini_array_end = .;
135
     */
136
 
137
 
138
    /* constant data like strings */
139
 
140 62 zero_gravi
    *(.rodata .rodata.* .gnu.linkonce.r.*)
141
    *(.rodata1)
142
 
143 72 zero_gravi
 
144 2 zero_gravi
    /* finish section on WORD boundary */
145
    . = ALIGN(4);
146
  } > rom
147
 
148
 
149 72 zero_gravi
  /* initialized read/write data, accessed in RAM, placed in ROM, copied during boot
150
   * not part of the final executable */
151 2 zero_gravi
  .data :
152
  {
153
    __DATA_BEGIN__ = .;
154
    __SDATA_BEGIN__ = .;
155
    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
156 62 zero_gravi
    *(.data1)
157 2 zero_gravi
    *(.data .data.* .gnu.linkonce.d.*)
158
    SORT(CONSTRUCTORS)
159
 
160 62 zero_gravi
    *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
161
    *(.dynamic)
162
 
163 2 zero_gravi
    /* We want the small data sections together, so single-instruction offsets
164
       can access them all, and initialized data all before uninitialized, so
165
       we can shorten the on-disk segment size.  */
166
 
167
    *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
168
    *(.sdata .sdata.* .gnu.linkonce.s.*)
169
 
170 72 zero_gravi
    PROVIDE_HIDDEN (__tdata_start = .);
171
    *(.tdata .tdata.* .gnu.linkonce.td.*)
172 2 zero_gravi
 
173
 
174
    /* finish section on WORD boundary */
175
    . = ALIGN(4);
176
 
177
    _edata = .; PROVIDE (edata = .);
178
    . = .;
179 72 zero_gravi
    __DATA_END__ = .;
180
    __global_pointer$ = __DATA_END__ + 0x800;
181 2 zero_gravi
 
182
  } > ram AT > rom
183
 
184
 
185 72 zero_gravi
  /* zero/non-initialized read/write data placed in RAM - not part of the final executable */
186 21 zero_gravi
  .bss (NOLOAD):
187 2 zero_gravi
  {
188 72 zero_gravi
    . = ALIGN(4);
189
    __BSS_START__ = .;
190 2 zero_gravi
    *(.dynsbss)
191
    *(.sbss .sbss.* .gnu.linkonce.sb.*)
192 62 zero_gravi
    *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
193
    *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
194 2 zero_gravi
    *(.scommon)
195
    *(.dynbss)
196
    *(.bss .bss.* .gnu.linkonce.b.*)
197
 
198
    PROVIDE_HIDDEN (__preinit_array_start = .);
199
    KEEP (*(.preinit_array))
200
    PROVIDE_HIDDEN (__preinit_array_end = .);
201
 
202
    *(COMMON)
203
    /* Align here to ensure that the .bss section occupies space up to
204
       _end.  Align after .bss to ensure correct alignment even if the
205
       .bss section disappears because there are no input sections.
206
       FIXME: Why do we need it? When there is no .bss section, we do not
207
       pad the .data section.  */
208
    . = ALIGN(. != 0 ? 32 / 8 : 1);
209
 
210 72 zero_gravi
    . = ALIGN(4);
211 2 zero_gravi
    __BSS_END__ = .;
212
    _end = .; PROVIDE (end = .);
213
  } > ram
214
 
215
 
216 72 zero_gravi
  /* heap for dynamic memory allocation (use carefully!) -  not part of the final executable */
217
  .heap :
218
  {
219
    PROVIDE(__heap_start = .);
220
    . = __heap_size;
221
    PROVIDE(__heap_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 72 zero_gravi
  /* Export symbols for neorv32 crt0 start-up code */
299
  PROVIDE(__crt0_imem_begin          = ORIGIN(rom));
300
  PROVIDE(__crt0_dmem_begin          = ORIGIN(ram));
301 62 zero_gravi
  PROVIDE(__crt0_stack_begin         = (ORIGIN(ram) + LENGTH(ram)) - 4);
302 72 zero_gravi
  PROVIDE(__crt0_bss_start           = __BSS_START__);
303 62 zero_gravi
  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 72 zero_gravi
  PROVIDE(__crt0_io_space_begin      = ORIGIN(iodev));
308
  PROVIDE(__crt0_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.