]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/epiphany_4x4.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / epiphany_4x4.sc
CommitLineData
250d07de 1# Copyright (C) 2014-2021 Free Software Foundation, Inc.
6c19b93b 2#
985743c7
NC
3# Copying and distribution of this file, with or without modification,
4# are permitted in any medium without royalty provided the copyright
5# notice and this notice are preserved.
f204ddb8
JR
6#
7# Unusual variables checked by this code:
8# NOP - four byte opcode for no-op (defaults to 0)
9# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
10# empty.
11# SMALL_DATA_CTOR - .ctors contains small data.
12# SMALL_DATA_DTOR - .dtors contains small data.
13# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
14# INITIAL_READONLY_SECTIONS - at start of text segment
15# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
16# (e.g., .PARISC.milli)
17# OTHER_TEXT_SECTIONS - these get put in .text when relocating
18# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
19# (e.g., .PARISC.global)
20# OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
21# (e.g. PPC32 .fixup, .got[12])
22# OTHER_BSS_SECTIONS - other than .bss .sbss ...
23# ATTRS_SECTIONS - at the end
24# OTHER_SECTIONS - at the end
25# EXECUTABLE_SYMBOLS - symbols that must be defined for an
26# executable (e.g., _DYNAMIC_LINK)
27# TEXT_START_ADDR - the first byte of the text segment, after any
28# headers.
29# TEXT_BASE_ADDRESS - the first byte of the text segment.
30# TEXT_START_SYMBOLS - symbols that appear at the start of the
31# .text section.
32# DATA_START_SYMBOLS - symbols that appear at the start of the
33# .data section.
34# DATA_END_SYMBOLS - symbols that appear at the end of the
35# writeable data sections.
36# OTHER_GOT_SYMBOLS - symbols defined just before .got.
37# OTHER_GOT_SECTIONS - sections just after .got.
38# OTHER_SDATA_SECTIONS - sections just after .sdata.
39# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
40# .bss section besides ___bss_start.
41# DATA_PLT - .plt should be in data segment, not text segment.
42# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
43# BSS_PLT - .plt should be in bss segment
44# NO_REL_RELOCS - Don't include .rel.* sections in script
45# NO_RELA_RELOCS - Don't include .rela.* sections in script
46# NON_ALLOC_DYN - Place dynamic sections after data segment.
47# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
6c19b93b 48# EMBEDDED - whether this is for an embedded system.
f204ddb8
JR
49# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
50# start address of shared library.
51# INPUT_FILES - INPUT command of files to always include
52# WRITABLE_RODATA - if set, the .rodata section should be writable
53# INIT_START, INIT_END - statements just before and just after
6c19b93b 54# combination of .init sections.
f204ddb8 55# FINI_START, FINI_END - statements just before and just after
6c19b93b 56# combination of .fini sections.
f204ddb8
JR
57# OTHER_SYMBOLS - symbols to place right at the end of the script.
58# ETEXT_NAME - name of a symbol for the end of the text section,
59# normally etext.
60# SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
61# so that .got can be in the RELRO area. It should be set to
62# the number of bytes in the beginning of .got.plt which can be
63# in the RELRO area as well.
64# USER_LABEL_PREFIX - prefix to add to user-visible symbols.
65#
66# When adding sections, do note that the names of some sections are used
67# when specifying the start address of the next.
68#
69
70# Many sections come in three flavours. There is the 'real' section,
71# like ".data". Then there are the per-procedure or per-variable
72# sections, generated by -ffunction-sections and -fdata-sections in GCC,
73# and useful for --gc-sections, which for a variable "foo" might be
74# ".data.foo". Then there are the linkonce sections, for which the linker
75# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
76# The exact correspondences are:
77#
78# Section Linkonce section
79# .text .gnu.linkonce.t.foo
80# .rodata .gnu.linkonce.r.foo
81# .data .gnu.linkonce.d.foo
82# .bss .gnu.linkonce.b.foo
83# .sdata .gnu.linkonce.s.foo
84# .sbss .gnu.linkonce.sb.foo
85# .sdata2 .gnu.linkonce.s2.foo
86# .sbss2 .gnu.linkonce.sb2.foo
87# .debug_info .gnu.linkonce.wi.foo
88# .tdata .gnu.linkonce.td.foo
89# .tbss .gnu.linkonce.tb.foo
90# .lrodata .gnu.linkonce.lr.foo
91# .ldata .gnu.linkonce.l.foo
92# .lbss .gnu.linkonce.lb.foo
93#
94# Each of these can also have corresponding .rel.* and .rela.* sections.
95
96
97test -z "$ENTRY" && ENTRY=_start
98test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
99test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
100if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
101test -z "${ELFSIZE}" && ELFSIZE=32
102test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
103test "$LD_FLAG" = "N" && DATA_ADDR=.
104test -z "${ETEXT_NAME}" && ETEXT_NAME=etext
105test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
106test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
107test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
108test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
109DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
110DATA_SEGMENT_RELRO_END=""
111DATA_SEGMENT_END=""
112if test -n "${COMMONPAGESIZE}"; then
113 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
114 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
115 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
116fi
117if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
118 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
119fi
120if test -z "$PLT"; then
121 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
122fi
123test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
124if test -z "$GOT"; then
125 if test -z "$SEPARATE_GOTPLT"; then
2bf2bf23 126 GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }"
f204ddb8
JR
127 else
128 GOT=".got ${RELOCATING-0} : { *(.got) }"
129 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }"
130 fi
131fi
132DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
133RODATA=".rodata ${RELOCATING+ADDR(.data)+SIZEOF(.data)} ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) } /*> INTERNAL_RAM*/"
134DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
135DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }"
136if test -z "${NO_SMALL_DATA}"; then
137 SBSS=".sbss ${RELOCATING-0} :
138 {
139 ${RELOCATING+${SBSS_START_SYMBOLS}}
140 ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
2bf2bf23 141 ${RELOCATING+*(.dynsbss)}
f204ddb8 142 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
2bf2bf23 143 ${RELOCATING+*(.scommon)}
f204ddb8
JR
144 ${RELOCATING+${SBSS_END_SYMBOLS}}
145 }"
146 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
147 SDATA="/* We want the small data sections together, so single-instruction offsets
148 can access them all, and initialized data all before uninitialized, so
149 we can shorten the on-disk segment size. */
6c19b93b 150 .sdata ${RELOCATING-0} :
f204ddb8
JR
151 {
152 ${RELOCATING+${SDATA_START_SYMBOLS}}
2bf2bf23 153 ${RELOCATING+${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}}
f204ddb8
JR
154 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
155 }"
156 SDATA2=".sdata2 ${RELOCATING-0} :
157 {
158 ${RELOCATING+${SDATA2_START_SYMBOLS}}
159 *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
160 }"
161 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
162 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
163 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
164 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
165 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
166 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
167 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
168 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
169else
170 NO_SMALL_DATA=" "
171fi
172if test -z "${DATA_GOT}"; then
173 if test -n "${NO_SMALL_DATA}"; then
174 DATA_GOT=" "
175 fi
176fi
177if test -z "${SDATA_GOT}"; then
178 if test -z "${NO_SMALL_DATA}"; then
179 SDATA_GOT=" "
180 fi
181fi
182test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
183test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
184 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
185 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
186 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
187 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
188 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
189 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
190test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
191 ${OTHER_BSS_SECTIONS}
192 .lbss ${RELOCATING-0} :
193 {
2bf2bf23 194 ${RELOCATING+*(.dynlbss)}
f204ddb8 195 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
2bf2bf23 196 ${RELOCATING+*(LARGE_COMMON)}
f204ddb8
JR
197 }"
198test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
199 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
200 {
201 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
202 }
203 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
204 {
205 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
206 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
207 }"
6c19b93b 208CTOR=".ctors ADDR(.text) + SIZEOF(.text) ${CONSTRUCTING-0} :
f204ddb8
JR
209 {
210 ${CONSTRUCTING+${CTOR_START}}
211 /* gcc uses crtbegin.o to find the start of
212 the constructors, so we make sure it is
213 first. Because this is a wildcard, it
214 doesn't matter if the user does not
215 actually link against crtbegin.o; the
216 linker won't look for a file to match a
217 wildcard. The wildcard also means that it
218 doesn't matter which directory crtbegin.o
219 is in. */
220
221 KEEP (*crtbegin.o(.ctors))
222 KEEP (*crtbegin?.o(.ctors))
223
224 /* We don't want to include the .ctor section from
225 the crtend.o file until after the sorted ctors.
226 The .ctor section from the crtend file contains the
227 end of ctors marker and it must be last */
228
229 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
230 KEEP (*(SORT(.ctors.*)))
231 KEEP (*(.ctors))
232 ${CONSTRUCTING+${CTOR_END}}
6c19b93b 233 } /*> INTERNAL_RAM*/"
f204ddb8
JR
234DTOR=".dtors ADDR(.ctors) + SIZEOF(.ctors) ${CONSTRUCTING-0} :
235 {
236 ${CONSTRUCTING+${DTOR_START}}
237 KEEP (*crtbegin.o(.dtors))
238 KEEP (*crtbegin?.o(.dtors))
239 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
240 KEEP (*(SORT(.dtors.*)))
241 KEEP (*(.dtors))
242 ${CONSTRUCTING+${DTOR_END}}
243 } /*> INTERNAL_RAM*/ "
f204ddb8 244
985743c7 245# If this is for an embedded system, don't add SIZEOF_HEADERS.
f204ddb8
JR
246if [ -z "$EMBEDDED" ]; then
247 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
248else
249 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
250fi
251
252cat <<EOF
250d07de 253/* Copyright (C) 2014-2021 Free Software Foundation, Inc.
985743c7
NC
254
255 Copying and distribution of this script, with or without modification,
256 are permitted in any medium without royalty provided the copyright
257 notice and this notice are preserved. */
f204ddb8
JR
258
259OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
260 "${LITTLE_OUTPUT_FORMAT}")
261OUTPUT_ARCH(${OUTPUT_ARCH})
2bf2bf23 262EOF
f204ddb8 263
2bf2bf23
AM
264test -n "${RELOCATING}" && cat <<EOF
265ENTRY(${ENTRY})
f204ddb8 266
2bf2bf23
AM
267${EXECUTABLE_SYMBOLS}
268${INPUT_FILES}
f204ddb8
JR
269
270/* BSP specific*/
271__PROG_SIZE_FOR_CORE__ = 1M;
272__HEAP_SIZE_FOR_CORE__ = 1M;
273
274__MAX_NUM_CORES_IN_ROWS__ = 4;
275__MAX_NUM_CORES_IN_COLS__ = 4;
276
277__FIRST_CORE_ROW_ = 0x20;
278__FIRST_CORE_COL_ = 0x24;
279
280
281
282PROVIDE (__CORE_ROW_ = __FIRST_CORE_ROW_);
283PROVIDE (__CORE_COL_ = __FIRST_CORE_COL_);
2bf2bf23
AM
284/* generic do not touch */
285/* used to calculated the slice address in the external memory */
f204ddb8
JR
286__CORE_NUM_ = (__CORE_ROW_ - __FIRST_CORE_ROW_ )* __MAX_NUM_CORES_IN_COLS__ + (__CORE_COL_ - __FIRST_CORE_COL_ ) ;
287
288
289MEMORY
290 {
6c19b93b 291 EXTERNAL_DRAM_0 (WXAI) : ORIGIN = 0x80000000, LENGTH = 0x1000000 /*.text, data, rodata, bss and .stack*/
f204ddb8 292 EXTERNAL_DRAM_1 (WXAI) : ORIGIN = 0x81000000, LENGTH = 0x1000000 /*.heap */
6c19b93b 293
f204ddb8 294 EXTERNAL_SRAM (WXAI) : ORIGIN = 0x92000000, LENGTH = 8K /* small external RAM, used for testing*/
6c19b93b 295
f204ddb8
JR
296 /* run time lib and crt0*/
297 RESERVED_CRT0_RAM (WXAI) : ORIGIN = 0, LENGTH = 0x400
6c19b93b 298
f204ddb8
JR
299 /* user program, per bank usage */
300 BANK0_SRAM (WXAI) : ORIGIN = LENGTH(RESERVED_CRT0_RAM), LENGTH = 8K - LENGTH(RESERVED_CRT0_RAM)
301 BANK1_SRAM (WXAI) : ORIGIN = 0x2000, LENGTH = 8K
302 BANK2_SRAM (WXAI) : ORIGIN = 0x4000, LENGTH = 8K
303 BANK3_SRAM (WXAI) : ORIGIN = 0x6000, LENGTH = 8K
6c19b93b 304
f204ddb8
JR
305 /* user program, continious placement */
306 INTERNAL_RAM (WXAI) : ORIGIN = LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K - LENGTH(RESERVED_CRT0_RAM)
6c19b93b
AM
307
308 MMR (WAI) : ORIGIN = 0xF000, LENGTH = 32K
309
310 /* multi cores space */
f204ddb8
JR
311 CORE_0x20_0x24_INTERNAL_RAM : ORIGIN = 0x82400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
312 CORE_0x20_0x25_INTERNAL_RAM : ORIGIN = 0x82500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
313 CORE_0x20_0x26_INTERNAL_RAM : ORIGIN = 0x82600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
314 CORE_0x20_0x27_INTERNAL_RAM : ORIGIN = 0x82700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
315 CORE_0x21_0x24_INTERNAL_RAM : ORIGIN = 0x86400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
316 CORE_0x21_0x25_INTERNAL_RAM : ORIGIN = 0x86500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
317 CORE_0x21_0x26_INTERNAL_RAM : ORIGIN = 0x86600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
318 CORE_0x21_0x27_INTERNAL_RAM : ORIGIN = 0x86700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
319 CORE_0x22_0x24_INTERNAL_RAM : ORIGIN = 0x8a400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
320 CORE_0x22_0x25_INTERNAL_RAM : ORIGIN = 0x8a500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
321 CORE_0x22_0x26_INTERNAL_RAM : ORIGIN = 0x8a600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
322 CORE_0x22_0x27_INTERNAL_RAM : ORIGIN = 0x8a700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
323 CORE_0x23_0x24_INTERNAL_RAM : ORIGIN = 0x8e400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
324 CORE_0x23_0x25_INTERNAL_RAM : ORIGIN = 0x8e500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
325 CORE_0x23_0x26_INTERNAL_RAM : ORIGIN = 0x8e600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
326 CORE_0x23_0x27_INTERNAL_RAM : ORIGIN = 0x8e700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
327 CORE_0x24_0x24_INTERNAL_RAM : ORIGIN = 0x82000000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
6c19b93b 328
f204ddb8
JR
329 }
330
2bf2bf23 331EOF
f204ddb8 332
2bf2bf23 333cat <<EOF
f204ddb8
JR
334SECTIONS
335{
2bf2bf23 336EOF
f204ddb8 337
2bf2bf23 338test -n "${RELOCATING}" && cat <<EOF
f204ddb8
JR
339 IVT 0 : {*.o(IVT) } > RESERVED_CRT0_RAM
340 RESERVED_CRT0 : {*.o(RESERVED_CRT0) } > RESERVED_CRT0_RAM
341 RESERVED_CRT0 : {*.o(reserved_crt0) } > RESERVED_CRT0_RAM
6c19b93b 342
f204ddb8
JR
343 CORE_RAM_0 : {*.o(core_ram_0) } > BANK0_SRAM
344 CORE_RAM_1 : {*.o(core_ram_1) } > BANK1_SRAM
345 CORE_RAM_2 : {*.o(core_ram_2) } > BANK2_SRAM
346 CORE_RAM_3 : {*.o(core_ram_3) } > BANK3_SRAM
6c19b93b 347
f204ddb8
JR
348 SRAM_SOUTH : {*.o(sram) } > EXTERNAL_SRAM
349 DRAM_WEST : {*.o(dram) } > EXTERNAL_DRAM_1
6c19b93b 350
f204ddb8 351 CORE_INTERNAL : {*.o(core_ram_internal) } /*> INTERNAL_RAM*/
6c19b93b 352
f204ddb8 353 /* the newlib (libc and libm) library is maped to the dedicated section */
6c19b93b 354
f204ddb8
JR
355 __new_lib_start_external_ = ( ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ *__CORE_NUM_ );
356 __new_lib_start_ = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ORIGIN(BANK1_SRAM) : __new_lib_start_external_ ;
6c19b93b 357
2bf2bf23 358 NEW_LIB_RO __new_lib_start_ : { lib_a-*.o(.text .rodata) *.o(libgloss_epiphany) } /* > INTERNAL_RAM */
6c19b93b
AM
359 GNU_C_BUILTIN_LIB_RO ADDR(NEW_LIB_RO) + SIZEOF(NEW_LIB_RO) : {
360 *mulsi3.o(.text .rodata) *modsi3.o(.text .rodata)
361 *divsi3.o(.text .rodata) *udivsi3.o(.text .rodata)
362 *umodsi3.o(.text .rodata) _*.o(.text .rodata)
363 }
364
365 NEW_LIB_WR ADDR(GNU_C_BUILTIN_LIB_RO) + SIZEOF(GNU_C_BUILTIN_LIB_RO) : { lib_a-*.o(.data ) } /* > INTERNAL_RAM*/
366
367
368 __init_start = DEFINED(__USE_INTERNAL_MEM_) ? ORIGIN(BANK1_SRAM) : (ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) ) ;
f204ddb8 369 __init_start = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) : __init_start;
2bf2bf23 370EOF
6c19b93b 371
2bf2bf23 372cat <<EOF
f204ddb8
JR
373 /* Read-only sections, merged into text segment: */
374 /*${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}*/
375 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
376 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
377 ${INITIAL_READONLY_SECTIONS}
c2e86386 378 .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
f204ddb8
JR
379EOF
380
381test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
382test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
383cat > ldscripts/dyntmp.$$ <<EOF
384 ${TEXT_DYNAMIC+${DYNAMIC}}
385 .hash ${RELOCATING-0} : { *(.hash) }
386 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
387 .dynsym ${RELOCATING-0} : { *(.dynsym) }
388 .dynstr ${RELOCATING-0} : { *(.dynstr) }
389 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
390 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
391 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
392EOF
393
394if [ "x$COMBRELOC" = x ]; then
395 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
396else
397 COMBRELOCCAT="cat > $COMBRELOC"
398fi
399eval $COMBRELOCCAT <<EOF
400 .rel.init ${RELOCATING-0} : { *(.rel.init) }
401 .rela.init ${RELOCATING-0} : { *(.rela.init) }
402 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
403 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
404 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
405 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
406 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
407 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
408 ${OTHER_READONLY_RELOC_SECTIONS}
409 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) }
410 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) }
411 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
412 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
413 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
414 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
415 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
416 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
417 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
418 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
419 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
420 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
421 .rel.got ${RELOCATING-0} : { *(.rel.got) }
422 .rela.got ${RELOCATING-0} : { *(.rela.got) }
423 ${OTHER_GOT_RELOC_SECTIONS}
424 ${REL_SDATA}
425 ${REL_SBSS}
426 ${REL_SDATA2}
427 ${REL_SBSS2}
428 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
429 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
430 ${REL_LARGE}
431EOF
432
433if [ -n "$COMBRELOC" ]; then
434cat >> ldscripts/dyntmp.$$ <<EOF
435 .rel.dyn ${RELOCATING-0} :
436 {
437EOF
6c19b93b 438sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
f204ddb8
JR
439cat >> ldscripts/dyntmp.$$ <<EOF
440 }
441 .rela.dyn ${RELOCATING-0} :
442 {
443EOF
6c19b93b 444sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
f204ddb8
JR
445cat >> ldscripts/dyntmp.$$ <<EOF
446 }
447EOF
448fi
449
450cat >> ldscripts/dyntmp.$$ <<EOF
451 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
452 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
453 ${OTHER_PLT_RELOC_SECTIONS}
454EOF
455
456if test -z "${NON_ALLOC_DYN}"; then
457 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
458 cat ldscripts/dyntmp.$$
459 else
460 if test -z "${NO_REL_RELOCS}"; then
6c19b93b 461 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
f204ddb8
JR
462 fi
463 if test -z "${NO_RELA_RELOCS}"; then
6c19b93b 464 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
f204ddb8
JR
465 fi
466 fi
467 rm -f ldscripts/dyntmp.$$
468fi
469
470cat <<EOF
6c19b93b 471
c2e86386 472 .init ${RELOCATING-0}${RELOCATING+__init_start} :
6c19b93b 473 {
f204ddb8 474 ${RELOCATING+${INIT_START}}
2d3181c7 475 KEEP (*(SORT_NONE(.init)))
f204ddb8 476 ${RELOCATING+${INIT_END}}
2bf2bf23 477 } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0}
f204ddb8
JR
478
479 ${TEXT_PLT+${PLT}}
480 ${TINY_READONLY_SECTION}
6c19b93b 481
c2e86386 482 .fini ${RELOCATING-0}${RELOCATING+ADDR(.init)+SIZEOF(.init)} :
f204ddb8
JR
483 {
484 ${RELOCATING+${FINI_START}}
2d3181c7 485 KEEP (*(SORT_NONE(.fini)))
f204ddb8 486 ${RELOCATING+${FINI_END}}
2bf2bf23 487 } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0}
6c19b93b 488
c2e86386 489 .text ${RELOCATING-0}${RELOCATING+ADDR(.fini)+SIZEOF(.fini)} :
f204ddb8
JR
490 {
491 ${RELOCATING+${TEXT_START_SYMBOLS}}
492 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
075a2b89 493 /* .gnu.warning sections are handled specially by elf.em. */
f204ddb8
JR
494 *(.gnu.warning)
495 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
2bf2bf23 496 } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0}
f204ddb8
JR
497
498 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
499 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
500 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
501 ${WRITABLE_RODATA-${RODATA}}
6c19b93b 502 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
f204ddb8
JR
503 ${CREATE_SHLIB-${SDATA2}}
504 ${CREATE_SHLIB-${SBSS2}}
505 ${OTHER_READONLY_SECTIONS}
c2e86386 506 .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) }
f204ddb8 507 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
2bf2bf23 508 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
f204ddb8
JR
509
510 /* Adjust the address for the data segment. We want to adjust up to
511 the same address within the page on the next page up. */
512 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
513 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
514 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
515
516 /* Exception handling */
517 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
2bf2bf23 518 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
f204ddb8
JR
519
520 /* Thread Local Storage sections */
521 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
522 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
523
524 .preinit_array ${RELOCATING-0} :
525 {
526 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
527 KEEP (*(.preinit_array))
528 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
6c19b93b 529 }
f204ddb8
JR
530 .init_array ${RELOCATING-0} :
531 {
532 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
2bf2bf23 533 ${RELOCATING+KEEP (*(SORT(.init_array.*)))}
f204ddb8
JR
534 KEEP (*(.init_array))
535 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
6c19b93b 536 }
f204ddb8
JR
537 .fini_array ${RELOCATING-0} :
538 {
539 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
540 KEEP (*(.fini_array))
2bf2bf23 541 ${RELOCATING+KEEP (*(SORT(.fini_array.*)))}
f204ddb8 542 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
6c19b93b 543 }
f204ddb8
JR
544 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
545 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
546 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
547
548 ${RELOCATING+${DATARELRO}}
549 ${OTHER_RELRO_SECTIONS}
550 ${TEXT_DYNAMIC-${DYNAMIC}}
551 ${DATA_GOT+${RELRO_NOW+${GOT}}}
552 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
553 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
554 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
555 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
556 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
557
558 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
559
c2e86386 560 .data ${RELOCATING-0}${RELOCATING+ADDR(.dtors)+SIZEOF(.dtors)} :
f204ddb8
JR
561 {
562 ${RELOCATING+${DATA_START_SYMBOLS}}
563 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
564 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
2bf2bf23 565 } /* ${RELOCATING+ > INTERNAL_RAM} */
6c19b93b 566 .data1 ${RELOCATING-0} : { *(.data1) }
f204ddb8
JR
567 ${WRITABLE_RODATA+${RODATA}}
568 ${OTHER_READWRITE_SECTIONS}
569 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
570 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
571 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
572 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
573 ${SDATA_GOT+${GOT}}
574 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
575 ${SDATA}
576 ${OTHER_SDATA_SECTIONS}
577 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
578 /* Align ___bss_start and _end to a multiple of 8 so that we can use strd
579 to clear bss. N.B., without adding any extra alignment, we would have
580 to clear the bss byte by byte. */
581 ${RELOCATING+. = ALIGN(8);}
582 ${RELOCATING+___bss_start = .;}
583 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
584 ${SBSS}
585 ${BSS_PLT+${PLT}}
c2e86386 586 .bss ${RELOCATING-0}${RELOCATING+ADDR(.rodata)+SIZEOF(.rodata)} :
f204ddb8 587 {
2bf2bf23 588 ${RELOCATING+*(.dynbss)}
f204ddb8 589 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
2bf2bf23 590 ${RELOCATING+*(COMMON)
f204ddb8
JR
591 /* Align here to ensure that the .bss section occupies space up to
592 _end. Align after .bss to ensure correct alignment even if the
593 .bss section disappears because there are no input sections.
2bf2bf23 594 FIXME: Why do we need it? When there is no .bss section, we do not
f204ddb8 595 pad the .data section. */
2bf2bf23
AM
596 . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
597 } /* ${RELOCATING+ > INTERNAL_RAM} */
f204ddb8
JR
598 ${OTHER_BSS_SECTIONS}
599 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
600 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
601 ${LARGE_SECTIONS}
602 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
603 ${RELOCATING+. = ALIGN(8);}
604 ${RELOCATING+${OTHER_END_SYMBOLS}}
605 ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
606 ${RELOCATING+${DATA_SEGMENT_END}}
74dc9032 607
2bf2bf23 608 ${RELOCATING+PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__ - 0x10) ;}
c2e86386 609 .stack ${RELOCATING-0}${RELOCATING+__stack_start_} : { ${RELOCATING+___stack = .;} *(.stack) }
74dc9032 610
2bf2bf23
AM
611 ${RELOCATING+PROVIDE ( ___heap_start = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );}
612 ${RELOCATING+PROVIDE ( ___heap_end = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ + __HEAP_SIZE_FOR_CORE__ - 4 );}
f204ddb8
JR
613EOF
614
615if test -n "${NON_ALLOC_DYN}"; then
616 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
617 cat ldscripts/dyntmp.$$
618 else
619 if test -z "${NO_REL_RELOCS}"; then
6c19b93b 620 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
f204ddb8
JR
621 fi
622 if test -z "${NO_RELA_RELOCS}"; then
6c19b93b 623 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
f204ddb8
JR
624 fi
625 fi
626 rm -f ldscripts/dyntmp.$$
627fi
628
629cat <<EOF
630 /* Stabs debugging sections. */
631 .stab 0 : { *(.stab) }
632 .stabstr 0 : { *(.stabstr) }
633 .stab.excl 0 : { *(.stab.excl) }
634 .stab.exclstr 0 : { *(.stab.exclstr) }
635 .stab.index 0 : { *(.stab.index) }
636 .stab.indexstr 0 : { *(.stab.indexstr) }
637
638 .comment 0 : { *(.comment) }
639
ceb0a680
NC
640EOF
641
d061dfac 642. $srcdir/scripttempl/DWARF.sc
f204ddb8 643
ceb0a680 644cat <<EOF
f204ddb8
JR
645 ${ATTRS_SECTIONS}
646 ${OTHER_SECTIONS}
647 ${RELOCATING+${OTHER_SYMBOLS}}
648 ${RELOCATING+${DISCARDED}}
649}
650EOF