1*e992f068Schristos# Copyright (C) 2014-2022 Free Software Foundation, Inc. 216dce513Schristos# 316dce513Schristos# Copying and distribution of this file, with or without modification, 416dce513Schristos# are permitted in any medium without royalty provided the copyright 516dce513Schristos# notice and this notice are preserved. 616dce513Schristos# 716dce513Schristos# Unusual variables checked by this code: 816dce513Schristos# NOP - four byte opcode for no-op (defaults to none) 916dce513Schristos# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not 1016dce513Schristos# empty. 1116dce513Schristos# SMALL_DATA_CTOR - .ctors contains small data. 1216dce513Schristos# SMALL_DATA_DTOR - .dtors contains small data. 1316dce513Schristos# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start 1416dce513Schristos# INITIAL_READONLY_SECTIONS - at start of text segment 1516dce513Schristos# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... 1616dce513Schristos# (e.g., .PARISC.milli) 1716dce513Schristos# OTHER_TEXT_SECTIONS - these get put in .text when relocating 1816dce513Schristos# INITIAL_READWRITE_SECTIONS - at start of data segment (after relro) 1916dce513Schristos# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... 2016dce513Schristos# (e.g., .PARISC.global) 2116dce513Schristos# OTHER_RELRO_SECTIONS - other than .data.rel.ro ... 2216dce513Schristos# (e.g. PPC32 .fixup, .got[12]) 2316dce513Schristos# OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment 2416dce513Schristos# OTHER_BSS_SECTIONS - other than .bss .sbss ... 2516dce513Schristos# ATTRS_SECTIONS - at the end 2616dce513Schristos# OTHER_SECTIONS - at the end 2716dce513Schristos# EXECUTABLE_SYMBOLS - symbols that must be defined for an 2816dce513Schristos# executable (e.g., _DYNAMIC_LINK) 2916dce513Schristos# TEXT_START_ADDR - the first byte of the text segment, after any 3016dce513Schristos# headers. 3116dce513Schristos# TEXT_BASE_ADDRESS - the first byte of the text segment. 3216dce513Schristos# TEXT_START_SYMBOLS - symbols that appear at the start of the 3316dce513Schristos# .text section. 3416dce513Schristos# DATA_START_SYMBOLS - symbols that appear at the start of the 3516dce513Schristos# .data section. 3616dce513Schristos# DATA_END_SYMBOLS - symbols that appear at the end of the 3716dce513Schristos# writeable data sections. 3816dce513Schristos# OTHER_GOT_SYMBOLS - symbols defined just before .got. 3916dce513Schristos# OTHER_GOT_SECTIONS - sections just after .got. 4016dce513Schristos# OTHER_SDATA_SECTIONS - sections just after .sdata. 4116dce513Schristos# OTHER_BSS_SYMBOLS - symbols that appear at the start of the 4216dce513Schristos# .bss section besides __bss_start. 4316dce513Schristos# PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment. 4416dce513Schristos# DATA_PLT - .plt should be in data segment, not text segment. 4516dce513Schristos# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. 4616dce513Schristos# BSS_PLT - .plt should be in bss segment 4716dce513Schristos# NO_REL_RELOCS - Don't include .rel.* sections in script 4816dce513Schristos# NO_RELA_RELOCS - Don't include .rela.* sections in script 4916dce513Schristos# NON_ALLOC_DYN - Place dynamic sections after data segment. 5016dce513Schristos# TEXT_DYNAMIC - .dynamic in text segment, not data segment. 5116dce513Schristos# EMBEDDED - whether this is for an embedded system. 5216dce513Schristos# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set 5316dce513Schristos# start address of shared library. 5416dce513Schristos# INPUT_FILES - INPUT command of files to always include 5516dce513Schristos# WRITABLE_RODATA - if set, the .rodata section should be writable 5616dce513Schristos# INIT_START, INIT_END - statements just before and just after 5716dce513Schristos# combination of .init sections. 5816dce513Schristos# FINI_START, FINI_END - statements just before and just after 5916dce513Schristos# combination of .fini sections. 6016dce513Schristos# STACK_ADDR - start of a .stack section. 6116dce513Schristos# OTHER_SYMBOLS - symbols to place right at the end of the script. 6216dce513Schristos# ETEXT_NAME - name of a symbol for the end of the text section, 6316dce513Schristos# normally etext. 6416dce513Schristos# SEPARATE_CODE - if set, .text and similar sections containing 6516dce513Schristos# actual machine instructions must be in wholly disjoint 6616dce513Schristos# pages from any other data, including headers 6716dce513Schristos# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, 6816dce513Schristos# so that .got can be in the RELRO area. It should be set to 6916dce513Schristos# the number of bytes in the beginning of .got.plt which can be 7016dce513Schristos# in the RELRO area as well. 7116dce513Schristos# USER_LABEL_PREFIX - prefix to add to user-visible symbols. 7216dce513Schristos# RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names 7316dce513Schristos# for standard sections, without initial "." or suffixes. 7416dce513Schristos# 7516dce513Schristos# When adding sections, do note that the names of some sections are used 7616dce513Schristos# when specifying the start address of the next. 7716dce513Schristos# 7816dce513Schristos 7916dce513Schristos# Many sections come in three flavours. There is the 'real' section, 8016dce513Schristos# like ".data". Then there are the per-procedure or per-variable 8116dce513Schristos# sections, generated by -ffunction-sections and -fdata-sections in GCC, 8216dce513Schristos# and useful for --gc-sections, which for a variable "foo" might be 8316dce513Schristos# ".data.foo". Then there are the linkonce sections, for which the linker 8416dce513Schristos# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". 8516dce513Schristos# The exact correspondences are: 8616dce513Schristos# 8716dce513Schristos# Section Linkonce section 8816dce513Schristos# .text .gnu.linkonce.t.foo 8916dce513Schristos# .rodata .gnu.linkonce.r.foo 9016dce513Schristos# .data .gnu.linkonce.d.foo 9116dce513Schristos# .bss .gnu.linkonce.b.foo 9216dce513Schristos# .sdata .gnu.linkonce.s.foo 9316dce513Schristos# .sbss .gnu.linkonce.sb.foo 9416dce513Schristos# .sdata2 .gnu.linkonce.s2.foo 9516dce513Schristos# .sbss2 .gnu.linkonce.sb2.foo 9616dce513Schristos# .debug_info .gnu.linkonce.wi.foo 9716dce513Schristos# .tdata .gnu.linkonce.td.foo 9816dce513Schristos# .tbss .gnu.linkonce.tb.foo 9916dce513Schristos# .lrodata .gnu.linkonce.lr.foo 10016dce513Schristos# .ldata .gnu.linkonce.l.foo 10116dce513Schristos# .lbss .gnu.linkonce.lb.foo 10216dce513Schristos# 10316dce513Schristos# Each of these can also have corresponding .rel.* and .rela.* sections. 10416dce513Schristos 10516dce513Schristosif test -n "$NOP"; then 10616dce513Schristos FILL="=$NOP" 10716dce513Schristoselse 10816dce513Schristos FILL= 10916dce513Schristosfi 11016dce513Schristos 11116dce513Schristostest -z "$RODATA_NAME" && RODATA_NAME=rodata 11216dce513Schristostest -z "$SDATA_NAME" && SDATA_NAME=sdata 11316dce513Schristostest -z "$SBSS_NAME" && SBSS_NAME=sbss 11416dce513Schristostest -z "$BSS_NAME" && BSS_NAME=bss 11516dce513Schristostest -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start 11616dce513Schristostest -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 11716dce513Schristostest -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 11816dce513Schristosif [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 11916dce513Schristostest -z "${ELFSIZE}" && ELFSIZE=32 12016dce513Schristostest -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" 12116dce513Schristostest "$LD_FLAG" = "N" && DATA_ADDR=. 12216dce513Schristostest -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext 12316dce513Schristostest -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" 12416dce513Schristostest -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" 12516dce513Schristostest -n "$RELRO_NOW" && unset SEPARATE_GOTPLT 12616dce513Schristostest -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" 12716dce513SchristosDATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 12816dce513SchristosDATA_SEGMENT_RELRO_END="" 12916dce513SchristosDATA_SEGMENT_END="" 13016dce513Schristosif test -n "${COMMONPAGESIZE}"; then 13116dce513Schristos if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then 13216dce513Schristos DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 13316dce513Schristos else 13416dce513Schristos DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 13516dce513Schristos fi 13616dce513Schristos DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" 13716dce513Schristos DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" 13816dce513Schristosfi 13916dce513Schristosif test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then 14016dce513Schristos INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" 14116dce513Schristosfi 14216dce513Schristosif test -z "$PLT"; then 14316dce513Schristos IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" 144012573ebSchristos PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} } 14516dce513Schristos ${IREL_IN_PLT-$IPLT}" 14616dce513Schristosfi 14716dce513Schristostest -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= 14816dce513Schristosif test -z "$GOT"; then 14916dce513Schristos if test -z "$SEPARATE_GOTPLT"; then 150012573ebSchristos GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }" 15116dce513Schristos else 152012573ebSchristos GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }" 153012573ebSchristos GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }" 15416dce513Schristos fi 15516dce513Schristosfi 15616dce513SchristosREL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" 15716dce513SchristosRELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" 15816dce513SchristosREL_IPLT=".rel.iplt ${RELOCATING-0} : 15916dce513Schristos { 16016dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} 16116dce513Schristos *(.rel.iplt) 16216dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} 16316dce513Schristos }" 16416dce513SchristosRELA_IPLT=".rela.iplt ${RELOCATING-0} : 16516dce513Schristos { 16616dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} 16716dce513Schristos *(.rela.iplt) 16816dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} 16916dce513Schristos }" 17016dce513SchristosDYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" 17116dce513SchristosRODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" 17216dce513SchristosDATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" 17316dce513SchristosDISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" 17416dce513Schristosif test -z "${NO_SMALL_DATA}"; then 17516dce513Schristos SBSS=".${SBSS_NAME} ${RELOCATING-0} : 17616dce513Schristos { 17716dce513Schristos ${RELOCATING+${SBSS_START_SYMBOLS}} 17816dce513Schristos ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)} 179012573ebSchristos ${RELOCATING+*(.dyn${SBSS_NAME})} 18016dce513Schristos *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*}) 181012573ebSchristos ${RELOCATING+*(.scommon)} 18216dce513Schristos ${RELOCATING+${SBSS_END_SYMBOLS}} 18316dce513Schristos }" 18416dce513Schristos SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" 18516dce513Schristos SDATA="/* We want the small data sections together, so single-instruction offsets 18616dce513Schristos can access them all, and initialized data all before uninitialized, so 18716dce513Schristos we can shorten the on-disk segment size. */ 18816dce513Schristos .${SDATA_NAME} ${RELOCATING-0} : 18916dce513Schristos { 19016dce513Schristos ${RELOCATING+${SDATA_START_SYMBOLS}} 19116dce513Schristos ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} 19216dce513Schristos *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) 19316dce513Schristos }" 19416dce513Schristos SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : 19516dce513Schristos { 19616dce513Schristos ${RELOCATING+${SDATA2_START_SYMBOLS}} 19716dce513Schristos *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) 19816dce513Schristos }" 19916dce513Schristos REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } 20016dce513Schristos .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" 20116dce513Schristos REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } 20216dce513Schristos .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" 20316dce513Schristos REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } 20416dce513Schristos .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" 20516dce513Schristos REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } 20616dce513Schristos .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" 20716dce513Schristoselse 20816dce513Schristos NO_SMALL_DATA=" " 20916dce513Schristosfi 21016dce513Schristosif test -z "${SDATA_GOT}${DATA_GOT}"; then 21116dce513Schristos if test -n "${NO_SMALL_DATA}"; then 21216dce513Schristos DATA_GOT=" " 21316dce513Schristos fi 21416dce513Schristosfi 21516dce513Schristosif test -z "${SDATA_GOT}${DATA_GOT}"; then 21616dce513Schristos if test -z "${NO_SMALL_DATA}"; then 21716dce513Schristos SDATA_GOT=" " 21816dce513Schristos fi 21916dce513Schristosfi 22016dce513Schristostest -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " 22116dce513Schristostest "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" 22216dce513Schristos .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } 22316dce513Schristos .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } 22416dce513Schristos .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } 22516dce513Schristos .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } 22616dce513Schristos .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } 22716dce513Schristos .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" 22816dce513Schristostest "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" 22916dce513Schristos .lbss ${RELOCATING-0} : 23016dce513Schristos { 23116dce513Schristos *(.dynlbss) 23216dce513Schristos *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) 23316dce513Schristos *(LARGE_COMMON) 23416dce513Schristos }" 23516dce513Schristostest "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" 23616dce513Schristos .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 23716dce513Schristos { 23816dce513Schristos *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) 23916dce513Schristos } 24016dce513Schristos .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 24116dce513Schristos { 24216dce513Schristos *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) 24316dce513Schristos ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 24416dce513Schristos }" 24516dce513Schristosif test "${ENABLE_INITFINI_ARRAY}" = "yes"; then 24616dce513Schristos SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" 24716dce513Schristos SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" 24816dce513Schristos CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" 24916dce513Schristos DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" 25016dce513Schristoselse 25116dce513Schristos SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" 25216dce513Schristos SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" 25316dce513Schristos CTORS_IN_INIT_ARRAY= 25416dce513Schristos DTORS_IN_FINI_ARRAY= 25516dce513Schristosfi 25616dce513SchristosINIT_ARRAY=".init_array ${RELOCATING-0} : 25716dce513Schristos { 25816dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} 25916dce513Schristos ${SORT_INIT_ARRAY} 26016dce513Schristos KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) 26116dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} 26216dce513Schristos }" 26316dce513SchristosFINI_ARRAY=".fini_array ${RELOCATING-0} : 26416dce513Schristos { 26516dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} 26616dce513Schristos ${SORT_FINI_ARRAY} 26716dce513Schristos KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) 26816dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} 26916dce513Schristos }" 27016dce513SchristosCTOR=".ctors ${CONSTRUCTING-0} : 27116dce513Schristos { 27216dce513Schristos ${CONSTRUCTING+${CTOR_START}} 27316dce513Schristos /* gcc uses crtbegin.o to find the start of 27416dce513Schristos the constructors, so we make sure it is 27516dce513Schristos first. Because this is a wildcard, it 27616dce513Schristos doesn't matter if the user does not 27716dce513Schristos actually link against crtbegin.o; the 27816dce513Schristos linker won't look for a file to match a 27916dce513Schristos wildcard. The wildcard also means that it 28016dce513Schristos doesn't matter which directory crtbegin.o 28116dce513Schristos is in. */ 28216dce513Schristos 28316dce513Schristos KEEP (*crtbegin.o(.ctors)) 28416dce513Schristos KEEP (*crtbegin?.o(.ctors)) 28516dce513Schristos 28616dce513Schristos /* We don't want to include the .ctor section from 28716dce513Schristos the crtend.o file until after the sorted ctors. 28816dce513Schristos The .ctor section from the crtend file contains the 28916dce513Schristos end of ctors marker and it must be last */ 29016dce513Schristos 29116dce513Schristos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) 29216dce513Schristos KEEP (*(SORT(.ctors.*))) 29316dce513Schristos KEEP (*(.ctors)) 29416dce513Schristos ${CONSTRUCTING+${CTOR_END}} 29516dce513Schristos }" 29616dce513SchristosDTOR=".dtors ${CONSTRUCTING-0} : 29716dce513Schristos { 29816dce513Schristos ${CONSTRUCTING+${DTOR_START}} 29916dce513Schristos KEEP (*crtbegin.o(.dtors)) 30016dce513Schristos KEEP (*crtbegin?.o(.dtors)) 30116dce513Schristos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) 30216dce513Schristos KEEP (*(SORT(.dtors.*))) 30316dce513Schristos KEEP (*(.dtors)) 30416dce513Schristos ${CONSTRUCTING+${DTOR_END}} 30516dce513Schristos }" 30616dce513SchristosSTACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : 30716dce513Schristos { 30816dce513Schristos ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} 30916dce513Schristos *(.stack) 310ede78133Schristos ${RELOCATING+${STACK_SENTINEL}} 31116dce513Schristos }" 31216dce513Schristos 31316dce513SchristosTEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" 31416dce513SchristosSHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" 31516dce513Schristos 31616dce513Schristosif [ -z "$SEPARATE_CODE" ]; then 31716dce513Schristos SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" 31816dce513Schristoselse 31916dce513Schristos SIZEOF_HEADERS_CODE= 32016dce513Schristosfi 32116dce513Schristos 32216dce513Schristos# If this is for an embedded system, don't add SIZEOF_HEADERS. 32316dce513Schristosif [ -z "$EMBEDDED" ]; then 32416dce513Schristos test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" 32516dce513Schristoselse 32616dce513Schristos test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" 32716dce513Schristosfi 32816dce513Schristos 32916dce513Schristoscat <<EOF 330*e992f068Schristos/* Copyright (C) 2014-2022 Free Software Foundation, Inc. 33116dce513Schristos 33216dce513Schristos Copying and distribution of this script, with or without modification, 33316dce513Schristos are permitted in any medium without royalty provided the copyright 33416dce513Schristos notice and this notice are preserved. */ 33516dce513Schristos 33616dce513SchristosOUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 33716dce513Schristos "${LITTLE_OUTPUT_FORMAT}") 33816dce513SchristosOUTPUT_ARCH(${OUTPUT_ARCH}) 33916dce513Schristos${RELOCATING+ENTRY(${ENTRY})} 34016dce513Schristos 34116dce513Schristos${RELOCATING+${LIB_SEARCH_DIRS}} 34216dce513Schristos${RELOCATING+${EXECUTABLE_SYMBOLS}} 34316dce513Schristos${RELOCATING+${INPUT_FILES}} 34416dce513Schristos${RELOCATING- /* For some reason, the Solaris linker makes bad executables 34516dce513Schristos if gld -r is used and the intermediate file has sections starting 34616dce513Schristos at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld 34716dce513Schristos bug. But for now assigning the zero vmas works. */} 34816dce513Schristos 34916dce513SchristosSECTIONS 35016dce513Schristos{ 35116dce513Schristos /* Read-only sections, merged into text segment: */ 35216dce513Schristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} 35316dce513Schristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 35416dce513Schristos ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 35516dce513SchristosEOF 35616dce513Schristos 35716dce513Schristosemit_early_ro() 35816dce513Schristos{ 35916dce513Schristos cat <<EOF 36016dce513Schristos ${INITIAL_READONLY_SECTIONS} 361012573ebSchristos .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) } 36216dce513SchristosEOF 36316dce513Schristos} 36416dce513Schristos 36516dce513Schristostest -n "${SEPARATE_CODE}" || emit_early_ro 36616dce513Schristos 36716dce513Schristostest -n "${RELOCATING+0}" || unset NON_ALLOC_DYN 36816dce513Schristostest -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= 36916dce513Schristoscat > ldscripts/dyntmp.$$ <<EOF 37016dce513Schristos ${TEXT_DYNAMIC+${DYNAMIC}} 37116dce513Schristos .hash ${RELOCATING-0} : { *(.hash) } 37216dce513Schristos .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } 37316dce513Schristos .dynsym ${RELOCATING-0} : { *(.dynsym) } 37416dce513Schristos .dynstr ${RELOCATING-0} : { *(.dynstr) } 37516dce513Schristos .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 37616dce513Schristos .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } 37716dce513Schristos .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } 37816dce513SchristosEOF 37916dce513Schristos 38016dce513Schristosif [ "x$COMBRELOC" = x ]; then 38116dce513Schristos COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" 38216dce513Schristoselse 38316dce513Schristos COMBRELOCCAT="cat > $COMBRELOC" 38416dce513Schristosfi 38516dce513Schristoseval $COMBRELOCCAT <<EOF 38616dce513Schristos ${INITIAL_RELOC_SECTIONS} 38716dce513Schristos .rel.init ${RELOCATING-0} : { *(.rel.init) } 38816dce513Schristos .rela.init ${RELOCATING-0} : { *(.rela.init) } 38916dce513Schristos .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } 39016dce513Schristos .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } 39116dce513Schristos .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 39216dce513Schristos .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 39316dce513Schristos .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } 39416dce513Schristos .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } 39516dce513Schristos ${OTHER_READONLY_RELOC_SECTIONS} 39616dce513Schristos .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) } 39716dce513Schristos .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) } 39816dce513Schristos .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } 39916dce513Schristos .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } 40016dce513Schristos ${OTHER_READWRITE_RELOC_SECTIONS} 40116dce513Schristos .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } 40216dce513Schristos .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } 40316dce513Schristos .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } 40416dce513Schristos .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } 40516dce513Schristos .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 40616dce513Schristos .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 40716dce513Schristos .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 40816dce513Schristos .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 40916dce513Schristos .rel.got ${RELOCATING-0} : { *(.rel.got) } 41016dce513Schristos .rela.got ${RELOCATING-0} : { *(.rela.got) } 41116dce513Schristos ${OTHER_GOT_RELOC_SECTIONS} 41216dce513Schristos ${REL_SDATA} 41316dce513Schristos ${REL_SBSS} 41416dce513Schristos ${REL_SDATA2} 41516dce513Schristos ${REL_SBSS2} 41616dce513Schristos .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } 41716dce513Schristos .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } 41816dce513Schristos ${REL_LARGE} 41916dce513Schristos ${IREL_IN_PLT+$REL_IFUNC} 42016dce513Schristos ${IREL_IN_PLT+$RELA_IFUNC} 42116dce513Schristos ${IREL_IN_PLT-$REL_IPLT} 42216dce513Schristos ${IREL_IN_PLT-$RELA_IPLT} 42316dce513SchristosEOF 42416dce513Schristos 42516dce513Schristosif [ -n "$COMBRELOC" ]; then 42616dce513Schristoscat >> ldscripts/dyntmp.$$ <<EOF 42716dce513Schristos .rel.dyn ${RELOCATING-0} : 42816dce513Schristos { 42916dce513SchristosEOF 43016dce513Schristossed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 43116dce513Schristoscat >> ldscripts/dyntmp.$$ <<EOF 43216dce513Schristos } 43316dce513Schristos .rela.dyn ${RELOCATING-0} : 43416dce513Schristos { 43516dce513SchristosEOF 43616dce513Schristossed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 43716dce513Schristoscat >> ldscripts/dyntmp.$$ <<EOF 43816dce513Schristos } 43916dce513SchristosEOF 44016dce513Schristosfi 44116dce513Schristos 44216dce513Schristoscat >> ldscripts/dyntmp.$$ <<EOF 44316dce513Schristos .rel.plt ${RELOCATING-0} : 44416dce513Schristos { 44516dce513Schristos *(.rel.plt) 44616dce513Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} 44716dce513Schristos ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} 44816dce513Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} 44916dce513Schristos } 45016dce513Schristos .rela.plt ${RELOCATING-0} : 45116dce513Schristos { 45216dce513Schristos *(.rela.plt) 45316dce513Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} 45416dce513Schristos ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} 45516dce513Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} 45616dce513Schristos } 45716dce513Schristos ${OTHER_PLT_RELOC_SECTIONS} 45816dce513SchristosEOF 45916dce513Schristos 46016dce513Schristosemit_dyn() 46116dce513Schristos{ 46216dce513Schristos if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then 46316dce513Schristos cat ldscripts/dyntmp.$$ 46416dce513Schristos else 46516dce513Schristos if test -z "${NO_REL_RELOCS}"; then 46616dce513Schristos sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$ 46716dce513Schristos fi 46816dce513Schristos if test -z "${NO_RELA_RELOCS}"; then 46916dce513Schristos sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$ 47016dce513Schristos fi 47116dce513Schristos fi 47216dce513Schristos rm -f ldscripts/dyntmp.$$ 47316dce513Schristos} 47416dce513Schristos 47516dce513Schristostest -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn 47616dce513Schristos 47716dce513Schristoscat <<EOF 47816dce513Schristos .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} : 47916dce513Schristos { 48016dce513Schristos ${RELOCATING+${INIT_START}} 48116dce513Schristos KEEP (*(SORT_NONE(.init))) 48216dce513Schristos ${RELOCATING+${INIT_END}} 48316dce513Schristos } ${FILL} 48416dce513Schristos 48516dce513Schristos ${TEXT_PLT+${PLT_NEXT_DATA-${PLT}}} 48616dce513Schristos ${TINY_READONLY_SECTION} 48716dce513Schristos .text ${RELOCATING-0} : 48816dce513Schristos { 48916dce513Schristos ${RELOCATING+${TEXT_START_SYMBOLS}} 49016dce513Schristos ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)} 49116dce513Schristos ${RELOCATING+*(.text.exit .text.exit.*)} 49216dce513Schristos ${RELOCATING+*(.text.startup .text.startup.*)} 49316dce513Schristos ${RELOCATING+*(.text.hot .text.hot.*)} 494012573ebSchristos ${RELOCATING+*(SORT(.text.sorted.*))} 49516dce513Schristos *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) 496012573ebSchristos /* .gnu.warning sections are handled specially by elf.em. */ 49716dce513Schristos *(.gnu.warning) 49816dce513Schristos ${RELOCATING+${OTHER_TEXT_SECTIONS}} 49916dce513Schristos } ${FILL} 50016dce513Schristos .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} : 50116dce513Schristos { 50216dce513Schristos ${RELOCATING+${FINI_START}} 50316dce513Schristos KEEP (*(SORT_NONE(.fini))) 50416dce513Schristos ${RELOCATING+${FINI_END}} 50516dce513Schristos } ${FILL} 50616dce513Schristos ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} 50716dce513Schristos ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} 50816dce513Schristos ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} 50916dce513SchristosEOF 51016dce513Schristos 51116dce513Schristosif test -n "${SEPARATE_CODE}"; then 51216dce513Schristos if test -n "${RODATA_ADDR}"; then 51316dce513Schristos RODATA_ADDR="\ 51416dce513SchristosSEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS" 51516dce513Schristos else 51616dce513Schristos RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 51716dce513Schristos RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})" 51816dce513Schristos fi 51916dce513Schristos if test -n "${SHLIB_RODATA_ADDR}"; then 52016dce513Schristos SHLIB_RODATA_ADDR="\ 52116dce513SchristosSEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" 52216dce513Schristos else 52316dce513Schristos SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" 52416dce513Schristos SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 52516dce513Schristos fi 52616dce513Schristos cat <<EOF 52716dce513Schristos /* Adjust the address for the rodata segment. We want to adjust up to 52816dce513Schristos the same address within the page on the next page up. */ 52916dce513Schristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}} 53016dce513Schristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} 53116dce513Schristos ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} 53216dce513SchristosEOF 53316dce513Schristos emit_early_ro 53416dce513Schristos emit_dyn 53516dce513Schristosfi 53616dce513Schristos 53716dce513Schristoscat <<EOF 53816dce513Schristos ${WRITABLE_RODATA-${RODATA}} 53916dce513Schristos .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } 54016dce513Schristos ${CREATE_SHLIB-${SDATA2}} 54116dce513Schristos ${CREATE_SHLIB-${SBSS2}} 54216dce513Schristos ${OTHER_READONLY_SECTIONS} 543012573ebSchristos .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) ${RELOCATING+*(.eh_frame_entry .eh_frame_entry.*)} } 54416dce513Schristos .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } 545012573ebSchristos .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } 54616dce513Schristos .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) } 54716dce513Schristos /* These sections are generated by the Sun/Oracle C++ compiler. */ 548012573ebSchristos .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) } 54916dce513Schristos ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}} 55016dce513Schristos 55116dce513Schristos /* Adjust the address for the data segment. We want to adjust up to 55216dce513Schristos the same address within the page on the next page up. */ 55316dce513Schristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} 55416dce513Schristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 55516dce513Schristos ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 55616dce513Schristos 55716dce513Schristos /* Exception handling */ 55816dce513Schristos .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } 55916dce513Schristos .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } 560012573ebSchristos .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } 561012573ebSchristos .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) } 56216dce513Schristos 56316dce513Schristos /* Thread Local Storage sections */ 564012573ebSchristos .tdata ${RELOCATING-0} : { ${RELOCATING+PROVIDE_HIDDEN(.tdata = .); }*(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } 565012573ebSchristos .tbss ${RELOCATING-0} : { ${RELOCATING+PROVIDE_HIDDEN(.tbss = .); }*(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } 56616dce513Schristos 56716dce513Schristos .preinit_array ${RELOCATING-0} : 56816dce513Schristos { 56916dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} 57016dce513Schristos KEEP (*(.preinit_array)) 57116dce513Schristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} 57216dce513Schristos } 57316dce513Schristos ${RELOCATING+${INIT_ARRAY}} 57416dce513Schristos ${RELOCATING+${FINI_ARRAY}} 57516dce513Schristos ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} 57616dce513Schristos ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} 57716dce513Schristos .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } 57816dce513Schristos 57916dce513Schristos ${RELOCATING+${DATARELRO}} 58016dce513Schristos ${OTHER_RELRO_SECTIONS} 58116dce513Schristos ${TEXT_DYNAMIC-${DYNAMIC}} 58216dce513Schristos ${OTHER_RELRO_SECTIONS_2} 58316dce513Schristos ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} 58416dce513Schristos ${DATA_GOT+${RELRO_NOW+${GOT}}} 58516dce513Schristos ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} 58616dce513Schristos ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} 58716dce513Schristos ${RELOCATING+${DATA_SEGMENT_RELRO_END}} 58816dce513Schristos ${INITIAL_READWRITE_SECTIONS} 58916dce513Schristos ${DATA_SDATA+${SDATA}} 59016dce513Schristos ${DATA_SDATA+${OTHER_SDATA_SECTIONS}} 59116dce513Schristos ${DATA_SDATA+${SBSS}} 59216dce513Schristos ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} 59316dce513Schristos ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} 59416dce513Schristos ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} 59516dce513Schristos 59616dce513Schristos ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} 59716dce513Schristos 59816dce513Schristos .data ${RELOCATING-0} : 59916dce513Schristos { 60016dce513Schristos ${RELOCATING+${DATA_START_SYMBOLS}} 60116dce513Schristos *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) 60216dce513Schristos ${CONSTRUCTING+SORT(CONSTRUCTORS)} 60316dce513Schristos } 60416dce513Schristos .data1 ${RELOCATING-0} : { *(.data1) } 60516dce513Schristos ${WRITABLE_RODATA+${RODATA}} 60616dce513Schristos ${OTHER_READWRITE_SECTIONS} 60716dce513Schristos ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} 60816dce513Schristos ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} 60916dce513Schristos ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}} 61016dce513Schristos ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}} 61116dce513Schristos ${SDATA_GOT+${GOT}} 61216dce513Schristos ${SDATA_GOT+${OTHER_GOT_SECTIONS}} 61316dce513Schristos ${DATA_SDATA-${SDATA}} 61416dce513Schristos ${DATA_SDATA-${OTHER_SDATA_SECTIONS}} 61516dce513Schristos ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} 61616dce513Schristos ${RELOCATING+. = .;} 61716dce513Schristos ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;} 61816dce513Schristos ${RELOCATING+${OTHER_BSS_SYMBOLS}} 61916dce513Schristos ${DATA_SDATA-${SBSS}} 62016dce513Schristos ${BSS_PLT+${PLT}} 62116dce513Schristos .${BSS_NAME} ${RELOCATING-0} : 62216dce513Schristos { 623012573ebSchristos ${RELOCATING+*(.dyn${BSS_NAME})} 62416dce513Schristos *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) 625012573ebSchristos ${RELOCATING+*(COMMON) 62616dce513Schristos /* Align here to ensure that the .bss section occupies space up to 62716dce513Schristos _end. Align after .bss to ensure correct alignment even if the 62816dce513Schristos .bss section disappears because there are no input sections. 629012573ebSchristos FIXME: Why do we need it? When there is no .bss section, we do not 63016dce513Schristos pad the .data section. */ 631012573ebSchristos . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 63216dce513Schristos } 63316dce513Schristos ${OTHER_BSS_SECTIONS} 63416dce513Schristos ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} 63516dce513Schristos ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} 63616dce513Schristos ${RELOCATING+. = ALIGN(${ALIGNMENT});} 63716dce513SchristosEOF 63816dce513Schristos 63916dce513SchristosLARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});" 64016dce513SchristosSHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});" 64116dce513Schristos 64216dce513Schristos cat <<EOF 64316dce513Schristos ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}} 64416dce513Schristos ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}} 64516dce513Schristos ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}} 64616dce513Schristos ${LARGE_SECTIONS} 64716dce513Schristos ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} 64816dce513Schristos ${RELOCATING+. = ALIGN(${ALIGNMENT});} 64916dce513Schristos ${RELOCATING+${OTHER_END_SYMBOLS}} 65016dce513Schristos ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} 65116dce513Schristos ${RELOCATING+${DATA_SEGMENT_END}} 652ede78133Schristos ${TINY_DATA_SECTION} 653ede78133Schristos ${TINY_BSS_SECTION} 654ede78133Schristos ${STACK_ADDR+${STACK}} 65516dce513SchristosEOF 65616dce513Schristos 65716dce513Schristostest -z "${NON_ALLOC_DYN}" || emit_dyn 65816dce513Schristos 65916dce513Schristoscat <<EOF 66016dce513Schristos /* Stabs debugging sections. */ 66116dce513Schristos .stab 0 : { *(.stab) } 66216dce513Schristos .stabstr 0 : { *(.stabstr) } 66316dce513Schristos .stab.excl 0 : { *(.stab.excl) } 66416dce513Schristos .stab.exclstr 0 : { *(.stab.exclstr) } 66516dce513Schristos .stab.index 0 : { *(.stab.index) } 66616dce513Schristos .stab.indexstr 0 : { *(.stab.indexstr) } 66716dce513Schristos 66816dce513Schristos .comment 0 : { *(.comment) } 66916dce513Schristos 67016dce513SchristosEOF 67116dce513Schristos 67216dce513Schristos. $srcdir/scripttempl/DWARF.sc 67316dce513Schristos 67416dce513Schristoscat <<EOF 67516dce513Schristos ${ATTRS_SECTIONS} 67616dce513Schristos ${OTHER_SECTIONS} 67716dce513Schristos ${RELOCATING+${OTHER_SYMBOLS}} 67816dce513Schristos ${RELOCATING+${DISCARDED}} 67916dce513Schristos} 68016dce513SchristosEOF 681