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

Subversion Repositories neorv32

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

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

powered by: WebSVN 2.1.0

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