Remove PROVIDE() qualifiers from definition of __CTOR_LIST__ and __DTOR_LIST__ symbol...
[external/binutils.git] / ld / scripttempl / epiphany_4x4.sc
1 # Copyright (C) 2014-2018 Free Software Foundation, Inc.
2 #
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.
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.
48 #       EMBEDDED - whether this is for an embedded system.
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
54 #       combination of .init sections.
55 #       FINI_START, FINI_END - statements just before and just after
56 #       combination of .fini sections.
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
97 test -z "$ENTRY" && ENTRY=_start
98 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
99 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
100 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
101 test -z "${ELFSIZE}" && ELFSIZE=32
102 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
103 test "$LD_FLAG" = "N" && DATA_ADDR=.
104 test -z "${ETEXT_NAME}" && ETEXT_NAME=etext
105 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
106 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
107 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
108 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
109 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
110 DATA_SEGMENT_RELRO_END=""
111 DATA_SEGMENT_END=""
112 if 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}, .);"
116 fi
117 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
118   INITIAL_READONLY_SECTIONS=".interp       ${RELOCATING-0} : { *(.interp) }"
119 fi
120 if test -z "$PLT"; then
121   PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
122 fi
123 test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
124 if test -z "$GOT"; then
125   if test -z "$SEPARATE_GOTPLT"; then
126     GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) }"
127   else
128     GOT=".got          ${RELOCATING-0} : { *(.got) }"
129     GOTPLT=".got.plt      ${RELOCATING-0} : { *(.got.plt) }"
130   fi
131 fi
132 DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
133 RODATA=".rodata ${RELOCATING+ADDR(.data)+SIZEOF(.data)} ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }  /*> INTERNAL_RAM*/"
134 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
135 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }"
136 if 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.*)}
141     *(.dynsbss)
142     *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
143     *(.scommon)
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.  */
150   .sdata        ${RELOCATING-0} :
151   {
152     ${RELOCATING+${SDATA_START_SYMBOLS}}
153     ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
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.*}) }"
169 else
170   NO_SMALL_DATA=" "
171 fi
172 if test -z "${DATA_GOT}"; then
173   if test -n "${NO_SMALL_DATA}"; then
174     DATA_GOT=" "
175   fi
176 fi
177 if test -z "${SDATA_GOT}"; then
178   if test -z "${NO_SMALL_DATA}"; then
179     SDATA_GOT=" "
180   fi
181 fi
182 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
183 test "${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.*}) }"
190 test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
191   ${OTHER_BSS_SECTIONS}
192   .lbss ${RELOCATING-0} :
193   {
194     *(.dynlbss)
195     *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
196     *(LARGE_COMMON)
197   }"
198 test "${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   }"
208 CTOR=".ctors    ADDR(.text) + SIZEOF(.text)      ${CONSTRUCTING-0} :
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}}
233   }  /*> INTERNAL_RAM*/"
234 DTOR=".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*/ "
244
245 # If this is for an embedded system, don't add SIZEOF_HEADERS.
246 if [ -z "$EMBEDDED" ]; then
247    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
248 else
249    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
250 fi
251
252 cat <<EOF
253 /* Copyright (C) 2014-2018 Free Software Foundation, Inc.
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.  */
258
259 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
260               "${LITTLE_OUTPUT_FORMAT}")
261 OUTPUT_ARCH(${OUTPUT_ARCH})
262 ${RELOCATING+ENTRY(${ENTRY})}
263
264 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
265 ${RELOCATING+${INPUT_FILES}}
266 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
267   if gld -r is used and the intermediate file has sections starting
268   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
269   bug.  But for now assigning the zero vmas works.  */}
270
271
272
273 /* BSP specific*/
274 __PROG_SIZE_FOR_CORE__ = 1M;
275 __HEAP_SIZE_FOR_CORE__ = 1M;
276
277 __MAX_NUM_CORES_IN_ROWS__ = 4;
278 __MAX_NUM_CORES_IN_COLS__ = 4;
279
280 __FIRST_CORE_ROW_ = 0x20;
281 __FIRST_CORE_COL_ = 0x24;
282
283
284
285 PROVIDE (__CORE_ROW_ = __FIRST_CORE_ROW_);
286 PROVIDE (__CORE_COL_ = __FIRST_CORE_COL_);
287 /* generic don't touch */
288 /* used to calculated the slice address in the external memory*/
289 __CORE_NUM_ =  (__CORE_ROW_ -  __FIRST_CORE_ROW_ )* __MAX_NUM_CORES_IN_COLS__ + (__CORE_COL_ - __FIRST_CORE_COL_ ) ;
290
291
292 MEMORY
293  {
294         EXTERNAL_DRAM_0 (WXAI) :     ORIGIN = 0x80000000,      LENGTH = 0x1000000  /*.text, data, rodata, bss and .stack*/
295     EXTERNAL_DRAM_1 (WXAI) :        ORIGIN = 0x81000000,      LENGTH = 0x1000000 /*.heap */
296
297     EXTERNAL_SRAM (WXAI) :       ORIGIN = 0x92000000,      LENGTH =   8K /* small external RAM, used for testing*/
298
299     /* run time lib and crt0*/
300     RESERVED_CRT0_RAM (WXAI) :    ORIGIN = 0,      LENGTH = 0x400
301
302     /* user program, per bank usage */
303     BANK0_SRAM (WXAI) : ORIGIN = LENGTH(RESERVED_CRT0_RAM),   LENGTH = 8K - LENGTH(RESERVED_CRT0_RAM)
304     BANK1_SRAM (WXAI) : ORIGIN = 0x2000, LENGTH = 8K
305     BANK2_SRAM (WXAI) : ORIGIN = 0x4000, LENGTH = 8K
306     BANK3_SRAM (WXAI) : ORIGIN = 0x6000, LENGTH = 8K
307
308     /* user program, continious placement */
309     INTERNAL_RAM        (WXAI) :     ORIGIN = LENGTH(RESERVED_CRT0_RAM),  LENGTH = 32K - LENGTH(RESERVED_CRT0_RAM)
310
311     MMR (WAI)         : ORIGIN = 0xF000, LENGTH = 32K
312
313     /* multi cores space */
314         CORE_0x20_0x24_INTERNAL_RAM :      ORIGIN = 0x82400000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
315         CORE_0x20_0x25_INTERNAL_RAM :      ORIGIN = 0x82500000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
316         CORE_0x20_0x26_INTERNAL_RAM :      ORIGIN = 0x82600000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
317         CORE_0x20_0x27_INTERNAL_RAM :      ORIGIN = 0x82700000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
318         CORE_0x21_0x24_INTERNAL_RAM :      ORIGIN = 0x86400000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
319         CORE_0x21_0x25_INTERNAL_RAM :      ORIGIN = 0x86500000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
320         CORE_0x21_0x26_INTERNAL_RAM :      ORIGIN = 0x86600000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
321         CORE_0x21_0x27_INTERNAL_RAM :      ORIGIN = 0x86700000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
322         CORE_0x22_0x24_INTERNAL_RAM :      ORIGIN = 0x8a400000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
323         CORE_0x22_0x25_INTERNAL_RAM :      ORIGIN = 0x8a500000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
324         CORE_0x22_0x26_INTERNAL_RAM :      ORIGIN = 0x8a600000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
325         CORE_0x22_0x27_INTERNAL_RAM :      ORIGIN = 0x8a700000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
326         CORE_0x23_0x24_INTERNAL_RAM :      ORIGIN = 0x8e400000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
327         CORE_0x23_0x25_INTERNAL_RAM :      ORIGIN = 0x8e500000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
328         CORE_0x23_0x26_INTERNAL_RAM :      ORIGIN = 0x8e600000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
329         CORE_0x23_0x27_INTERNAL_RAM :      ORIGIN = 0x8e700000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
330         CORE_0x24_0x24_INTERNAL_RAM :      ORIGIN = 0x82000000+LENGTH(RESERVED_CRT0_RAM),      LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
331
332  }
333
334
335 SECTIONS
336 {
337
338    IVT 0 : {*.o(IVT)  } > RESERVED_CRT0_RAM
339    RESERVED_CRT0 : {*.o(RESERVED_CRT0)  } > RESERVED_CRT0_RAM
340    RESERVED_CRT0 : {*.o(reserved_crt0)  } > RESERVED_CRT0_RAM
341
342    CORE_RAM_0 :   {*.o(core_ram_0)  }  > BANK0_SRAM
343    CORE_RAM_1 :   {*.o(core_ram_1)  }  > BANK1_SRAM
344    CORE_RAM_2 :   {*.o(core_ram_2)  }  > BANK2_SRAM
345    CORE_RAM_3 :   {*.o(core_ram_3)  }  > BANK3_SRAM
346
347    SRAM_SOUTH :  {*.o(sram)  }  > EXTERNAL_SRAM
348    DRAM_WEST :  {*.o(dram)  }  > EXTERNAL_DRAM_1
349
350    CORE_INTERNAL :  {*.o(core_ram_internal)  }    /*> INTERNAL_RAM*/
351
352    /* the newlib  (libc and libm)  library is maped to the dedicated section */
353
354    __new_lib_start_external_ =  ( ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ *__CORE_NUM_ );
355    __new_lib_start_ = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ORIGIN(BANK1_SRAM) :  __new_lib_start_external_ ;
356
357    NEW_LIB_RO ${RELOCATING+__new_lib_start_} : { lib_a-*.o(.text  .rodata )  *.o(libgloss_epiphany)  }  /*  > INTERNAL_RAM*/
358    GNU_C_BUILTIN_LIB_RO     ADDR(NEW_LIB_RO) + SIZEOF(NEW_LIB_RO) : {
359                                                                 *mulsi3.o(.text  .rodata)  *modsi3.o(.text  .rodata)
360                                                                 *divsi3.o(.text  .rodata)       *udivsi3.o(.text  .rodata)
361                                                             *umodsi3.o(.text  .rodata)   _*.o(.text  .rodata)
362    }
363
364    NEW_LIB_WR   ADDR(GNU_C_BUILTIN_LIB_RO) + SIZEOF(GNU_C_BUILTIN_LIB_RO)  : { lib_a-*.o(.data ) }    /* >  INTERNAL_RAM*/
365
366
367    __init_start = DEFINED(__USE_INTERNAL_MEM_) ? ORIGIN(BANK1_SRAM) :  (ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) ) ;
368    __init_start = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR)  : __init_start;
369
370
371   /* Read-only sections, merged into text segment: */
372   /*${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}*/
373   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
374   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
375   ${INITIAL_READONLY_SECTIONS}
376   .note.gnu.build-id : { *(.note.gnu.build-id) }
377 EOF
378
379 test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
380 test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
381 cat > ldscripts/dyntmp.$$ <<EOF
382   ${TEXT_DYNAMIC+${DYNAMIC}}
383   .hash         ${RELOCATING-0} : { *(.hash) }
384   .gnu.hash     ${RELOCATING-0} : { *(.gnu.hash) }
385   .dynsym       ${RELOCATING-0} : { *(.dynsym) }
386   .dynstr       ${RELOCATING-0} : { *(.dynstr) }
387   .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
388   .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
389   .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
390 EOF
391
392 if [ "x$COMBRELOC" = x ]; then
393   COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
394 else
395   COMBRELOCCAT="cat > $COMBRELOC"
396 fi
397 eval $COMBRELOCCAT <<EOF
398   .rel.init     ${RELOCATING-0} : { *(.rel.init) }
399   .rela.init    ${RELOCATING-0} : { *(.rela.init) }
400   .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
401   .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
402   .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
403   .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
404   .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
405   .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
406   ${OTHER_READONLY_RELOC_SECTIONS}
407   .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) }
408   .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) }
409   .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
410   .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
411   .rel.tdata    ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
412   .rela.tdata   ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
413   .rel.tbss     ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
414   .rela.tbss    ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
415   .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
416   .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
417   .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
418   .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
419   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
420   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
421   ${OTHER_GOT_RELOC_SECTIONS}
422   ${REL_SDATA}
423   ${REL_SBSS}
424   ${REL_SDATA2}
425   ${REL_SBSS2}
426   .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
427   .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
428   ${REL_LARGE}
429 EOF
430
431 if [ -n "$COMBRELOC" ]; then
432 cat >> ldscripts/dyntmp.$$ <<EOF
433   .rel.dyn      ${RELOCATING-0} :
434     {
435 EOF
436 sed -e '/^[      ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC >> ldscripts/dyntmp.$$
437 cat >> ldscripts/dyntmp.$$ <<EOF
438     }
439   .rela.dyn     ${RELOCATING-0} :
440     {
441 EOF
442 sed -e '/^[      ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC >> ldscripts/dyntmp.$$
443 cat >> ldscripts/dyntmp.$$ <<EOF
444     }
445 EOF
446 fi
447
448 cat >> ldscripts/dyntmp.$$ <<EOF
449   .rel.plt      ${RELOCATING-0} : { *(.rel.plt) }
450   .rela.plt     ${RELOCATING-0} : { *(.rela.plt) }
451   ${OTHER_PLT_RELOC_SECTIONS}
452 EOF
453
454 if test -z "${NON_ALLOC_DYN}"; then
455   if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
456     cat ldscripts/dyntmp.$$
457   else
458     if test -z "${NO_REL_RELOCS}"; then
459       sed -e '/^[        ]*\.rela\.[^}]*$/,/}/d' -e '/^[         ]*\.rela\./d' ldscripts/dyntmp.$$
460     fi
461     if test -z "${NO_RELA_RELOCS}"; then
462       sed -e '/^[        ]*\.rel\.[^}]*$/,/}/d' -e '/^[  ]*\.rel\./d' ldscripts/dyntmp.$$
463     fi
464   fi
465   rm -f ldscripts/dyntmp.$$
466 fi
467
468 cat <<EOF
469
470   .init  __init_start  :
471   {
472     ${RELOCATING+${INIT_START}}
473     KEEP (*(.init))
474     ${RELOCATING+${INIT_END}}
475   }     /*> INTERNAL_RAM*/ =${NOP-0}
476
477   ${TEXT_PLT+${PLT}}
478   ${TINY_READONLY_SECTION}
479
480   .fini ${RELOCATING+ADDR(.init)+SIZEOF(.init)} ${RELOCATING-0} :
481   {
482     ${RELOCATING+${FINI_START}}
483     KEEP (*(.fini))
484     ${RELOCATING+${FINI_END}}
485   }    /*> INTERNAL_RAM*/ =${NOP-0}
486
487   .text ${RELOCATING+ADDR(.fini)+SIZEOF(.fini)} ${RELOCATING-0} :
488   {
489     ${RELOCATING+${TEXT_START_SYMBOLS}}
490     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
491     /* .gnu.warning sections are handled specially by elf32.em.  */
492     *(.gnu.warning)
493     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
494   }    /*> INTERNAL_RAM */ =${NOP-0}
495
496   ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
497   ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
498   ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
499   ${WRITABLE_RODATA-${RODATA}}
500   .rodata1      ${RELOCATING-0} : { *(.rodata1) }
501   ${CREATE_SHLIB-${SDATA2}}
502   ${CREATE_SHLIB-${SBSS2}}
503   ${OTHER_READONLY_SECTIONS}
504   .eh_frame_hdr : { *(.eh_frame_hdr) }
505   .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
506   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
507
508   /* Adjust the address for the data segment.  We want to adjust up to
509      the same address within the page on the next page up.  */
510   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
511   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
512   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
513
514   /* Exception handling  */
515   .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
516   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
517
518   /* Thread Local Storage sections  */
519   .tdata        ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
520   .tbss         ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
521
522   .preinit_array   ${RELOCATING-0} :
523   {
524     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
525     KEEP (*(.preinit_array))
526     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
527   }
528   .init_array   ${RELOCATING-0} :
529   {
530      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
531      KEEP (*(SORT(.init_array.*)))
532      KEEP (*(.init_array))
533      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
534   }
535   .fini_array   ${RELOCATING-0} :
536   {
537     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
538     KEEP (*(.fini_array))
539     KEEP (*(SORT(.fini_array.*)))
540     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
541   }
542   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
543   ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
544   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
545
546   ${RELOCATING+${DATARELRO}}
547   ${OTHER_RELRO_SECTIONS}
548   ${TEXT_DYNAMIC-${DYNAMIC}}
549   ${DATA_GOT+${RELRO_NOW+${GOT}}}
550   ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
551   ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
552   ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
553   ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
554   ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
555
556   ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
557
558   .data ${RELOCATING+ADDR(.dtors)+SIZEOF(.dtors)} ${RELOCATING-0} :
559   {
560     ${RELOCATING+${DATA_START_SYMBOLS}}
561     *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
562     ${CONSTRUCTING+SORT(CONSTRUCTORS)}
563   }  /*> INTERNAL_RAM*/
564   .data1        ${RELOCATING-0} : { *(.data1) }
565   ${WRITABLE_RODATA+${RODATA}}
566   ${OTHER_READWRITE_SECTIONS}
567   ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
568   ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
569   ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
570   ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
571   ${SDATA_GOT+${GOT}}
572   ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
573   ${SDATA}
574   ${OTHER_SDATA_SECTIONS}
575   ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
576   /* Align ___bss_start and _end to a multiple of 8 so that we can use strd
577      to clear bss.  N.B., without adding any extra alignment, we would have
578      to clear the bss byte by byte.  */
579   ${RELOCATING+. = ALIGN(8);}
580   ${RELOCATING+___bss_start = .;}
581   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
582   ${SBSS}
583   ${BSS_PLT+${PLT}}
584   .bss ${RELOCATING+ADDR(.rodata)+SIZEOF(.rodata)} ${RELOCATING-0} :
585   {
586    *(.dynbss)
587    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
588    *(COMMON)
589    /* Align here to ensure that the .bss section occupies space up to
590       _end.  Align after .bss to ensure correct alignment even if the
591       .bss section disappears because there are no input sections.
592       FIXME: Why do we need it? When there is no .bss section, we don't
593       pad the .data section.  */
594    ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
595   }  /*> INTERNAL_RAM*/
596   ${OTHER_BSS_SECTIONS}
597   ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
598   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
599   ${LARGE_SECTIONS}
600   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
601   ${RELOCATING+. = ALIGN(8);}
602   ${RELOCATING+${OTHER_END_SYMBOLS}}
603   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
604   ${RELOCATING+${DATA_SEGMENT_END}}
605
606   PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__  - 0x10) ;
607   .stack ${RELOCATING+__stack_start_} :  {    ${RELOCATING+___stack = .;}    *(.stack)  }
608
609   PROVIDE (  ___heap_start = ORIGIN(EXTERNAL_DRAM_1)  + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );
610   PROVIDE (  ___heap_end =   ORIGIN(EXTERNAL_DRAM_1)  + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_  + __HEAP_SIZE_FOR_CORE__ - 4 );
611 EOF
612
613 if test -n "${NON_ALLOC_DYN}"; then
614   if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
615     cat ldscripts/dyntmp.$$
616   else
617     if test -z "${NO_REL_RELOCS}"; then
618       sed -e '/^[        ]*\.rela\.[^}]*$/,/}/d' -e '/^[         ]*\.rela\./d' ldscripts/dyntmp.$$
619     fi
620     if test -z "${NO_RELA_RELOCS}"; then
621       sed -e '/^[        ]*\.rel\.[^}]*$/,/}/d' -e '/^[  ]*\.rel\./d' ldscripts/dyntmp.$$
622     fi
623   fi
624   rm -f ldscripts/dyntmp.$$
625 fi
626
627 cat <<EOF
628   /* Stabs debugging sections.  */
629   .stab          0 : { *(.stab) }
630   .stabstr       0 : { *(.stabstr) }
631   .stab.excl     0 : { *(.stab.excl) }
632   .stab.exclstr  0 : { *(.stab.exclstr) }
633   .stab.index    0 : { *(.stab.index) }
634   .stab.indexstr 0 : { *(.stab.indexstr) }
635
636   .comment       0 : { *(.comment) }
637
638 EOF
639
640 . $srcdir/scripttempl/DWARF.sc
641
642 cat <<EOF
643   ${ATTRS_SECTIONS}
644   ${OTHER_SECTIONS}
645   ${RELOCATING+${OTHER_SYMBOLS}}
646   ${RELOCATING+${DISCARDED}}
647 }
648 EOF