xref: /netbsd-src/external/gpl3/binutils.old/dist/ld/scripttempl/elfarc.sc (revision e992f068c547fd6e84b3f104dc2340adcc955732)
116dce513Schristos#
216dce513Schristos# Unusual variables checked by this code:
316dce513Schristos#	NOP - four byte opcode for no-op (defaults to 0)
416dce513Schristos#	NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
516dce513Schristos#		empty.
616dce513Schristos#	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
716dce513Schristos#	INITIAL_READONLY_SECTIONS - at start of text segment
816dce513Schristos#	OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
916dce513Schristos#		(e.g., .PARISC.milli)
1016dce513Schristos#	OTHER_TEXT_SECTIONS - these get put in .text when relocating
1116dce513Schristos#	OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
1216dce513Schristos#		(e.g., .PARISC.global)
1316dce513Schristos#	OTHER_BSS_SECTIONS - other than .bss .sbss ...
1416dce513Schristos#	OTHER_SECTIONS - at the end
1516dce513Schristos#	EXECUTABLE_SYMBOLS - symbols that must be defined for an
1616dce513Schristos#		executable (e.g., _DYNAMIC_LINK)
1716dce513Schristos#	TEXT_START_SYMBOLS - symbols that appear at the start of the
1816dce513Schristos#		.text section.
1916dce513Schristos#	DATA_START_SYMBOLS - symbols that appear at the start of the
2016dce513Schristos#		.data section.
2116dce513Schristos#	OTHER_GOT_SYMBOLS - symbols defined just before .got.
2216dce513Schristos#	OTHER_GOT_SECTIONS - sections just after .got.
2316dce513Schristos#	OTHER_SDATA_SECTIONS - sections just after .sdata.
2416dce513Schristos#	OTHER_BSS_SYMBOLS - symbols that appear at the start of the
2516dce513Schristos#		.bss section besides __bss_start.
2616dce513Schristos#	DATA_PLT - .plt should be in data segment, not text segment.
2716dce513Schristos#	BSS_PLT - .plt should be in bss segment
2816dce513Schristos#	TEXT_DYNAMIC - .dynamic in text segment, not data segment.
2916dce513Schristos#	EMBEDDED - whether this is for an embedded system.
3016dce513Schristos#	SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
3116dce513Schristos#		start address of shared library.
3216dce513Schristos#	INPUT_FILES - INPUT command of files to always include
3316dce513Schristos#	WRITABLE_RODATA - if set, the .rodata section should be writable
3416dce513Schristos#	INIT_START, INIT_END -  statements just before and just after
3516dce513Schristos#	combination of .init sections.
3616dce513Schristos#	FINI_START, FINI_END - statements just before and just after
3716dce513Schristos#	combination of .fini sections.
3816dce513Schristos#	STACK_ADDR - start of a .stack section.
3916dce513Schristos#	OTHER_END_SYMBOLS - symbols to place right at the end of the script.
4016dce513Schristos#
4116dce513Schristos# When adding sections, do note that the names of some sections are used
4216dce513Schristos# when specifying the start address of the next.
4316dce513Schristos#
4416dce513Schristos
4516dce513Schristos#  Many sections come in three flavours.  There is the 'real' section,
4616dce513Schristos#  like ".data".  Then there are the per-procedure or per-variable
4716dce513Schristos#  sections, generated by -ffunction-sections and -fdata-sections in GCC,
4816dce513Schristos#  and useful for --gc-sections, which for a variable "foo" might be
4916dce513Schristos#  ".data.foo".  Then there are the linkonce sections, for which the linker
5016dce513Schristos#  eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
5116dce513Schristos#  The exact correspondences are:
5216dce513Schristos#
5316dce513Schristos#  Section	Linkonce section
5416dce513Schristos#  .text	.gnu.linkonce.t.foo
5516dce513Schristos#  .rodata	.gnu.linkonce.r.foo
5616dce513Schristos#  .data	.gnu.linkonce.d.foo
5716dce513Schristos#  .bss		.gnu.linkonce.b.foo
5816dce513Schristos#  .sdata	.gnu.linkonce.s.foo
5916dce513Schristos#  .sbss	.gnu.linkonce.sb.foo
6016dce513Schristos#  .sdata2	.gnu.linkonce.s2.foo
6116dce513Schristos#  .sbss2	.gnu.linkonce.sb2.foo
6216dce513Schristos#  .debug_info	.gnu.linkonce.wi.foo
6316dce513Schristos#  .tdata	.gnu.linkonce.td.foo
6416dce513Schristos#  .tbss	.gnu.linkonce.tb.foo
6516dce513Schristos#
6616dce513Schristos#  Each of these can also have corresponding .rel.* and .rela.* sections.
6716dce513Schristos
6816dce513Schristostest -z "$ENTRY" && ENTRY=start
6916dce513Schristostest -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
7016dce513Schristostest -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
7116dce513Schristos# If we request a big endian toolchain, give a big endian linker
72*e992f068Schristostest "${ARC_ENDIAN}" = "big" && OUTPUT_FORMAT=${BIG_OUTPUT_FORMAT}
7316dce513Schristosif [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
7416dce513Schristostest -z "${ELFSIZE}" && ELFSIZE=32
7516dce513Schristostest -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
7616dce513Schristostest "$LD_FLAG" = "N" && DATA_ADDR=.
7716dce513Schristostest -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
7816dce513Schristostest -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
7916dce513SchristosDATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
8016dce513SchristosDATA_SEGMENT_END=""
8116dce513Schristosif test -n "${COMMONPAGESIZE}"; then
8216dce513Schristos  DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
8316dce513Schristos  DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
8416dce513Schristosfi
8516dce513SchristosINTERP=".interp       ${RELOCATING-0} : { *(.interp) }"
8616dce513SchristosPLT=".plt          ${RELOCATING-0} : { *(.plt) }"
87012573ebSchristostest -z "$GOT" && GOT=".got          ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }"
8816dce513SchristosDYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
8916dce513SchristosRODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
9016dce513SchristosSTACKNOTE="/DISCARD/ : { *(.note.GNU-stack) }"
9116dce513Schristosif test -z "${NO_SMALL_DATA}"; then
9216dce513Schristos  SBSS=".sbss         ${RELOCATING-0} :
9316dce513Schristos  {
9416dce513Schristos    ${RELOCATING+PROVIDE (__sbss_start = .);}
9516dce513Schristos    ${RELOCATING+PROVIDE (___sbss_start = .);}
96012573ebSchristos    ${RELOCATING+*(.dynsbss)}
9716dce513Schristos    *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
98012573ebSchristos    ${RELOCATING+*(.scommon)}
9916dce513Schristos    ${RELOCATING+PROVIDE (__sbss_end = .);}
10016dce513Schristos    ${RELOCATING+PROVIDE (___sbss_end = .);}
10116dce513Schristos  }"
10216dce513Schristos  SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
10316dce513Schristos  SDATA="/* We want the small data sections together, so single-instruction offsets
10416dce513Schristos     can access them all, and initialized data all before uninitialized, so
10516dce513Schristos     we can shorten the on-disk segment size.  */
10616dce513Schristos  .sdata        ${RELOCATING-0} :
10716dce513Schristos  {
10816dce513Schristos    ${RELOCATING+${SDATA_START_SYMBOLS}}
10916dce513Schristos    *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
11016dce513Schristos  }"
11116dce513Schristos  SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
11216dce513Schristos  REL_SDATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
11316dce513Schristos  .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
11416dce513Schristos  REL_SBSS=".rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
11516dce513Schristos  .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
11616dce513Schristos  REL_SDATA2=".rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
11716dce513Schristos  .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
11816dce513Schristos  REL_SBSS2=".rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
11916dce513Schristos  .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
12016dce513Schristosfi
121*e992f068SchristosINIT_ARRAY=".init_array   ${RELOCATING-0} :
122*e992f068Schristos  {
123*e992f068Schristos    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
124*e992f068Schristos    KEEP (*(SORT(.init_array.*)))
125*e992f068Schristos    KEEP (*(.init_array))
126*e992f068Schristos    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
127*e992f068Schristos  }"
128*e992f068SchristosFINI_ARRAY=".fini_array   ${RELOCATING-0} :
129*e992f068Schristos  {
130*e992f068Schristos    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
131*e992f068Schristos    KEEP (*(SORT(.fini_array.*)))
132*e992f068Schristos    KEEP (*(.fini_array))
133*e992f068Schristos    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
134*e992f068Schristos  }"
13516dce513SchristosCTOR=".ctors        ${CONSTRUCTING-0} :
13616dce513Schristos  {
13716dce513Schristos    ${CONSTRUCTING+${CTOR_START}}
13816dce513Schristos    /* gcc uses crtbegin.o to find the start of
13916dce513Schristos       the constructors, so we make sure it is
14016dce513Schristos       first.  Because this is a wildcard, it
14116dce513Schristos       doesn't matter if the user does not
14216dce513Schristos       actually link against crtbegin.o; the
14316dce513Schristos       linker won't look for a file to match a
14416dce513Schristos       wildcard.  The wildcard also means that it
14516dce513Schristos       doesn't matter which directory crtbegin.o
14616dce513Schristos       is in.  */
14716dce513Schristos
14816dce513Schristos    KEEP (*crtbegin*.o(.ctors))
14916dce513Schristos
15016dce513Schristos    /* We don't want to include the .ctor section from
15116dce513Schristos       from the crtend.o file until after the sorted ctors.
15216dce513Schristos       The .ctor section from the crtend file contains the
15316dce513Schristos       end of ctors marker and it must be last */
15416dce513Schristos
15516dce513Schristos    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
15616dce513Schristos    KEEP (*(SORT(.ctors.*)))
15716dce513Schristos    KEEP (*(.ctors))
15816dce513Schristos    ${CONSTRUCTING+${CTOR_END}}
15916dce513Schristos  }"
16016dce513SchristosDTOR=".dtors        ${CONSTRUCTING-0} :
16116dce513Schristos  {
16216dce513Schristos    ${CONSTRUCTING+${DTOR_START}}
16316dce513Schristos    KEEP (*crtbegin*.o(.dtors))
16416dce513Schristos    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
16516dce513Schristos    KEEP (*(SORT(.dtors.*)))
16616dce513Schristos    KEEP (*(.dtors))
16716dce513Schristos    ${CONSTRUCTING+${DTOR_END}}
16816dce513Schristos  }"
16916dce513SchristosSTACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
17016dce513Schristos  {
17116dce513Schristos    ${RELOCATING+_stack = .;}
17216dce513Schristos    *(.stack)
17316dce513Schristos  }"
17416dce513Schristos
175*e992f068SchristosTEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
176*e992f068SchristosSHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
177*e992f068Schristos
17816dce513Schristos# if this is for an embedded system, don't add SIZEOF_HEADERS.
17916dce513Schristosif [ -z "$EMBEDDED" ]; then
18016dce513Schristos   test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
18116dce513Schristoselse
18216dce513Schristos   test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
18316dce513Schristosfi
18416dce513Schristos
18516dce513Schristoscat <<EOF
18616dce513SchristosOUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
18716dce513Schristos	      "${LITTLE_OUTPUT_FORMAT}")
18816dce513SchristosOUTPUT_ARCH(${OUTPUT_ARCH})
18916dce513Schristos${RELOCATING+ENTRY(${ENTRY})}
19016dce513Schristos
19116dce513Schristos${RELOCATING+${LIB_SEARCH_DIRS}}
19216dce513Schristos${RELOCATING+/* Do we need any of these for elf?
19316dce513Schristos   __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
19416dce513Schristos${RELOCATING+${EXECUTABLE_SYMBOLS}}
19516dce513Schristos${RELOCATING+${INPUT_FILES}}
19616dce513Schristos${RELOCATING- /* For some reason, the Solaris linker makes bad executables
19716dce513Schristos  if gld -r is used and the intermediate file has sections starting
19816dce513Schristos  at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
19916dce513Schristos  bug.  But for now assigning the zero vmas works.  */}
20016dce513Schristos
20116dce513SchristosSECTIONS
20216dce513Schristos{
20316dce513Schristos  /* Read-only sections, merged into text segment: */
20416dce513Schristos  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
20516dce513Schristos  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
20616dce513Schristos  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
20716dce513Schristos  ${CREATE_SHLIB-${INTERP}}
20816dce513Schristos  ${INITIAL_READONLY_SECTIONS}
20916dce513Schristos  ${TEXT_DYNAMIC+${DYNAMIC}}
21016dce513Schristos  .hash         ${RELOCATING-0} : { *(.hash) }
21116dce513Schristos  .dynsym       ${RELOCATING-0} : { *(.dynsym) }
21216dce513Schristos  .dynstr       ${RELOCATING-0} : { *(.dynstr) }
21316dce513Schristos  .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
21416dce513Schristos  .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
21516dce513Schristos  .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
21616dce513Schristos
21716dce513SchristosEOF
21816dce513Schristosif [ "x$COMBRELOC" = x ]; then
21916dce513Schristos  COMBRELOCCAT=cat
22016dce513Schristoselse
22116dce513Schristos  COMBRELOCCAT="cat > $COMBRELOC"
22216dce513Schristosfi
22316dce513Schristoseval $COMBRELOCCAT <<EOF
22416dce513Schristos  .rel.init     ${RELOCATING-0} : { *(.rel.init) }
22516dce513Schristos  .rela.init    ${RELOCATING-0} : { *(.rela.init) }
22616dce513Schristos  .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
22716dce513Schristos  .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
22816dce513Schristos  .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
22916dce513Schristos  .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
23016dce513Schristos  .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
23116dce513Schristos  .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
23216dce513Schristos  ${OTHER_READONLY_RELOC_SECTIONS}
23316dce513Schristos  .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
23416dce513Schristos  .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
23516dce513Schristos  .rel.tdata	${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
23616dce513Schristos  .rela.tdata	${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
23716dce513Schristos  .rel.tbss	${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
23816dce513Schristos  .rela.tbss	${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
23916dce513Schristos  .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
24016dce513Schristos  .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
24116dce513Schristos  .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
24216dce513Schristos  .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
24316dce513Schristos  .rel.got      ${RELOCATING-0} : { *(.rel.got) }
24416dce513Schristos  .rela.got     ${RELOCATING-0} : { *(.rela.got) }
24516dce513Schristos  ${OTHER_GOT_RELOC_SECTIONS}
24616dce513Schristos  ${REL_SDATA}
24716dce513Schristos  ${REL_SBSS}
24816dce513Schristos  ${REL_SDATA2}
24916dce513Schristos  ${REL_SBSS2}
25016dce513Schristos  .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
25116dce513Schristos  .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
25216dce513SchristosEOF
25316dce513Schristosif [ -n "$COMBRELOC" ]; then
25416dce513Schristoscat <<EOF
25516dce513Schristos  .rel.dyn      ${RELOCATING-0} :
25616dce513Schristos    {
25716dce513SchristosEOF
25816dce513Schristossed -e '/^[	 ]*[{}][	 ]*$/d;/:[	 ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC
25916dce513Schristoscat <<EOF
26016dce513Schristos    }
26116dce513Schristos  .rela.dyn     ${RELOCATING-0} :
26216dce513Schristos    {
26316dce513SchristosEOF
26416dce513Schristossed -e '/^[	 ]*[{}][	 ]*$/d;/:[	 ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC
26516dce513Schristoscat <<EOF
26616dce513Schristos    }
26716dce513SchristosEOF
26816dce513Schristosfi
26916dce513Schristoscat <<EOF
27016dce513Schristos  .rel.plt      ${RELOCATING-0} : { *(.rel.plt) }
27116dce513Schristos  .rela.plt     ${RELOCATING-0} : { *(.rela.plt) }
27216dce513Schristos  ${OTHER_PLT_RELOC_SECTIONS}
27316dce513Schristos
27416dce513Schristos  .init         ${RELOCATING-0} :
27516dce513Schristos  {
27616dce513Schristos    ${RELOCATING+${INIT_START}}
277012573ebSchristos    KEEP (*(SORT_NONE(.init)))
27816dce513Schristos    ${RELOCATING+${INIT_END}}
27916dce513Schristos  } =${NOP-0}
28016dce513Schristos
28116dce513Schristos  ${DATA_PLT-${BSS_PLT-${PLT}}}
282ede78133Schristos  .jlitab       ${RELOCATING-0} :
283ede78133Schristos  {
284ede78133Schristos    ${RELOCATING+${JLI_START_TABLE}}
285012573ebSchristos    ${RELOCATING+jlitab*.o(.jlitab*)}
286012573ebSchristos    *(.jlitab${RELOCATING+*})
287ede78133Schristos  } =${NOP-0}
28816dce513Schristos  .text         ${RELOCATING-0} :
28916dce513Schristos  {
29016dce513Schristos    ${RELOCATING+${TEXT_START_SYMBOLS}}
29116dce513Schristos    *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
292012573ebSchristos    /* .gnu.warning sections are handled specially by elf.em.  */
29316dce513Schristos    *(.gnu.warning)
29416dce513Schristos    ${RELOCATING+${OTHER_TEXT_SECTIONS}}
29516dce513Schristos  } =${NOP-0}
29616dce513Schristos  .text.init ${RELOCATING-0} :
29716dce513Schristos  {
29816dce513Schristos    *(.text.init)
29916dce513Schristos  } =${NOP-0}
30016dce513Schristos  .fini         ${RELOCATING-0} :
30116dce513Schristos  {
30216dce513Schristos    ${RELOCATING+${FINI_START}}
303012573ebSchristos    KEEP (*(SORT_NONE(.fini)))
30416dce513Schristos    ${RELOCATING+${FINI_END}}
30516dce513Schristos  } =${NOP-0}
30616dce513Schristos  ${RELOCATING+PROVIDE (__etext = .);}
30716dce513Schristos  ${RELOCATING+PROVIDE (_etext = .);}
30816dce513Schristos  ${RELOCATING+PROVIDE (etext = .);}
30916dce513Schristos  ${WRITABLE_RODATA-${RODATA}}
31016dce513Schristos  .rodata1      ${RELOCATING-0} : { *(.rodata1) }
31116dce513Schristos  ${CREATE_SHLIB-${SDATA2}}
31216dce513Schristos  ${CREATE_SHLIB-${SBSS2}}
31316dce513Schristos  ${OTHER_READONLY_SECTIONS}
314012573ebSchristos  .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) }
315012573ebSchristos  .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
31616dce513Schristos
31716dce513Schristos  /* Adjust the address for the data segment.  We want to adjust up to
31816dce513Schristos     the same address within the page on the next page up.  */
31916dce513Schristos  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
32016dce513Schristos  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
32116dce513Schristos  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
32216dce513Schristos
32316dce513Schristos  /* Exception handling  */
324012573ebSchristos  .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
32516dce513Schristos
32616dce513Schristos  /* Ensure the __preinit_array_start label is properly aligned.  We
32716dce513Schristos     could instead move the label definition inside the section, but
32816dce513Schristos     the linker would then create the section even if it turns out to
32916dce513Schristos     be empty, which isn't pretty.  */
33016dce513Schristos  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
33116dce513Schristos  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
33216dce513Schristos  .preinit_array   ${RELOCATING-0} : { *(.preinit_array) }
33316dce513Schristos  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
334*e992f068Schristos  ${RELOCATING+${INIT_ARRAY}}
335*e992f068Schristos  ${RELOCATING+${FINI_ARRAY}}
33616dce513Schristos
33716dce513Schristos  .data         ${RELOCATING-0} :
33816dce513Schristos  {
33916dce513Schristos    ${RELOCATING+${DATA_START_SYMBOLS}}
34016dce513Schristos    *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
34116dce513Schristos    ${CONSTRUCTING+SORT(CONSTRUCTORS)}
34216dce513Schristos  }
34316dce513Schristos  .data.init  ${RELOCATING-0} :
34416dce513Schristos  {
34516dce513Schristos    *(.data.init)
34616dce513Schristos  }
34716dce513Schristos  .data1        ${RELOCATING-0} : { *(.data1) }
34816dce513Schristos  .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
34916dce513Schristos  .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
35016dce513Schristos  .eh_frame     ${RELOCATING-0} : { KEEP (*(.eh_frame)) }
35116dce513Schristos  .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) }
35216dce513Schristos  ${WRITABLE_RODATA+${RODATA}}
35316dce513Schristos  ${OTHER_READWRITE_SECTIONS}
35416dce513Schristos  ${TEXT_DYNAMIC-${DYNAMIC}}
35516dce513Schristos  ${RELOCATING+${CTOR}}
35616dce513Schristos  ${RELOCATING+${DTOR}}
35716dce513Schristos  .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
35816dce513Schristos  ${DATA_PLT+${PLT}}
35916dce513Schristos  ${RELOCATING+${OTHER_GOT_SYMBOLS}}
36016dce513Schristos  ${GOT}
36116dce513Schristos  ${OTHER_GOT_SECTIONS}
36216dce513Schristos  ${CREATE_SHLIB+${SDATA2}}
36316dce513Schristos  ${CREATE_SHLIB+${SBSS2}}
36416dce513Schristos  ${SDATA}
36516dce513Schristos  ${OTHER_SDATA_SECTIONS}
36616dce513Schristos  ${RELOCATING+_edata = .;}
36716dce513Schristos  ${RELOCATING+PROVIDE (edata = .);}
36816dce513Schristos  ${RELOCATING+__bss_start = .;}
36916dce513Schristos  ${RELOCATING+${OTHER_BSS_SYMBOLS}}
37016dce513Schristos  ${SBSS}
37116dce513Schristos  ${BSS_PLT+${PLT}}
37216dce513Schristos  .bss          ${RELOCATING-0} :
37316dce513Schristos  {
374012573ebSchristos    ${RELOCATING+*(.dynbss)}
37516dce513Schristos    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
376012573ebSchristos    ${RELOCATING+*(COMMON)
37716dce513Schristos    /* Align here to ensure that the .bss section occupies space up to
37816dce513Schristos       _end.  Align after .bss to ensure correct alignment even if the
37916dce513Schristos       .bss section disappears because there are no input sections.  */
380012573ebSchristos    . = ALIGN(${ALIGNMENT});}
38116dce513Schristos  }
38216dce513Schristos  ${OTHER_BSS_SECTIONS}
38316dce513Schristos  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
38416dce513Schristos  ${RELOCATING+_end = .;}
38516dce513Schristos  ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
38616dce513Schristos  ${RELOCATING+PROVIDE (end = .);}
38716dce513Schristos  ${RELOCATING+${DATA_SEGMENT_END}}
388012573ebSchristosEOF
38916dce513Schristos
390012573ebSchristostest -n "${RELOCATING}" && cat <<EOF
39116dce513Schristos  /* We want to be able to set a default stack / heap size in a dejagnu
39216dce513Schristos     board description file, but override it for selected test cases.
39316dce513Schristos     The options appear in the wrong order to do this with a single symbol -
39416dce513Schristos     ldflags comes after flags injected with per-file stanzas, and thus
39516dce513Schristos     the setting from ldflags prevails.  */
396012573ebSchristos  .heap :
39716dce513Schristos  {
398012573ebSchristos	__start_heap = . ;
399012573ebSchristos	. = . + (DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : (DEFINED(__DEFAULT_HEAP_SIZE) ? __DEFAULT_HEAP_SIZE : 20k)) ;
400012573ebSchristos	__end_heap = . ;
40116dce513Schristos  }
40216dce513Schristos
403012573ebSchristos  . = ALIGN(0x8);
404012573ebSchristos  .stack :
40516dce513Schristos  {
406012573ebSchristos	__stack = . ;
407012573ebSchristos	. = . + (DEFINED(__STACK_SIZE) ? __STACK_SIZE : (DEFINED(__DEFAULT_STACK_SIZE) ? __DEFAULT_STACK_SIZE : 64k)) ;
408012573ebSchristos	__stack_top = . ;
40916dce513Schristos  }
410012573ebSchristosEOF
41116dce513Schristos
412012573ebSchristoscat <<EOF
41316dce513Schristos  /* Stabs debugging sections.  */
41416dce513Schristos  .stab          0 : { *(.stab) }
41516dce513Schristos  .stabstr       0 : { *(.stabstr) }
41616dce513Schristos  .stab.excl     0 : { *(.stab.excl) }
41716dce513Schristos  .stab.exclstr  0 : { *(.stab.exclstr) }
41816dce513Schristos  .stab.index    0 : { *(.stab.index) }
41916dce513Schristos  .stab.indexstr 0 : { *(.stab.indexstr) }
42016dce513Schristos
42116dce513Schristos  .comment       0 : { *(.comment) }
422012573ebSchristos  .note.gnu.build-id : { *(.note.gnu.build-id) }
423012573ebSchristosEOF
42416dce513Schristos
425012573ebSchristos. $srcdir/scripttempl/DWARF.sc
42616dce513Schristos
427012573ebSchristoscat <<EOF
42816dce513Schristos  /* ARC Extension Sections */
429012573ebSchristos  .arcextmap	  0 : { *(.arcextmap.*) }
43016dce513Schristos
43116dce513Schristos  ${OTHER_SECTIONS}
43216dce513Schristos  ${RELOCATING+${OTHER_END_SYMBOLS}}
43316dce513Schristos  ${RELOCATING+${STACKNOTE}}
43416dce513Schristos}
43516dce513SchristosEOF
436