1*b88e3e88Schristos# Copyright (C) 2014-2020 Free Software Foundation, Inc. 2440a403fSchristos# 3440a403fSchristos# Copying and distribution of this file, with or without modification, 4440a403fSchristos# are permitted in any medium without royalty provided the copyright 5440a403fSchristos# notice and this notice are preserved. 6440a403fSchristos# 7440a403fSchristos# Unusual variables checked by this code: 8440a403fSchristos# NOP - four byte opcode for no-op (defaults to none) 9440a403fSchristos# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not 10440a403fSchristos# empty. 11440a403fSchristos# SMALL_DATA_CTOR - .ctors contains small data. 12440a403fSchristos# SMALL_DATA_DTOR - .dtors contains small data. 13440a403fSchristos# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start 14440a403fSchristos# INITIAL_READONLY_SECTIONS - at start of text segment 15440a403fSchristos# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... 16440a403fSchristos# (e.g., .PARISC.milli) 17440a403fSchristos# OTHER_TEXT_SECTIONS - these get put in .text when relocating 18440a403fSchristos# INITIAL_READWRITE_SECTIONS - at start of data segment (after relro) 19440a403fSchristos# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... 20440a403fSchristos# (e.g., .PARISC.global) 21440a403fSchristos# OTHER_RELRO_SECTIONS - other than .data.rel.ro ... 22440a403fSchristos# (e.g. PPC32 .fixup, .got[12]) 23440a403fSchristos# OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment 24440a403fSchristos# OTHER_BSS_SECTIONS - other than .bss .sbss ... 25440a403fSchristos# ATTRS_SECTIONS - at the end 26440a403fSchristos# OTHER_SECTIONS - at the end 27440a403fSchristos# EXECUTABLE_SYMBOLS - symbols that must be defined for an 28440a403fSchristos# executable (e.g., _DYNAMIC_LINK) 29440a403fSchristos# TEXT_START_ADDR - the first byte of the text segment, after any 30440a403fSchristos# headers. 31440a403fSchristos# TEXT_BASE_ADDRESS - the first byte of the text segment. 32440a403fSchristos# TEXT_START_SYMBOLS - symbols that appear at the start of the 33440a403fSchristos# .text section. 34440a403fSchristos# DATA_START_SYMBOLS - symbols that appear at the start of the 35440a403fSchristos# .data section. 36440a403fSchristos# DATA_END_SYMBOLS - symbols that appear at the end of the 37440a403fSchristos# writeable data sections. 38440a403fSchristos# OTHER_GOT_SYMBOLS - symbols defined just before .got. 39440a403fSchristos# OTHER_GOT_SECTIONS - sections just after .got. 40440a403fSchristos# OTHER_SDATA_SECTIONS - sections just after .sdata. 41440a403fSchristos# OTHER_BSS_SYMBOLS - symbols that appear at the start of the 42440a403fSchristos# .bss section besides __bss_start. 43440a403fSchristos# PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment. 44440a403fSchristos# DATA_PLT - .plt should be in data segment, not text segment. 45440a403fSchristos# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. 46440a403fSchristos# BSS_PLT - .plt should be in bss segment 47440a403fSchristos# NO_REL_RELOCS - Don't include .rel.* sections in script 48440a403fSchristos# NO_RELA_RELOCS - Don't include .rela.* sections in script 49440a403fSchristos# NON_ALLOC_DYN - Place dynamic sections after data segment. 50440a403fSchristos# TEXT_DYNAMIC - .dynamic in text segment, not data segment. 51440a403fSchristos# EMBEDDED - whether this is for an embedded system. 52440a403fSchristos# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set 53440a403fSchristos# start address of shared library. 54440a403fSchristos# INPUT_FILES - INPUT command of files to always include 55440a403fSchristos# WRITABLE_RODATA - if set, the .rodata section should be writable 56440a403fSchristos# INIT_START, INIT_END - statements just before and just after 57440a403fSchristos# combination of .init sections. 58440a403fSchristos# FINI_START, FINI_END - statements just before and just after 59440a403fSchristos# combination of .fini sections. 60440a403fSchristos# STACK_ADDR - start of a .stack section. 61440a403fSchristos# OTHER_SYMBOLS - symbols to place right at the end of the script. 62440a403fSchristos# ETEXT_NAME - name of a symbol for the end of the text section, 63440a403fSchristos# normally etext. 64440a403fSchristos# SEPARATE_CODE - if set, .text and similar sections containing 65440a403fSchristos# actual machine instructions must be in wholly disjoint 66440a403fSchristos# pages from any other data, including headers 67440a403fSchristos# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, 68440a403fSchristos# so that .got can be in the RELRO area. It should be set to 69440a403fSchristos# the number of bytes in the beginning of .got.plt which can be 70440a403fSchristos# in the RELRO area as well. 71440a403fSchristos# USER_LABEL_PREFIX - prefix to add to user-visible symbols. 72440a403fSchristos# RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names 73440a403fSchristos# for standard sections, without initial "." or suffixes. 74440a403fSchristos# 75440a403fSchristos# When adding sections, do note that the names of some sections are used 76440a403fSchristos# when specifying the start address of the next. 77440a403fSchristos# 78440a403fSchristos 79440a403fSchristos# Many sections come in three flavours. There is the 'real' section, 80440a403fSchristos# like ".data". Then there are the per-procedure or per-variable 81440a403fSchristos# sections, generated by -ffunction-sections and -fdata-sections in GCC, 82440a403fSchristos# and useful for --gc-sections, which for a variable "foo" might be 83440a403fSchristos# ".data.foo". Then there are the linkonce sections, for which the linker 84440a403fSchristos# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". 85440a403fSchristos# The exact correspondences are: 86440a403fSchristos# 87440a403fSchristos# Section Linkonce section 88440a403fSchristos# .text .gnu.linkonce.t.foo 89440a403fSchristos# .rodata .gnu.linkonce.r.foo 90440a403fSchristos# .data .gnu.linkonce.d.foo 91440a403fSchristos# .bss .gnu.linkonce.b.foo 92440a403fSchristos# .sdata .gnu.linkonce.s.foo 93440a403fSchristos# .sbss .gnu.linkonce.sb.foo 94440a403fSchristos# .sdata2 .gnu.linkonce.s2.foo 95440a403fSchristos# .sbss2 .gnu.linkonce.sb2.foo 96440a403fSchristos# .debug_info .gnu.linkonce.wi.foo 97440a403fSchristos# .tdata .gnu.linkonce.td.foo 98440a403fSchristos# .tbss .gnu.linkonce.tb.foo 99440a403fSchristos# .lrodata .gnu.linkonce.lr.foo 100440a403fSchristos# .ldata .gnu.linkonce.l.foo 101440a403fSchristos# .lbss .gnu.linkonce.lb.foo 102440a403fSchristos# 103440a403fSchristos# Each of these can also have corresponding .rel.* and .rela.* sections. 104440a403fSchristos 105440a403fSchristosif test -n "$NOP"; then 106440a403fSchristos FILL="=$NOP" 107440a403fSchristoselse 108440a403fSchristos FILL= 109440a403fSchristosfi 110440a403fSchristos 111440a403fSchristostest -z "$RODATA_NAME" && RODATA_NAME=rodata 112440a403fSchristostest -z "$SDATA_NAME" && SDATA_NAME=sdata 113440a403fSchristostest -z "$SBSS_NAME" && SBSS_NAME=sbss 114440a403fSchristostest -z "$BSS_NAME" && BSS_NAME=bss 115440a403fSchristostest -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start 116440a403fSchristostest -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 117440a403fSchristostest -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 118440a403fSchristosif [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 119440a403fSchristostest -z "${ELFSIZE}" && ELFSIZE=32 120440a403fSchristostest -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" 121440a403fSchristostest "$LD_FLAG" = "N" && DATA_ADDR=. 122440a403fSchristostest -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext 123440a403fSchristostest -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" 124440a403fSchristostest -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" 125440a403fSchristostest -n "$RELRO_NOW" && unset SEPARATE_GOTPLT 126440a403fSchristostest -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" 127440a403fSchristosDATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 128440a403fSchristosDATA_SEGMENT_RELRO_END="" 129440a403fSchristosDATA_SEGMENT_END="" 130440a403fSchristosif test -n "${COMMONPAGESIZE}"; then 131440a403fSchristos if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then 132440a403fSchristos DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 133440a403fSchristos else 134440a403fSchristos DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 135440a403fSchristos fi 136440a403fSchristos DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" 137440a403fSchristos DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" 138440a403fSchristosfi 139440a403fSchristosif test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then 140440a403fSchristos INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" 141440a403fSchristosfi 142440a403fSchristosif test -z "$PLT"; then 143440a403fSchristos IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" 144*b88e3e88Schristos PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} } 145440a403fSchristos ${IREL_IN_PLT-$IPLT}" 146440a403fSchristosfi 147440a403fSchristostest -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= 148440a403fSchristosif test -z "$GOT"; then 149440a403fSchristos if test -z "$SEPARATE_GOTPLT"; then 150*b88e3e88Schristos GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }" 151440a403fSchristos else 152*b88e3e88Schristos GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }" 153*b88e3e88Schristos GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }" 154440a403fSchristos fi 155440a403fSchristosfi 156440a403fSchristosREL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" 157440a403fSchristosRELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" 158440a403fSchristosREL_IPLT=".rel.iplt ${RELOCATING-0} : 159440a403fSchristos { 160440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} 161440a403fSchristos *(.rel.iplt) 162440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} 163440a403fSchristos }" 164440a403fSchristosRELA_IPLT=".rela.iplt ${RELOCATING-0} : 165440a403fSchristos { 166440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} 167440a403fSchristos *(.rela.iplt) 168440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} 169440a403fSchristos }" 170440a403fSchristosDYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" 171440a403fSchristosRODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" 172440a403fSchristosDATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" 173440a403fSchristosDISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" 174440a403fSchristosif test -z "${NO_SMALL_DATA}"; then 175440a403fSchristos SBSS=".${SBSS_NAME} ${RELOCATING-0} : 176440a403fSchristos { 177440a403fSchristos ${RELOCATING+${SBSS_START_SYMBOLS}} 178440a403fSchristos ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)} 179*b88e3e88Schristos ${RELOCATING+*(.dyn${SBSS_NAME})} 180440a403fSchristos *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*}) 181*b88e3e88Schristos ${RELOCATING+*(.scommon)} 182440a403fSchristos ${RELOCATING+${SBSS_END_SYMBOLS}} 183440a403fSchristos }" 184440a403fSchristos SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" 185440a403fSchristos SDATA="/* We want the small data sections together, so single-instruction offsets 186440a403fSchristos can access them all, and initialized data all before uninitialized, so 187440a403fSchristos we can shorten the on-disk segment size. */ 188440a403fSchristos .${SDATA_NAME} ${RELOCATING-0} : 189440a403fSchristos { 190440a403fSchristos ${RELOCATING+${SDATA_START_SYMBOLS}} 191440a403fSchristos ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} 192440a403fSchristos *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) 193440a403fSchristos }" 194440a403fSchristos SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : 195440a403fSchristos { 196440a403fSchristos ${RELOCATING+${SDATA2_START_SYMBOLS}} 197440a403fSchristos *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) 198440a403fSchristos }" 199440a403fSchristos REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } 200440a403fSchristos .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" 201440a403fSchristos REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } 202440a403fSchristos .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" 203440a403fSchristos REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } 204440a403fSchristos .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" 205440a403fSchristos REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } 206440a403fSchristos .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" 207440a403fSchristoselse 208440a403fSchristos NO_SMALL_DATA=" " 209440a403fSchristosfi 210440a403fSchristosif test -z "${SDATA_GOT}${DATA_GOT}"; then 211440a403fSchristos if test -n "${NO_SMALL_DATA}"; then 212440a403fSchristos DATA_GOT=" " 213440a403fSchristos fi 214440a403fSchristosfi 215440a403fSchristosif test -z "${SDATA_GOT}${DATA_GOT}"; then 216440a403fSchristos if test -z "${NO_SMALL_DATA}"; then 217440a403fSchristos SDATA_GOT=" " 218440a403fSchristos fi 219440a403fSchristosfi 220440a403fSchristostest -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " 221440a403fSchristostest "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" 222440a403fSchristos .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } 223440a403fSchristos .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } 224440a403fSchristos .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } 225440a403fSchristos .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } 226440a403fSchristos .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } 227440a403fSchristos .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" 228440a403fSchristostest "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" 229440a403fSchristos .lbss ${RELOCATING-0} : 230440a403fSchristos { 231440a403fSchristos *(.dynlbss) 232440a403fSchristos *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) 233440a403fSchristos *(LARGE_COMMON) 234440a403fSchristos }" 235440a403fSchristostest "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" 236440a403fSchristos .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 237440a403fSchristos { 238440a403fSchristos *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) 239440a403fSchristos } 240440a403fSchristos .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 241440a403fSchristos { 242440a403fSchristos *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) 243440a403fSchristos ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 244440a403fSchristos }" 245440a403fSchristosif test "${ENABLE_INITFINI_ARRAY}" = "yes"; then 246440a403fSchristos SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" 247440a403fSchristos SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" 248440a403fSchristos CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" 249440a403fSchristos DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" 250440a403fSchristoselse 251440a403fSchristos SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" 252440a403fSchristos SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" 253440a403fSchristos CTORS_IN_INIT_ARRAY= 254440a403fSchristos DTORS_IN_FINI_ARRAY= 255440a403fSchristosfi 256440a403fSchristosINIT_ARRAY=".init_array ${RELOCATING-0} : 257440a403fSchristos { 258440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} 259440a403fSchristos ${SORT_INIT_ARRAY} 260440a403fSchristos KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) 261440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} 262440a403fSchristos }" 263440a403fSchristosFINI_ARRAY=".fini_array ${RELOCATING-0} : 264440a403fSchristos { 265440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} 266440a403fSchristos ${SORT_FINI_ARRAY} 267440a403fSchristos KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) 268440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} 269440a403fSchristos }" 270440a403fSchristosCTOR=".ctors ${CONSTRUCTING-0} : 271440a403fSchristos { 272440a403fSchristos ${CONSTRUCTING+${CTOR_START}} 273440a403fSchristos /* gcc uses crtbegin.o to find the start of 274440a403fSchristos the constructors, so we make sure it is 275440a403fSchristos first. Because this is a wildcard, it 276440a403fSchristos doesn't matter if the user does not 277440a403fSchristos actually link against crtbegin.o; the 278440a403fSchristos linker won't look for a file to match a 279440a403fSchristos wildcard. The wildcard also means that it 280440a403fSchristos doesn't matter which directory crtbegin.o 281440a403fSchristos is in. */ 282440a403fSchristos 283440a403fSchristos KEEP (*crtbegin.o(.ctors)) 284440a403fSchristos KEEP (*crtbegin?.o(.ctors)) 285440a403fSchristos 286440a403fSchristos /* We don't want to include the .ctor section from 287440a403fSchristos the crtend.o file until after the sorted ctors. 288440a403fSchristos The .ctor section from the crtend file contains the 289440a403fSchristos end of ctors marker and it must be last */ 290440a403fSchristos 291440a403fSchristos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) 292440a403fSchristos KEEP (*(SORT(.ctors.*))) 293440a403fSchristos KEEP (*(.ctors)) 294440a403fSchristos ${CONSTRUCTING+${CTOR_END}} 295440a403fSchristos }" 296440a403fSchristosDTOR=".dtors ${CONSTRUCTING-0} : 297440a403fSchristos { 298440a403fSchristos ${CONSTRUCTING+${DTOR_START}} 299440a403fSchristos KEEP (*crtbegin.o(.dtors)) 300440a403fSchristos KEEP (*crtbegin?.o(.dtors)) 301440a403fSchristos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) 302440a403fSchristos KEEP (*(SORT(.dtors.*))) 303440a403fSchristos KEEP (*(.dtors)) 304440a403fSchristos ${CONSTRUCTING+${DTOR_END}} 305440a403fSchristos }" 306440a403fSchristosSTACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : 307440a403fSchristos { 308440a403fSchristos ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} 309440a403fSchristos *(.stack) 31006324dcfSchristos ${RELOCATING+${STACK_SENTINEL}} 311440a403fSchristos }" 312440a403fSchristos 313440a403fSchristosTEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" 314440a403fSchristosSHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" 315440a403fSchristos 316440a403fSchristosif [ -z "$SEPARATE_CODE" ]; then 317440a403fSchristos SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" 318440a403fSchristoselse 319440a403fSchristos SIZEOF_HEADERS_CODE= 320440a403fSchristosfi 321440a403fSchristos 322440a403fSchristos# If this is for an embedded system, don't add SIZEOF_HEADERS. 323440a403fSchristosif [ -z "$EMBEDDED" ]; then 324440a403fSchristos test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" 325440a403fSchristoselse 326440a403fSchristos test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" 327440a403fSchristosfi 328440a403fSchristos 329440a403fSchristoscat <<EOF 330*b88e3e88Schristos/* Copyright (C) 2014-2020 Free Software Foundation, Inc. 331440a403fSchristos 332440a403fSchristos Copying and distribution of this script, with or without modification, 333440a403fSchristos are permitted in any medium without royalty provided the copyright 334440a403fSchristos notice and this notice are preserved. */ 335440a403fSchristos 336440a403fSchristosOUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 337440a403fSchristos "${LITTLE_OUTPUT_FORMAT}") 338440a403fSchristosOUTPUT_ARCH(${OUTPUT_ARCH}) 339440a403fSchristos${RELOCATING+ENTRY(${ENTRY})} 340440a403fSchristos 341440a403fSchristos${RELOCATING+${LIB_SEARCH_DIRS}} 342440a403fSchristos${RELOCATING+${EXECUTABLE_SYMBOLS}} 343440a403fSchristos${RELOCATING+${INPUT_FILES}} 344440a403fSchristos${RELOCATING- /* For some reason, the Solaris linker makes bad executables 345440a403fSchristos if gld -r is used and the intermediate file has sections starting 346440a403fSchristos at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld 347440a403fSchristos bug. But for now assigning the zero vmas works. */} 348440a403fSchristos 349440a403fSchristosSECTIONS 350440a403fSchristos{ 351440a403fSchristos /* Read-only sections, merged into text segment: */ 352440a403fSchristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} 353440a403fSchristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 354440a403fSchristos ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 355440a403fSchristosEOF 356440a403fSchristos 357440a403fSchristosemit_early_ro() 358440a403fSchristos{ 359440a403fSchristos cat <<EOF 360440a403fSchristos ${INITIAL_READONLY_SECTIONS} 361*b88e3e88Schristos .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) } 362440a403fSchristosEOF 363440a403fSchristos} 364440a403fSchristos 365440a403fSchristostest -n "${SEPARATE_CODE}" || emit_early_ro 366440a403fSchristos 367440a403fSchristostest -n "${RELOCATING+0}" || unset NON_ALLOC_DYN 368440a403fSchristostest -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= 369440a403fSchristoscat > ldscripts/dyntmp.$$ <<EOF 370440a403fSchristos ${TEXT_DYNAMIC+${DYNAMIC}} 371440a403fSchristos .hash ${RELOCATING-0} : { *(.hash) } 372440a403fSchristos .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } 373440a403fSchristos .dynsym ${RELOCATING-0} : { *(.dynsym) } 374440a403fSchristos .dynstr ${RELOCATING-0} : { *(.dynstr) } 375440a403fSchristos .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 376440a403fSchristos .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } 377440a403fSchristos .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } 378440a403fSchristosEOF 379440a403fSchristos 380440a403fSchristosif [ "x$COMBRELOC" = x ]; then 381440a403fSchristos COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" 382440a403fSchristoselse 383440a403fSchristos COMBRELOCCAT="cat > $COMBRELOC" 384440a403fSchristosfi 385440a403fSchristoseval $COMBRELOCCAT <<EOF 386440a403fSchristos ${INITIAL_RELOC_SECTIONS} 387440a403fSchristos .rel.init ${RELOCATING-0} : { *(.rel.init) } 388440a403fSchristos .rela.init ${RELOCATING-0} : { *(.rela.init) } 389440a403fSchristos .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } 390440a403fSchristos .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } 391440a403fSchristos .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 392440a403fSchristos .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 393440a403fSchristos .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } 394440a403fSchristos .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } 395440a403fSchristos ${OTHER_READONLY_RELOC_SECTIONS} 396440a403fSchristos .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) } 397440a403fSchristos .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) } 398440a403fSchristos .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } 399440a403fSchristos .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } 400440a403fSchristos ${OTHER_READWRITE_RELOC_SECTIONS} 401440a403fSchristos .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } 402440a403fSchristos .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } 403440a403fSchristos .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } 404440a403fSchristos .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } 405440a403fSchristos .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 406440a403fSchristos .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 407440a403fSchristos .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 408440a403fSchristos .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 409440a403fSchristos .rel.got ${RELOCATING-0} : { *(.rel.got) } 410440a403fSchristos .rela.got ${RELOCATING-0} : { *(.rela.got) } 411440a403fSchristos ${OTHER_GOT_RELOC_SECTIONS} 412440a403fSchristos ${REL_SDATA} 413440a403fSchristos ${REL_SBSS} 414440a403fSchristos ${REL_SDATA2} 415440a403fSchristos ${REL_SBSS2} 416440a403fSchristos .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } 417440a403fSchristos .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } 418440a403fSchristos ${REL_LARGE} 419440a403fSchristos ${IREL_IN_PLT+$REL_IFUNC} 420440a403fSchristos ${IREL_IN_PLT+$RELA_IFUNC} 421440a403fSchristos ${IREL_IN_PLT-$REL_IPLT} 422440a403fSchristos ${IREL_IN_PLT-$RELA_IPLT} 423440a403fSchristosEOF 424440a403fSchristos 425440a403fSchristosif [ -n "$COMBRELOC" ]; then 426440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 427440a403fSchristos .rel.dyn ${RELOCATING-0} : 428440a403fSchristos { 429440a403fSchristosEOF 430440a403fSchristossed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 431440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 432440a403fSchristos } 433440a403fSchristos .rela.dyn ${RELOCATING-0} : 434440a403fSchristos { 435440a403fSchristosEOF 436440a403fSchristossed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 437440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 438440a403fSchristos } 439440a403fSchristosEOF 440440a403fSchristosfi 441440a403fSchristos 442440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 443440a403fSchristos .rel.plt ${RELOCATING-0} : 444440a403fSchristos { 445440a403fSchristos *(.rel.plt) 446440a403fSchristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} 447440a403fSchristos ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} 448440a403fSchristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} 449440a403fSchristos } 450440a403fSchristos .rela.plt ${RELOCATING-0} : 451440a403fSchristos { 452440a403fSchristos *(.rela.plt) 453440a403fSchristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} 454440a403fSchristos ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} 455440a403fSchristos ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} 456440a403fSchristos } 457440a403fSchristos ${OTHER_PLT_RELOC_SECTIONS} 458440a403fSchristosEOF 459440a403fSchristos 460440a403fSchristosemit_dyn() 461440a403fSchristos{ 462440a403fSchristos if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then 463440a403fSchristos cat ldscripts/dyntmp.$$ 464440a403fSchristos else 465440a403fSchristos if test -z "${NO_REL_RELOCS}"; then 466440a403fSchristos sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$ 467440a403fSchristos fi 468440a403fSchristos if test -z "${NO_RELA_RELOCS}"; then 469440a403fSchristos sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$ 470440a403fSchristos fi 471440a403fSchristos fi 472440a403fSchristos rm -f ldscripts/dyntmp.$$ 473440a403fSchristos} 474440a403fSchristos 475440a403fSchristostest -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn 476440a403fSchristos 477440a403fSchristoscat <<EOF 478440a403fSchristos .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} : 479440a403fSchristos { 480440a403fSchristos ${RELOCATING+${INIT_START}} 481440a403fSchristos KEEP (*(SORT_NONE(.init))) 482440a403fSchristos ${RELOCATING+${INIT_END}} 483440a403fSchristos } ${FILL} 484440a403fSchristos 485440a403fSchristos ${TEXT_PLT+${PLT_NEXT_DATA-${PLT}}} 486440a403fSchristos ${TINY_READONLY_SECTION} 487440a403fSchristos .text ${RELOCATING-0} : 488440a403fSchristos { 489440a403fSchristos ${RELOCATING+${TEXT_START_SYMBOLS}} 490440a403fSchristos ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)} 491440a403fSchristos ${RELOCATING+*(.text.exit .text.exit.*)} 492440a403fSchristos ${RELOCATING+*(.text.startup .text.startup.*)} 493440a403fSchristos ${RELOCATING+*(.text.hot .text.hot.*)} 494*b88e3e88Schristos ${RELOCATING+*(SORT(.text.sorted.*))} 495440a403fSchristos *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) 496*b88e3e88Schristos /* .gnu.warning sections are handled specially by elf.em. */ 497440a403fSchristos *(.gnu.warning) 498440a403fSchristos ${RELOCATING+${OTHER_TEXT_SECTIONS}} 499440a403fSchristos } ${FILL} 500440a403fSchristos .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} : 501440a403fSchristos { 502440a403fSchristos ${RELOCATING+${FINI_START}} 503440a403fSchristos KEEP (*(SORT_NONE(.fini))) 504440a403fSchristos ${RELOCATING+${FINI_END}} 505440a403fSchristos } ${FILL} 506440a403fSchristos ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} 507440a403fSchristos ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} 508440a403fSchristos ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} 509440a403fSchristosEOF 510440a403fSchristos 511440a403fSchristosif test -n "${SEPARATE_CODE}"; then 512440a403fSchristos if test -n "${RODATA_ADDR}"; then 513440a403fSchristos RODATA_ADDR="\ 514440a403fSchristosSEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS" 515440a403fSchristos else 516440a403fSchristos RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 517440a403fSchristos RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})" 518440a403fSchristos fi 519440a403fSchristos if test -n "${SHLIB_RODATA_ADDR}"; then 520440a403fSchristos SHLIB_RODATA_ADDR="\ 521440a403fSchristosSEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" 522440a403fSchristos else 523440a403fSchristos SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" 524440a403fSchristos SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 525440a403fSchristos fi 526440a403fSchristos cat <<EOF 527440a403fSchristos /* Adjust the address for the rodata segment. We want to adjust up to 528440a403fSchristos the same address within the page on the next page up. */ 529440a403fSchristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}} 530440a403fSchristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} 531440a403fSchristos ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} 532440a403fSchristosEOF 533440a403fSchristos emit_early_ro 534440a403fSchristos emit_dyn 535440a403fSchristosfi 536440a403fSchristos 537440a403fSchristoscat <<EOF 538440a403fSchristos ${WRITABLE_RODATA-${RODATA}} 539440a403fSchristos .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } 540440a403fSchristos ${CREATE_SHLIB-${SDATA2}} 541440a403fSchristos ${CREATE_SHLIB-${SBSS2}} 542440a403fSchristos ${OTHER_READONLY_SECTIONS} 543*b88e3e88Schristos .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) ${RELOCATING+*(.eh_frame_entry .eh_frame_entry.*)} } 544440a403fSchristos .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } 545*b88e3e88Schristos .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } 546440a403fSchristos .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) } 547440a403fSchristos /* These sections are generated by the Sun/Oracle C++ compiler. */ 548*b88e3e88Schristos .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) } 549440a403fSchristos ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}} 550440a403fSchristos 551440a403fSchristos /* Adjust the address for the data segment. We want to adjust up to 552440a403fSchristos the same address within the page on the next page up. */ 553440a403fSchristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} 554440a403fSchristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 555440a403fSchristos ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 556440a403fSchristos 557440a403fSchristos /* Exception handling */ 558440a403fSchristos .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } 559440a403fSchristos .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } 560*b88e3e88Schristos .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } 561*b88e3e88Schristos .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) } 562440a403fSchristos 563440a403fSchristos /* Thread Local Storage sections */ 564*b88e3e88Schristos .tdata ${RELOCATING-0} : { ${RELOCATING+PROVIDE_HIDDEN(.tdata = .); }*(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } 565*b88e3e88Schristos .tbss ${RELOCATING-0} : { ${RELOCATING+PROVIDE_HIDDEN(.tbss = .); }*(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } 566440a403fSchristos 567440a403fSchristos .preinit_array ${RELOCATING-0} : 568440a403fSchristos { 569440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} 570440a403fSchristos KEEP (*(.preinit_array)) 571440a403fSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} 572440a403fSchristos } 573440a403fSchristos ${RELOCATING+${INIT_ARRAY}} 574440a403fSchristos ${RELOCATING+${FINI_ARRAY}} 575440a403fSchristos ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} 576440a403fSchristos ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} 577440a403fSchristos .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } 578440a403fSchristos 579440a403fSchristos ${RELOCATING+${DATARELRO}} 580440a403fSchristos ${OTHER_RELRO_SECTIONS} 581440a403fSchristos ${TEXT_DYNAMIC-${DYNAMIC}} 582440a403fSchristos ${OTHER_RELRO_SECTIONS_2} 583440a403fSchristos ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} 584440a403fSchristos ${DATA_GOT+${RELRO_NOW+${GOT}}} 585440a403fSchristos ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} 586440a403fSchristos ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} 587440a403fSchristos ${RELOCATING+${DATA_SEGMENT_RELRO_END}} 588440a403fSchristos ${INITIAL_READWRITE_SECTIONS} 589440a403fSchristos ${DATA_SDATA+${SDATA}} 590440a403fSchristos ${DATA_SDATA+${OTHER_SDATA_SECTIONS}} 591440a403fSchristos ${DATA_SDATA+${SBSS}} 592440a403fSchristos ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} 593440a403fSchristos ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} 594440a403fSchristos ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} 595440a403fSchristos 596440a403fSchristos ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} 597440a403fSchristos 598440a403fSchristos .data ${RELOCATING-0} : 599440a403fSchristos { 600440a403fSchristos ${RELOCATING+${DATA_START_SYMBOLS}} 601440a403fSchristos *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) 602440a403fSchristos ${CONSTRUCTING+SORT(CONSTRUCTORS)} 603440a403fSchristos } 604440a403fSchristos .data1 ${RELOCATING-0} : { *(.data1) } 605440a403fSchristos ${WRITABLE_RODATA+${RODATA}} 606440a403fSchristos ${OTHER_READWRITE_SECTIONS} 607440a403fSchristos ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} 608440a403fSchristos ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} 609440a403fSchristos ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}} 610440a403fSchristos ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}} 611440a403fSchristos ${SDATA_GOT+${GOT}} 612440a403fSchristos ${SDATA_GOT+${OTHER_GOT_SECTIONS}} 613440a403fSchristos ${DATA_SDATA-${SDATA}} 614440a403fSchristos ${DATA_SDATA-${OTHER_SDATA_SECTIONS}} 615440a403fSchristos ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} 616440a403fSchristos ${RELOCATING+. = .;} 617440a403fSchristos ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;} 618440a403fSchristos ${RELOCATING+${OTHER_BSS_SYMBOLS}} 619440a403fSchristos ${DATA_SDATA-${SBSS}} 620440a403fSchristos ${BSS_PLT+${PLT}} 621440a403fSchristos .${BSS_NAME} ${RELOCATING-0} : 622440a403fSchristos { 623*b88e3e88Schristos ${RELOCATING+*(.dyn${BSS_NAME})} 624440a403fSchristos *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) 625*b88e3e88Schristos ${RELOCATING+*(COMMON) 626440a403fSchristos /* Align here to ensure that the .bss section occupies space up to 627440a403fSchristos _end. Align after .bss to ensure correct alignment even if the 628440a403fSchristos .bss section disappears because there are no input sections. 629*b88e3e88Schristos FIXME: Why do we need it? When there is no .bss section, we do not 630440a403fSchristos pad the .data section. */ 631*b88e3e88Schristos . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 632440a403fSchristos } 633440a403fSchristos ${OTHER_BSS_SECTIONS} 634440a403fSchristos ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} 635440a403fSchristos ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} 636440a403fSchristos ${RELOCATING+. = ALIGN(${ALIGNMENT});} 637440a403fSchristosEOF 638440a403fSchristos 639440a403fSchristosLARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});" 640440a403fSchristosSHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});" 641440a403fSchristos 642440a403fSchristos cat <<EOF 643440a403fSchristos ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}} 644440a403fSchristos ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}} 645440a403fSchristos ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}} 646440a403fSchristos ${LARGE_SECTIONS} 647440a403fSchristos ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} 648440a403fSchristos ${RELOCATING+. = ALIGN(${ALIGNMENT});} 649440a403fSchristos ${RELOCATING+${OTHER_END_SYMBOLS}} 650440a403fSchristos ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} 651440a403fSchristos ${RELOCATING+${DATA_SEGMENT_END}} 65206324dcfSchristos ${TINY_DATA_SECTION} 65306324dcfSchristos ${TINY_BSS_SECTION} 65406324dcfSchristos ${STACK_ADDR+${STACK}} 655440a403fSchristosEOF 656440a403fSchristos 657440a403fSchristostest -z "${NON_ALLOC_DYN}" || emit_dyn 658440a403fSchristos 659440a403fSchristoscat <<EOF 660440a403fSchristos /* Stabs debugging sections. */ 661440a403fSchristos .stab 0 : { *(.stab) } 662440a403fSchristos .stabstr 0 : { *(.stabstr) } 663440a403fSchristos .stab.excl 0 : { *(.stab.excl) } 664440a403fSchristos .stab.exclstr 0 : { *(.stab.exclstr) } 665440a403fSchristos .stab.index 0 : { *(.stab.index) } 666440a403fSchristos .stab.indexstr 0 : { *(.stab.indexstr) } 667440a403fSchristos 668440a403fSchristos .comment 0 : { *(.comment) } 669440a403fSchristos 670440a403fSchristosEOF 671440a403fSchristos 672440a403fSchristos. $srcdir/scripttempl/DWARF.sc 673440a403fSchristos 674440a403fSchristoscat <<EOF 675440a403fSchristos ${ATTRS_SECTIONS} 676440a403fSchristos ${OTHER_SECTIONS} 677440a403fSchristos ${RELOCATING+${OTHER_SYMBOLS}} 678440a403fSchristos ${RELOCATING+${DISCARDED}} 679440a403fSchristos} 680440a403fSchristosEOF 681