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

Subversion Repositories neorv32

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

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

powered by: WebSVN 2.1.0

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