Home | History | Annotate | Line # | Download | only in scripttempl
      1 # Copyright (C) 2014-2025 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 #	OTHER_SECTIONS - at the end
     24 #	EXECUTABLE_SYMBOLS - symbols that must be defined for an
     25 #		executable (e.g., _DYNAMIC_LINK)
     26 #       TEXT_START_ADDR - the first byte of the text segment, after any
     27 #               headers.
     28 #       TEXT_BASE_ADDRESS - the first byte of the text segment.
     29 #	TEXT_START_SYMBOLS - symbols that appear at the start of the
     30 #		.text section.
     31 #	DATA_START_SYMBOLS - symbols that appear at the start of the
     32 #		.data section.
     33 #	OTHER_GOT_SYMBOLS - symbols defined just before .got.
     34 #	OTHER_GOT_SECTIONS - sections just after .got.
     35 #	OTHER_SDATA_SECTIONS - sections just after .sdata.
     36 #	OTHER_BSS_SYMBOLS - symbols that appear at the start of the
     37 #		.bss section besides __bss_start.
     38 #	DATA_PLT - .plt should be in data segment, not text segment.
     39 #	PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
     40 #	BSS_PLT - .plt should be in bss segment
     41 #	TEXT_DYNAMIC - .dynamic in text segment, not data segment.
     42 #	EMBEDDED - whether this is for an embedded system.
     43 #	SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
     44 #		start address of shared library.
     45 #	INPUT_FILES - INPUT command of files to always include
     46 #	WRITABLE_RODATA - if set, the .rodata section should be writable
     47 #	INIT_START, INIT_END -  statements just before and just after
     48 #	combination of .init sections.
     49 #	FINI_START, FINI_END - statements just before and just after
     50 #	combination of .fini sections.
     51 #	STACK_ADDR - start of a .stack section.
     52 #	OTHER_END_SYMBOLS - symbols to place right at the end of the script.
     53 #	SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
     54 #		so that .got can be in the RELRO area.  It should be set to
     55 #		the number of bytes in the beginning of .got.plt which can be
     56 #		in the RELRO area as well.
     57 #
     58 # When adding sections, do note that the names of some sections are used
     59 # when specifying the start address of the next.
     60 #
     61 
     62 #  Many sections come in three flavours.  There is the 'real' section,
     63 #  like ".data".  Then there are the per-procedure or per-variable
     64 #  sections, generated by -ffunction-sections and -fdata-sections in GCC,
     65 #  and useful for --gc-sections, which for a variable "foo" might be
     66 #  ".data.foo".  Then there are the linkonce sections, for which the linker
     67 #  eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
     68 #  The exact correspondences are:
     69 #
     70 #  Section	Linkonce section
     71 #  .text	.gnu.linkonce.t.foo
     72 #  .rodata	.gnu.linkonce.r.foo
     73 #  .data	.gnu.linkonce.d.foo
     74 #  .bss		.gnu.linkonce.b.foo
     75 #  .sdata	.gnu.linkonce.s.foo
     76 #  .sbss	.gnu.linkonce.sb.foo
     77 #  .sdata2	.gnu.linkonce.s2.foo
     78 #  .sbss2	.gnu.linkonce.sb2.foo
     79 #  .debug_info	.gnu.linkonce.wi.foo
     80 #  .tdata	.gnu.linkonce.td.foo
     81 #  .tbss	.gnu.linkonce.tb.foo
     82 #
     83 #  Each of these can also have corresponding .rel.* and .rela.* sections.
     84 
     85 test -z "$ENTRY" && ENTRY=_start
     86 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
     87 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
     88 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
     89 test -z "${ELFSIZE}" && ELFSIZE=32
     90 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
     91 test "$LD_FLAG" = "N" && DATA_ADDR=.
     92 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
     93 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
     94 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
     95 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
     96 DATA_SEGMENT_RELRO_END=""
     97 DATA_SEGMENT_RELRO_GOTPLT_END=""
     98 DATA_SEGMENT_END=""
     99 if test -n "${COMMONPAGESIZE}"; then
    100   DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
    101   DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
    102   if test -n "${SEPARATE_GOTPLT}"; then
    103     DATA_SEGMENT_RELRO_GOTPLT_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT}, .);"
    104   else
    105     DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (0, .);"
    106   fi
    107 fi
    108 INTERP=".interp       ${RELOCATING-0} : { *(.interp) }"
    109 PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
    110 if test -z "$GOT"; then
    111   if test -z "$SEPARATE_GOTPLT"; then
    112     GOT=".got          ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }"
    113   else
    114     GOT=".got          ${RELOCATING-0} : { *(.got) }"
    115     GOTPLT="${RELOCATING+${DATA_SEGMENT_RELRO_GOTPLT_END}}
    116   .got.plt      ${RELOCATING-0} : { *(.got.plt) }"
    117   fi
    118 fi
    119 DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
    120 RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
    121 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
    122 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
    123 if test -z "${NO_SMALL_DATA}"; then
    124   SBSS=".sbss         ${RELOCATING-0} :
    125   {
    126     ${RELOCATING+PROVIDE (__sbss_start = .);}
    127     ${RELOCATING+PROVIDE (___sbss_start = .);}
    128     ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
    129     ${RELOCATING+*(.dynsbss)}
    130     *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
    131     ${RELOCATING+*(.scommon)}
    132     ${RELOCATING+PROVIDE (__sbss_end = .);}
    133     ${RELOCATING+PROVIDE (___sbss_end = .);}
    134   }"
    135   SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
    136   SDATA="/* We want the small data sections together, so single-instruction offsets
    137      can access them all, and initialized data all before uninitialized, so
    138      we can shorten the on-disk segment size.  */
    139   .sdata        ${RELOCATING-0} :
    140   {
    141     ${RELOCATING+${SDATA_START_SYMBOLS}}
    142     ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
    143     *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
    144   }"
    145   SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
    146   REL_SDATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
    147   .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
    148   REL_SBSS=".rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
    149   .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
    150   REL_SDATA2=".rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
    151   .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
    152   REL_SBSS2=".rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
    153   .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
    154 else
    155   NO_SMALL_DATA=" "
    156 fi
    157 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
    158 CTOR=".ctors        ${CONSTRUCTING-0} :
    159   {
    160     ${CONSTRUCTING+${CTOR_START}}
    161     /* gcc uses crtbegin.o to find the start of
    162        the constructors, so we make sure it is
    163        first.  Because this is a wildcard, it
    164        doesn't matter if the user does not
    165        actually link against crtbegin.o; the
    166        linker won't look for a file to match a
    167        wildcard.  The wildcard also means that it
    168        doesn't matter which directory crtbegin.o
    169        is in.  */
    170 
    171     KEEP (*crtbegin*.o(.ctors))
    172 
    173     /* We don't want to include the .ctor section from
    174        from the crtend.o file until after the sorted ctors.
    175        The .ctor section from the crtend file contains the
    176        end of ctors marker and it must be last */
    177 
    178     KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
    179     KEEP (*(SORT(.ctors.*)))
    180     KEEP (*(.ctors))
    181     ${CONSTRUCTING+${CTOR_END}}
    182   }"
    183 DTOR=".dtors        ${CONSTRUCTING-0} :
    184   {
    185     ${CONSTRUCTING+${DTOR_START}}
    186     KEEP (*crtbegin*.o(.dtors))
    187     KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
    188     KEEP (*(SORT(.dtors.*)))
    189     KEEP (*(.dtors))
    190     ${CONSTRUCTING+${DTOR_END}}
    191   }"
    192 STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
    193   {
    194     ${RELOCATING+_stack = .;}
    195     *(.stack)
    196   }"
    197 
    198 # If this is for an embedded system, don't add SIZEOF_HEADERS.
    199 if [ -z "$EMBEDDED" ]; then
    200    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
    201 else
    202    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
    203 fi
    204 
    205 cat <<EOF
    206 /* Copyright (C) 2014-2025 Free Software Foundation, Inc.
    207 
    208    Copying and distribution of this script, with or without modification,
    209    are permitted in any medium without royalty provided the copyright
    210    notice and this notice are preserved.  */
    211 
    212 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
    213 	      "${LITTLE_OUTPUT_FORMAT}")
    214 OUTPUT_ARCH(${OUTPUT_ARCH})
    215 ${RELOCATING+ENTRY(${ENTRY})}
    216 
    217 ${RELOCATING+${LIB_SEARCH_DIRS}}
    218 ${RELOCATING+/* Do we need any of these for elf?
    219    __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
    220 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
    221 ${RELOCATING+${INPUT_FILES}}
    222 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
    223   if gld -r is used and the intermediate file has sections starting
    224   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
    225   bug.  But for now assigning the zero vmas works.  */}
    226 
    227 SECTIONS
    228 {
    229   /* Read-only sections, merged into text segment: */
    230   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
    231   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
    232   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
    233 
    234   /* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
    235      section is typically placed next to the ELF headers.  */
    236   .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
    237 
    238   ${CREATE_SHLIB-${INTERP}}
    239   ${INITIAL_READONLY_SECTIONS}
    240   ${TEXT_DYNAMIC+${DYNAMIC}}
    241   .hash         ${RELOCATING-0} : { *(.hash) }
    242   .dynsym       ${RELOCATING-0} : { *(.dynsym) }
    243   .dynstr       ${RELOCATING-0} : { *(.dynstr) }
    244   .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
    245   .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
    246   .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
    247 
    248 EOF
    249 if [ "x$COMBRELOC" = x ]; then
    250   COMBRELOCCAT=cat
    251 else
    252   COMBRELOCCAT="cat > $COMBRELOC"
    253 fi
    254 eval $COMBRELOCCAT <<EOF
    255   .rel.init     ${RELOCATING-0} : { *(.rel.init) }
    256   .rela.init    ${RELOCATING-0} : { *(.rela.init) }
    257   .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
    258   .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
    259   .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
    260   .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
    261   .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
    262   .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
    263   ${OTHER_READONLY_RELOC_SECTIONS}
    264   .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.*}) }
    265   .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.*}) }
    266   .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
    267   .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
    268   .rel.tdata	${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
    269   .rela.tdata	${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
    270   .rel.tbss	${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
    271   .rela.tbss	${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
    272   .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
    273   .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
    274   .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
    275   .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
    276   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
    277   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
    278   ${OTHER_GOT_RELOC_SECTIONS}
    279   ${REL_SDATA}
    280   ${REL_SBSS}
    281   ${REL_SDATA2}
    282   ${REL_SBSS2}
    283   .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
    284   .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
    285 EOF
    286 if [ -n "$COMBRELOC" ]; then
    287 cat <<EOF
    288   .rel.dyn      ${RELOCATING-0} :
    289     {
    290 EOF
    291 sed -e '/^[	 ]*[{}][	 ]*$/d;/:[	 ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC
    292 cat <<EOF
    293     }
    294   .rela.dyn     ${RELOCATING-0} :
    295     {
    296 EOF
    297 sed -e '/^[	 ]*[{}][	 ]*$/d;/:[	 ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC
    298 cat <<EOF
    299     }
    300 EOF
    301 fi
    302 cat <<EOF
    303   .rel.plt      ${RELOCATING-0} : { *(.rel.plt) }
    304   .rela.plt     ${RELOCATING-0} : { *(.rela.plt) }
    305   ${OTHER_PLT_RELOC_SECTIONS}
    306 
    307   .init         ${RELOCATING-0} :
    308   {
    309     ${RELOCATING+${INIT_START}}
    310     KEEP (*(SORT_NONE(.init)))
    311     ${RELOCATING+${INIT_END}}
    312   } =${NOP-0}
    313 
    314   ${DATA_PLT-${BSS_PLT-${PLT}}}
    315   .text         ${RELOCATING-0} :
    316   {
    317     ${RELOCATING+${TEXT_START_SYMBOLS}}
    318     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
    319     /* .gnu.warning sections are handled specially by elf.em.  */
    320     *(.gnu.warning)
    321     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
    322   } =${NOP-0}
    323   .fini         ${RELOCATING-0} :
    324   {
    325     ${RELOCATING+${FINI_START}}
    326     KEEP (*(SORT_NONE(.fini)))
    327     ${RELOCATING+${FINI_END}}
    328   } =${NOP-0}
    329   ${RELOCATING+PROVIDE (__etext = .);}
    330   ${RELOCATING+PROVIDE (_etext = .);}
    331   ${RELOCATING+PROVIDE (etext = .);}
    332   ${WRITABLE_RODATA-${RODATA}}
    333   .rodata1      ${RELOCATING-0} : { *(.rodata1) }
    334   ${CREATE_SHLIB-${SDATA2}}
    335   ${CREATE_SHLIB-${SBSS2}}
    336   ${OTHER_READONLY_SECTIONS}
    337   .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) }
    338   .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
    339   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table${RELOCATING+ .gcc_except_table.*})) }
    340 
    341   /* Adjust the address for the data segment.  We want to adjust up to
    342      the same address within the page on the next page up.  */
    343   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
    344   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
    345   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
    346 
    347   /* Exception handling  */
    348   .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
    349   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table${RELOCATING+ .gcc_except_table.*})) }
    350 
    351   /* Thread Local Storage sections  */
    352   .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
    353   .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
    354 
    355   .preinit_array   ${RELOCATING-0} : { KEEP (*(.preinit_array)) }
    356   .init_array   ${RELOCATING-0} : { KEEP (*(.init_array)) }
    357   .fini_array   ${RELOCATING-0} : { KEEP (*(.fini_array)) }
    358 
    359   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
    360   ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
    361   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
    362 
    363   ${RELOCATING+${DATARELRO}}
    364   ${OTHER_RELRO_SECTIONS}
    365   ${TEXT_DYNAMIC-${DYNAMIC}}
    366   ${NO_SMALL_DATA+${RELRO_NOW+${GOT}}}
    367   ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
    368   ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT+${GOTPLT}}}}
    369   ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
    370   ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
    371 
    372   ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
    373 
    374   .data         ${RELOCATING-0} :
    375   {
    376     ${RELOCATING+${DATA_START_SYMBOLS}}
    377     *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
    378     ${CONSTRUCTING+SORT(CONSTRUCTORS)}
    379   }
    380   .data1        ${RELOCATING-0} : { *(.data1) }
    381   ${WRITABLE_RODATA+${RODATA}}
    382   ${OTHER_READWRITE_SECTIONS}
    383   ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
    384   ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
    385   ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
    386   ${RELOCATING+${OTHER_GOT_SYMBOLS}}
    387   ${NO_SMALL_DATA-${GOT}}
    388   ${OTHER_GOT_SECTIONS}
    389   ${SDATA}
    390   ${OTHER_SDATA_SECTIONS}
    391   ${RELOCATING+_edata = .;}
    392   ${RELOCATING+PROVIDE (edata = .);}
    393   ${RELOCATING+. = ALIGN(ALIGNOF(NEXT_SECTION));}
    394   ${RELOCATING+__bss_start = .;}
    395   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
    396   ${SBSS}
    397   ${BSS_PLT+${PLT}}
    398   .bss          ${RELOCATING-0} :
    399   {
    400    ${RELOCATING+*(.dynbss)}
    401    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
    402    ${RELOCATING+*(COMMON)
    403    /* Align here to ensure that the .bss section occupies space up to
    404       _end.  Align after .bss to ensure correct alignment even if the
    405       .bss section disappears because there are no input sections.  */
    406    . = ALIGN(${ALIGNMENT});}
    407   }
    408   ${OTHER_BSS_SECTIONS}
    409   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
    410   ${RELOCATING+_end = .;}
    411   ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
    412   ${RELOCATING+PROVIDE (end = .);}
    413   ${RELOCATING+${DATA_SEGMENT_END}}
    414 
    415 EOF
    416 
    417 source_sh $srcdir/scripttempl/misc-sections.sc
    418 source_sh $srcdir/scripttempl/DWARF.sc
    419 
    420 cat <<EOF
    421   ${STACK_ADDR+${STACK}}
    422   ${OTHER_SECTIONS}
    423   ${RELOCATING+${OTHER_END_SYMBOLS}}
    424   ${RELOCATING+${DISCARDED}}
    425 }
    426 EOF
    427