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

Subversion Repositories neorv32

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

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 14 zero_gravi
  rom  (rx) : ORIGIN = 0x00000000, LENGTH = 16*1024
57
  ram (rwx) : ORIGIN = 0x80000000, LENGTH =  8*1024
58 2 zero_gravi
}
59
/* ************************************************* */
60
 
61
SECTIONS
62
{
63
 
64
  /* start section on WORD boundary */
65
  . = ALIGN(4);
66
 
67
  .interp         : { *(.interp) }
68
  .note.gnu.build-id  : { *(.note.gnu.build-id) }
69
  .hash           : { *(.hash) }
70
  .gnu.hash       : { *(.gnu.hash) }
71
  .dynsym         : { *(.dynsym) }
72
  .dynstr         : { *(.dynstr) }
73
  .gnu.version    : { *(.gnu.version) }
74
  .gnu.version_d  : { *(.gnu.version_d) }
75
  .gnu.version_r  : { *(.gnu.version_r) }
76
  .rela.init      : { *(.rela.init) }
77
  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
78
  .rela.fini      : { *(.rela.fini) }
79
  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
80
  .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
81
  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
82
  .rela.tdata     : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
83
  .rela.tbss      : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
84
  .rela.ctors     : { *(.rela.ctors) }
85
  .rela.dtors     : { *(.rela.dtors) }
86
  .rela.got       : { *(.rela.got) }
87
  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
88
  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
89
  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
90
  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
91
  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
92
  /* Actual instructions */
93
  .text :
94
  {
95
    PROVIDE(__text_start = .);
96
    PROVIDE(__textstart = .);
97
 
98
 
99
 
100
    PROVIDE_HIDDEN (__rela_iplt_start = .);
101
    *(.rela.iplt)
102
    PROVIDE_HIDDEN (__rela_iplt_end = .);
103
 
104
    *(.rela.plt)
105
 
106
    KEEP (*(SORT_NONE(.init)))
107
 
108
    KEEP(crt0.elf(.text)); /* NEORV32-SPECIFIC start-up code */
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
 
175
  /* initialized read/write data, accessed in RAM, placed in ROM, copied during boot */
176
  .jcr            : { KEEP (*(.jcr)) }
177
  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
178
  .dynamic        : { *(.dynamic) }
179
  .data1          : { *(.data1) }
180
  .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
181
  .data :
182
  {
183
    __DATA_BEGIN__ = .;
184
    __SDATA_BEGIN__ = .;
185
    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
186
 
187
    *(.data .data.* .gnu.linkonce.d.*)
188
    SORT(CONSTRUCTORS)
189
 
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
 
212
  /* zero/non-initialized read/write data placed in RAM */
213
  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
214
  .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
215
  .bss :
216
  {
217
    __bss_start = .;
218
    *(.dynsbss)
219
    *(.sbss .sbss.* .gnu.linkonce.sb.*)
220
    *(.scommon)
221
 
222
    *(.dynbss)
223
    *(.bss .bss.* .gnu.linkonce.b.*)
224
 
225
 
226
    PROVIDE_HIDDEN (__preinit_array_start = .);
227
    KEEP (*(.preinit_array))
228
    PROVIDE_HIDDEN (__preinit_array_end = .);
229
 
230
    *(COMMON)
231
    /* Align here to ensure that the .bss section occupies space up to
232
       _end.  Align after .bss to ensure correct alignment even if the
233
       .bss section disappears because there are no input sections.
234
       FIXME: Why do we need it? When there is no .bss section, we do not
235
       pad the .data section.  */
236
    . = ALIGN(. != 0 ? 32 / 8 : 1);
237
 
238
    . = ALIGN(32 / 8);
239
    __BSS_END__ = .;
240
    __global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800,
241
                            MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));
242
    _end = .; PROVIDE (end = .);
243
  } > ram
244
 
245
 
246
 
247
  /* Stabs debugging sections.  */
248
  .stab          0 : { *(.stab) }
249
  .stabstr       0 : { *(.stabstr) }
250
  .stab.excl     0 : { *(.stab.excl) }
251
  .stab.exclstr  0 : { *(.stab.exclstr) }
252
  .stab.index    0 : { *(.stab.index) }
253
  .stab.indexstr 0 : { *(.stab.indexstr) }
254
  .comment       0 : { *(.comment) }
255
  .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
256
  /* DWARF debug sections.
257
     Symbols in the DWARF debugging sections are relative to the beginning
258
     of the section so we begin them at 0.  */
259
  /* DWARF 1 */
260
  .debug          0 : { *(.debug) }
261
  .line           0 : { *(.line) }
262
  /* GNU DWARF 1 extensions */
263
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
264
  .debug_sfnames  0 : { *(.debug_sfnames) }
265
  /* DWARF 1.1 and DWARF 2 */
266
  .debug_aranges  0 : { *(.debug_aranges) }
267
  .debug_pubnames 0 : { *(.debug_pubnames) }
268
  /* DWARF 2 */
269
  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
270
  .debug_abbrev   0 : { *(.debug_abbrev) }
271
  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end) }
272
  .debug_frame    0 : { *(.debug_frame) }
273
  .debug_str      0 : { *(.debug_str) }
274
  .debug_loc      0 : { *(.debug_loc) }
275
  .debug_macinfo  0 : { *(.debug_macinfo) }
276
  /* SGI/MIPS DWARF 2 extensions */
277
  .debug_weaknames 0 : { *(.debug_weaknames) }
278
  .debug_funcnames 0 : { *(.debug_funcnames) }
279
  .debug_typenames 0 : { *(.debug_typenames) }
280
  .debug_varnames  0 : { *(.debug_varnames) }
281
  /* DWARF 3 */
282
  .debug_pubtypes 0 : { *(.debug_pubtypes) }
283
  .debug_ranges   0 : { *(.debug_ranges) }
284
  /* DWARF Extension.  */
285
  .debug_macro    0 : { *(.debug_macro) }
286
  .debug_addr     0 : { *(.debug_addr) }
287
  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
288
  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
289
 
290
 
291
 
292
  /* Provide further symbols for neorv32 crt0.elf */
293
  PROVIDE(__crt0_bss_start = __bss_start);
294
  PROVIDE(__crt0_bss_end   = __BSS_END__);
295
  PROVIDE(__crt0_copy_data_src_begin = __etext + SIZEOF(.rodata));
296
  PROVIDE(__crt0_copy_data_dst_begin = __DATA_BEGIN__);
297
  PROVIDE(__crt0_copy_data_dst_end   = __DATA_BEGIN__ + SIZEOF(.data));
298
}

powered by: WebSVN 2.1.0

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