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. 4006324dcfSchristos# OTHER_PLT_SECTIONS - sections just after .plt. 41440a403fSchristos# OTHER_SDATA_SECTIONS - sections just after .sdata. 42440a403fSchristos# OTHER_BSS_SYMBOLS - symbols that appear at the start of the 43440a403fSchristos# .bss section besides __bss_start. 44440a403fSchristos# PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment. 45440a403fSchristos# DATA_PLT - .plt should be in data segment, not text segment. 46440a403fSchristos# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. 47440a403fSchristos# BSS_PLT - .plt should be in bss segment 48440a403fSchristos# NO_REL_RELOCS - Don't include .rel.* sections in script 49440a403fSchristos# NO_RELA_RELOCS - Don't include .rela.* sections in script 50440a403fSchristos# NON_ALLOC_DYN - Place dynamic sections after data segment. 51440a403fSchristos# TEXT_DYNAMIC - .dynamic in text segment, not data segment. 52440a403fSchristos# EMBEDDED - whether this is for an embedded system. 53440a403fSchristos# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set 54440a403fSchristos# start address of shared library. 55440a403fSchristos# INPUT_FILES - INPUT command of files to always include 56440a403fSchristos# WRITABLE_RODATA - if set, the .rodata section should be writable 57440a403fSchristos# INIT_START, INIT_END - statements just before and just after 58440a403fSchristos# combination of .init sections. 59440a403fSchristos# FINI_START, FINI_END - statements just before and just after 60440a403fSchristos# combination of .fini sections. 61440a403fSchristos# STACK_ADDR - start of a .stack section. 62440a403fSchristos# OTHER_SYMBOLS - symbols to place right at the end of the script. 63440a403fSchristos# ETEXT_NAME - name of a symbol for the end of the text section, 64440a403fSchristos# normally etext. 65440a403fSchristos# SEPARATE_CODE - if set, .text and similar sections containing 66440a403fSchristos# actual machine instructions must be in wholly disjoint 67440a403fSchristos# pages from any other data, including headers 68440a403fSchristos# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, 69440a403fSchristos# so that .got can be in the RELRO area. It should be set to 70440a403fSchristos# the number of bytes in the beginning of .got.plt which can be 71440a403fSchristos# in the RELRO area as well. 72440a403fSchristos# USER_LABEL_PREFIX - prefix to add to user-visible symbols. 73440a403fSchristos# RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names 74440a403fSchristos# for standard sections, without initial "." or suffixes. 75440a403fSchristos# 76440a403fSchristos# When adding sections, do note that the names of some sections are used 77440a403fSchristos# when specifying the start address of the next. 78440a403fSchristos# 79440a403fSchristos 80440a403fSchristos# Many sections come in three flavours. There is the 'real' section, 81440a403fSchristos# like ".data". Then there are the per-procedure or per-variable 82440a403fSchristos# sections, generated by -ffunction-sections and -fdata-sections in GCC, 83440a403fSchristos# and useful for --gc-sections, which for a variable "foo" might be 84440a403fSchristos# ".data.foo". Then there are the linkonce sections, for which the linker 85440a403fSchristos# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". 86440a403fSchristos# The exact correspondences are: 87440a403fSchristos# 88440a403fSchristos# Section Linkonce section 89440a403fSchristos# .text .gnu.linkonce.t.foo 90440a403fSchristos# .rodata .gnu.linkonce.r.foo 91440a403fSchristos# .data .gnu.linkonce.d.foo 92440a403fSchristos# .bss .gnu.linkonce.b.foo 93440a403fSchristos# .sdata .gnu.linkonce.s.foo 94440a403fSchristos# .sbss .gnu.linkonce.sb.foo 95440a403fSchristos# .sdata2 .gnu.linkonce.s2.foo 96440a403fSchristos# .sbss2 .gnu.linkonce.sb2.foo 97440a403fSchristos# .debug_info .gnu.linkonce.wi.foo 98440a403fSchristos# .tdata .gnu.linkonce.td.foo 99440a403fSchristos# .tbss .gnu.linkonce.tb.foo 100440a403fSchristos# .lrodata .gnu.linkonce.lr.foo 101440a403fSchristos# .ldata .gnu.linkonce.l.foo 102440a403fSchristos# .lbss .gnu.linkonce.lb.foo 103440a403fSchristos# 104440a403fSchristos# Each of these can also have corresponding .rel.* and .rela.* sections. 105440a403fSchristos 106440a403fSchristostest -z "$TEXT_START_SYMBOLS" && TEXT_START_SYMBOLS="PROVIDE_HIDDEN (__eprol = .);" 107440a403fSchristostest -z "$ENTRY" && ENTRY=_start 108440a403fSchristosif test -n "$NOP"; then 109440a403fSchristos FILL="=$NOP" 110440a403fSchristoselse 111440a403fSchristos FILL= 112440a403fSchristosfi 113440a403fSchristos 114*b88e3e88Schristostest -n "$CREATE_SHLIB$CREATE_PIE" && CREATE_PIC=" " 115440a403fSchristostest -z "$RODATA_NAME" && RODATA_NAME=rodata 116440a403fSchristostest -z "$SDATA_NAME" && SDATA_NAME=sdata 117440a403fSchristostest -z "$SBSS_NAME" && SBSS_NAME=sbss 118440a403fSchristostest -z "$BSS_NAME" && BSS_NAME=bss 119440a403fSchristostest -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start 120440a403fSchristostest -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 121440a403fSchristostest -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 122440a403fSchristosif [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 123440a403fSchristostest -z "${ELFSIZE}" && ELFSIZE=32 124440a403fSchristostest -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" 125440a403fSchristostest "$LD_FLAG" = "N" && DATA_ADDR=. 126440a403fSchristostest -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext 127440a403fSchristostest -n "$RELRO_NOW" && unset SEPARATE_GOTPLT 128440a403fSchristostest -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" 12906324dcfSchristosif test -z "$DATA_SEGMENT_ALIGN"; then 13006324dcfSchristos test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" 13106324dcfSchristos test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" 132440a403fSchristos DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 133440a403fSchristos DATA_SEGMENT_RELRO_END="" 134440a403fSchristos DATA_SEGMENT_END="" 135440a403fSchristos if test -n "${COMMONPAGESIZE}"; then 136440a403fSchristos if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then 137440a403fSchristos DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 138440a403fSchristos else 139440a403fSchristos DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 140440a403fSchristos fi 141440a403fSchristos DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" 142440a403fSchristos DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" 143440a403fSchristos fi 14406324dcfSchristosfi 145440a403fSchristosif test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then 146440a403fSchristos INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" 147440a403fSchristosfi 148440a403fSchristosif test -z "$PLT"; then 149440a403fSchristos IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" 150*b88e3e88Schristos PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} } 151440a403fSchristos ${IREL_IN_PLT-$IPLT}" 152440a403fSchristosfi 153440a403fSchristostest -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= 154440a403fSchristosif test -z "$GOT"; then 155440a403fSchristos if test -z "$SEPARATE_GOTPLT"; then 156*b88e3e88Schristos GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }" 157440a403fSchristos else 158*b88e3e88Schristos GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }" 159*b88e3e88Schristos GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }" 160440a403fSchristos fi 161440a403fSchristosfi 162440a403fSchristosREL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" 163440a403fSchristosRELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" 164440a403fSchristosREL_IPLT=".rel.iplt ${RELOCATING-0} : 165440a403fSchristos { 166*b88e3e88Schristos ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} 167440a403fSchristos *(.rel.iplt) 168*b88e3e88Schristos ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} 169440a403fSchristos }" 170440a403fSchristosRELA_IPLT=".rela.iplt ${RELOCATING-0} : 171440a403fSchristos { 172*b88e3e88Schristos ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} 173440a403fSchristos *(.rela.iplt) 174*b88e3e88Schristos ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} 175440a403fSchristos }" 176440a403fSchristosDYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" 177440a403fSchristosRODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" 178440a403fSchristosDATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" 179440a403fSchristosDISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" 180440a403fSchristosif test -z "${NO_SMALL_DATA}"; then 181440a403fSchristos SBSS=".${SBSS_NAME} ${RELOCATING-0} : 182440a403fSchristos { 183440a403fSchristos ${RELOCATING+${SBSS_START_SYMBOLS}} 184440a403fSchristos ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)} 185*b88e3e88Schristos ${RELOCATING+*(.dyn${SBSS_NAME})} 186440a403fSchristos *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*}) 187*b88e3e88Schristos ${RELOCATING+*(.scommon)} 188440a403fSchristos ${RELOCATING+${SBSS_END_SYMBOLS}} 189440a403fSchristos }" 190440a403fSchristos SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" 191440a403fSchristos SDATA="/* We want the small data sections together, so single-instruction offsets 192440a403fSchristos can access them all, and initialized data all before uninitialized, so 193440a403fSchristos we can shorten the on-disk segment size. */ 194440a403fSchristos .${SDATA_NAME} ${RELOCATING-0} : 195440a403fSchristos { 196440a403fSchristos ${RELOCATING+${SDATA_START_SYMBOLS}} 197440a403fSchristos ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} 198440a403fSchristos *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) 199440a403fSchristos }" 200440a403fSchristos SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : 201440a403fSchristos { 202440a403fSchristos ${RELOCATING+${SDATA2_START_SYMBOLS}} 203440a403fSchristos *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) 204440a403fSchristos }" 205440a403fSchristos REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } 206440a403fSchristos .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" 207440a403fSchristos REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } 208440a403fSchristos .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" 209440a403fSchristos REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } 210440a403fSchristos .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" 211440a403fSchristos REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } 212440a403fSchristos .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" 213440a403fSchristoselse 214440a403fSchristos NO_SMALL_DATA=" " 215440a403fSchristosfi 216440a403fSchristosif test -z "${SDATA_GOT}${DATA_GOT}"; then 217440a403fSchristos if test -n "${NO_SMALL_DATA}"; then 218440a403fSchristos DATA_GOT=" " 219440a403fSchristos fi 220440a403fSchristosfi 221440a403fSchristosif test -z "${SDATA_GOT}${DATA_GOT}"; then 222440a403fSchristos if test -z "${NO_SMALL_DATA}"; then 223440a403fSchristos SDATA_GOT=" " 224440a403fSchristos fi 225440a403fSchristosfi 226440a403fSchristostest -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " 227440a403fSchristostest "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" 228440a403fSchristos .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } 229440a403fSchristos .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } 230440a403fSchristos .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } 231440a403fSchristos .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } 232440a403fSchristos .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } 233440a403fSchristos .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" 234440a403fSchristostest "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" 235440a403fSchristos .lbss ${RELOCATING-0} : 236440a403fSchristos { 237*b88e3e88Schristos ${RELOCATING+*(.dynlbss)} 238440a403fSchristos *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) 239*b88e3e88Schristos ${RELOCATING+*(LARGE_COMMON)} 240440a403fSchristos }" 241440a403fSchristostest "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" 242440a403fSchristos .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 243440a403fSchristos { 244440a403fSchristos *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) 245440a403fSchristos } 246440a403fSchristos .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 247440a403fSchristos { 248440a403fSchristos *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) 249440a403fSchristos ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 250440a403fSchristos }" 251440a403fSchristosif test "${ENABLE_INITFINI_ARRAY}" = "yes"; then 252440a403fSchristos SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" 253440a403fSchristos SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" 254440a403fSchristos CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" 255440a403fSchristos DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" 256440a403fSchristoselse 257440a403fSchristos SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" 258440a403fSchristos SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" 259440a403fSchristos CTORS_IN_INIT_ARRAY= 260440a403fSchristos DTORS_IN_FINI_ARRAY= 261440a403fSchristosfi 262*b88e3e88SchristosPREINIT_ARRAY=".preinit_array : 263440a403fSchristos { 264*b88e3e88Schristos ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);} 265*b88e3e88Schristos KEEP (*(.preinit_array)) 266*b88e3e88Schristos ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);} 267*b88e3e88Schristos }" 268*b88e3e88SchristosINIT_ARRAY=".init_array : 269*b88e3e88Schristos { 270*b88e3e88Schristos ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);} 271440a403fSchristos ${SORT_INIT_ARRAY} 272440a403fSchristos KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) 273*b88e3e88Schristos ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);} 274440a403fSchristos }" 275*b88e3e88SchristosFINI_ARRAY=".fini_array : 276440a403fSchristos { 277*b88e3e88Schristos ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);} 278440a403fSchristos ${SORT_FINI_ARRAY} 279440a403fSchristos KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) 280*b88e3e88Schristos ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);} 281440a403fSchristos }" 282440a403fSchristosCTOR=".ctors ${CONSTRUCTING-0} : 283440a403fSchristos { 284440a403fSchristos ${CONSTRUCTING+${CTOR_START}} 285440a403fSchristos /* gcc uses crtbegin.o to find the start of 286440a403fSchristos the constructors, so we make sure it is 287440a403fSchristos first. Because this is a wildcard, it 288440a403fSchristos doesn't matter if the user does not 289440a403fSchristos actually link against crtbegin.o; the 290440a403fSchristos linker won't look for a file to match a 291440a403fSchristos wildcard. The wildcard also means that it 292440a403fSchristos doesn't matter which directory crtbegin.o 293440a403fSchristos is in. */ 294440a403fSchristos 295440a403fSchristos KEEP (*crtbegin.o(.ctors)) 296440a403fSchristos KEEP (*crtbegin?.o(.ctors)) 297440a403fSchristos 298440a403fSchristos /* We don't want to include the .ctor section from 299440a403fSchristos the crtend.o file until after the sorted ctors. 300440a403fSchristos The .ctor section from the crtend file contains the 301440a403fSchristos end of ctors marker and it must be last */ 302440a403fSchristos 303440a403fSchristos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) 304440a403fSchristos KEEP (*(SORT(.ctors.*))) 305440a403fSchristos KEEP (*(.ctors)) 306440a403fSchristos ${CONSTRUCTING+${CTOR_END}} 307440a403fSchristos }" 308440a403fSchristosDTOR=".dtors ${CONSTRUCTING-0} : 309440a403fSchristos { 310440a403fSchristos ${CONSTRUCTING+${DTOR_START}} 311440a403fSchristos KEEP (*crtbegin.o(.dtors)) 312440a403fSchristos KEEP (*crtbegin?.o(.dtors)) 313440a403fSchristos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) 314440a403fSchristos KEEP (*(SORT(.dtors.*))) 315440a403fSchristos KEEP (*(.dtors)) 316440a403fSchristos ${CONSTRUCTING+${DTOR_END}} 317440a403fSchristos }" 318440a403fSchristosSTACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : 319440a403fSchristos { 320440a403fSchristos ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} 321440a403fSchristos *(.stack) 32206324dcfSchristos ${RELOCATING+${STACK_SENTINEL}} 323440a403fSchristos }" 324440a403fSchristos 325440a403fSchristosTEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" 326440a403fSchristosSHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" 327440a403fSchristos 32806324dcfSchristos# Don't bother with separate code segment when there are data sections 32906324dcfSchristos# between .plt and .text. 33006324dcfSchristosif test -z "$TINY_READONLY_SECTION"; then 33106324dcfSchristos case "$LD_FLAG" in 33206324dcfSchristos *textonly*) 333*b88e3e88Schristos SEPARATE_TEXT=" " 33406324dcfSchristos TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});" 33506324dcfSchristos ;; 33606324dcfSchristos esac 33706324dcfSchristosfi 33806324dcfSchristos 339440a403fSchristosif [ -z "$SEPARATE_CODE" ]; then 340440a403fSchristos SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" 341440a403fSchristoselse 342440a403fSchristos SIZEOF_HEADERS_CODE= 343440a403fSchristosfi 344440a403fSchristos 345440a403fSchristos# If this is for an embedded system, don't add SIZEOF_HEADERS. 346440a403fSchristosif [ -z "$EMBEDDED" ]; then 347440a403fSchristos test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" 348440a403fSchristoselse 349440a403fSchristos test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" 350440a403fSchristosfi 351440a403fSchristos 352440a403fSchristoscat <<EOF 353*b88e3e88Schristos/* Copyright (C) 2014-2020 Free Software Foundation, Inc. 354440a403fSchristos 355440a403fSchristos Copying and distribution of this script, with or without modification, 356440a403fSchristos are permitted in any medium without royalty provided the copyright 357440a403fSchristos notice and this notice are preserved. */ 358440a403fSchristos 359440a403fSchristosOUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 360440a403fSchristos "${LITTLE_OUTPUT_FORMAT}") 361440a403fSchristosOUTPUT_ARCH(${OUTPUT_ARCH}) 362440a403fSchristos${RELOCATING+ENTRY(${ENTRY})} 363440a403fSchristos 364440a403fSchristos${RELOCATING+${LIB_SEARCH_DIRS}} 36506324dcfSchristos${RELOCATING+${CREATE_SHLIB-${EXECUTABLE_SYMBOLS}}} 366440a403fSchristos${RELOCATING+${INPUT_FILES}} 367440a403fSchristos${RELOCATING- /* For some reason, the Solaris linker makes bad executables 368440a403fSchristos if gld -r is used and the intermediate file has sections starting 369440a403fSchristos at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld 370440a403fSchristos bug. But for now assigning the zero vmas works. */} 371440a403fSchristos 372440a403fSchristosSECTIONS 373440a403fSchristos{ 374*b88e3e88Schristos ${RELOCATING+${SEPARATE_TEXT-/* Read-only sections, merged into text segment: */}} 375440a403fSchristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} 376440a403fSchristos ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 377440a403fSchristos ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 378440a403fSchristosEOF 379440a403fSchristos 380440a403fSchristosemit_early_ro() 381440a403fSchristos{ 382440a403fSchristos cat <<EOF 383440a403fSchristos ${INITIAL_READONLY_SECTIONS} 384*b88e3e88Schristos .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) } 385440a403fSchristosEOF 386440a403fSchristos} 387440a403fSchristos 388440a403fSchristostest -n "${SEPARATE_CODE}" || emit_early_ro 389440a403fSchristos 390440a403fSchristostest -n "${RELOCATING+0}" || unset NON_ALLOC_DYN 391440a403fSchristostest -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= 392440a403fSchristoscat > ldscripts/dyntmp.$$ <<EOF 393440a403fSchristos ${TEXT_DYNAMIC+${DYNAMIC}} 394440a403fSchristos .hash ${RELOCATING-0} : { *(.hash) } 395440a403fSchristos .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } 396440a403fSchristos .dynsym ${RELOCATING-0} : { *(.dynsym) } 397440a403fSchristos .dynstr ${RELOCATING-0} : { *(.dynstr) } 398440a403fSchristos .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 399440a403fSchristos .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } 400440a403fSchristos .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } 401440a403fSchristosEOF 402440a403fSchristos 403440a403fSchristosif [ "x$COMBRELOC" = x ]; then 404440a403fSchristos COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" 405440a403fSchristoselse 406440a403fSchristos COMBRELOCCAT="cat > $COMBRELOC" 407440a403fSchristosfi 408440a403fSchristoseval $COMBRELOCCAT <<EOF 409440a403fSchristos ${INITIAL_RELOC_SECTIONS} 410440a403fSchristos .rel.init ${RELOCATING-0} : { *(.rel.init) } 411440a403fSchristos .rela.init ${RELOCATING-0} : { *(.rela.init) } 412440a403fSchristos .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } 413440a403fSchristos .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } 414440a403fSchristos .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 415440a403fSchristos .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 416440a403fSchristos .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } 417440a403fSchristos .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } 418440a403fSchristos ${OTHER_READONLY_RELOC_SECTIONS} 419440a403fSchristos .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) } 420440a403fSchristos .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) } 421440a403fSchristos .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } 422440a403fSchristos .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } 423440a403fSchristos ${OTHER_READWRITE_RELOC_SECTIONS} 424440a403fSchristos .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } 425440a403fSchristos .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } 426440a403fSchristos .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } 427440a403fSchristos .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } 428440a403fSchristos .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 429440a403fSchristos .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 430440a403fSchristos .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 431440a403fSchristos .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 432440a403fSchristos .rel.got ${RELOCATING-0} : { *(.rel.got) } 433440a403fSchristos .rela.got ${RELOCATING-0} : { *(.rela.got) } 434440a403fSchristos ${OTHER_GOT_RELOC_SECTIONS} 435440a403fSchristos ${REL_SDATA} 436440a403fSchristos ${REL_SBSS} 437440a403fSchristos ${REL_SDATA2} 438440a403fSchristos ${REL_SBSS2} 439440a403fSchristos .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } 440440a403fSchristos .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } 441440a403fSchristos ${REL_LARGE} 442440a403fSchristos ${IREL_IN_PLT+$REL_IFUNC} 443440a403fSchristos ${IREL_IN_PLT+$RELA_IFUNC} 444440a403fSchristos ${IREL_IN_PLT-$REL_IPLT} 445440a403fSchristos ${IREL_IN_PLT-$RELA_IPLT} 446440a403fSchristosEOF 447440a403fSchristos 448440a403fSchristosif [ -n "$COMBRELOC" ]; then 449440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 450440a403fSchristos .rel.dyn ${RELOCATING-0} : 451440a403fSchristos { 452440a403fSchristosEOF 453440a403fSchristossed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 454440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 455440a403fSchristos } 456440a403fSchristos .rela.dyn ${RELOCATING-0} : 457440a403fSchristos { 458440a403fSchristosEOF 459440a403fSchristossed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 460440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 461440a403fSchristos } 462440a403fSchristosEOF 463440a403fSchristosfi 464440a403fSchristos 465440a403fSchristoscat >> ldscripts/dyntmp.$$ <<EOF 466440a403fSchristos .rel.plt ${RELOCATING-0} : 467440a403fSchristos { 468440a403fSchristos *(.rel.plt) 469*b88e3e88Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} 470440a403fSchristos ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} 471*b88e3e88Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} 472440a403fSchristos } 473440a403fSchristos .rela.plt ${RELOCATING-0} : 474440a403fSchristos { 475440a403fSchristos *(.rela.plt) 476*b88e3e88Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} 477440a403fSchristos ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} 478*b88e3e88Schristos ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} 479440a403fSchristos } 480440a403fSchristos ${OTHER_PLT_RELOC_SECTIONS} 481440a403fSchristosEOF 482440a403fSchristos 483440a403fSchristosemit_dyn() 484440a403fSchristos{ 485440a403fSchristos if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then 486440a403fSchristos cat ldscripts/dyntmp.$$ 487440a403fSchristos else 488440a403fSchristos if test -z "${NO_REL_RELOCS}"; then 489440a403fSchristos sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$ 490440a403fSchristos fi 491440a403fSchristos if test -z "${NO_RELA_RELOCS}"; then 492440a403fSchristos sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$ 493440a403fSchristos fi 494440a403fSchristos fi 495440a403fSchristos rm -f ldscripts/dyntmp.$$ 496440a403fSchristos} 497440a403fSchristos 498440a403fSchristostest -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn 499440a403fSchristos 500440a403fSchristoscat <<EOF 50106324dcfSchristos ${RELOCATING+${TEXT_SEGMENT_ALIGN}} 50206324dcfSchristos 503440a403fSchristos .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} : 504440a403fSchristos { 505440a403fSchristos ${RELOCATING+${INIT_START}} 506440a403fSchristos KEEP (*(SORT_NONE(.init))) 507440a403fSchristos ${RELOCATING+${INIT_END}} 508440a403fSchristos } ${FILL} 509440a403fSchristos 51006324dcfSchristos ${TEXT_PLT+${PLT_NEXT_DATA-${PLT} ${OTHER_PLT_SECTIONS}}} 511440a403fSchristos ${TINY_READONLY_SECTION} 512440a403fSchristos .text ${RELOCATING-0} : 513440a403fSchristos { 514440a403fSchristos ${RELOCATING+${TEXT_START_SYMBOLS}} 515440a403fSchristos *(.text) 516440a403fSchristos ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)} 517440a403fSchristos ${RELOCATING+*(.text.exit .text.exit.*)} 518440a403fSchristos ${RELOCATING+*(.text.startup .text.startup.*)} 519440a403fSchristos ${RELOCATING+*(.text.hot .text.hot.*)} 520*b88e3e88Schristos ${RELOCATING+*(SORT(.text.sorted.*))} 521*b88e3e88Schristos *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) 522*b88e3e88Schristos /* .gnu.warning sections are handled specially by elf.em. */ 523440a403fSchristos *(.gnu.warning) 524440a403fSchristos ${RELOCATING+${OTHER_TEXT_SECTIONS}} 525440a403fSchristos } ${FILL} 526440a403fSchristos .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} : 527440a403fSchristos { 528440a403fSchristos ${RELOCATING+${FINI_START}} 529440a403fSchristos KEEP (*(SORT_NONE(.fini))) 530440a403fSchristos ${RELOCATING+${FINI_END}} 531440a403fSchristos } ${FILL} 532440a403fSchristos ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} 533440a403fSchristos ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} 534440a403fSchristos ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} 53506324dcfSchristos ${RELOCATING+${TEXT_SEGMENT_ALIGN}} 536440a403fSchristosEOF 537440a403fSchristos 53806324dcfSchristosif test -n "${SEPARATE_CODE}${SEPARATE_TEXT}"; then 539440a403fSchristos if test -n "${RODATA_ADDR}"; then 540440a403fSchristos RODATA_ADDR="\ 541440a403fSchristosSEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS" 542440a403fSchristos else 543440a403fSchristos RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 544440a403fSchristos RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})" 545440a403fSchristos fi 546440a403fSchristos if test -n "${SHLIB_RODATA_ADDR}"; then 547440a403fSchristos SHLIB_RODATA_ADDR="\ 548440a403fSchristosSEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" 549440a403fSchristos else 550440a403fSchristos SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 55106324dcfSchristos SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" 552440a403fSchristos fi 553440a403fSchristos cat <<EOF 554*b88e3e88Schristos ${RELOCATING+/* Adjust the address for the rodata segment. We want to adjust up to 555440a403fSchristos the same address within the page on the next page up. */ 556*b88e3e88Schristos ${CREATE_SHLIB-${CREATE_PIE-. = ${RODATA_ADDR};}} 557*b88e3e88Schristos ${CREATE_SHLIB+. = ${SHLIB_RODATA_ADDR};} 558*b88e3e88Schristos ${CREATE_PIE+. = ${SHLIB_RODATA_ADDR};}} 559440a403fSchristosEOF 56006324dcfSchristos if test -n "${SEPARATE_CODE}"; then 561440a403fSchristos emit_early_ro 562440a403fSchristos emit_dyn 563440a403fSchristos fi 56406324dcfSchristosfi 565440a403fSchristos 566440a403fSchristoscat <<EOF 567440a403fSchristos ${WRITABLE_RODATA-${RODATA}} 568440a403fSchristos .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } 569440a403fSchristos ${CREATE_SHLIB-${SDATA2}} 570440a403fSchristos ${CREATE_SHLIB-${SBSS2}} 571440a403fSchristos ${OTHER_READONLY_SECTIONS} 572*b88e3e88Schristos .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr)${RELOCATING+ *(.eh_frame_entry .eh_frame_entry.*)} } 573440a403fSchristos .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} } 574*b88e3e88Schristos .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } 575440a403fSchristos .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) } 576440a403fSchristos /* These sections are generated by the Sun/Oracle C++ compiler. */ 577*b88e3e88Schristos .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) } 57806324dcfSchristos ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}} 579440a403fSchristos 580*b88e3e88Schristos ${RELOCATING+/* Adjust the address for the data segment. We want to adjust up to 581*b88e3e88Schristos the same address within the page on the next page up. */} 582440a403fSchristos ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} 583*b88e3e88Schristos ${CREATE_SHLIB+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};} 584*b88e3e88Schristos ${CREATE_PIE+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};} 585440a403fSchristos 586440a403fSchristos /* Exception handling */ 587440a403fSchristos .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} } 588440a403fSchristos .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } 589*b88e3e88Schristos .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } 590*b88e3e88Schristos .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) } 591440a403fSchristos 592440a403fSchristos /* Thread Local Storage sections */ 59306324dcfSchristos .tdata ${RELOCATING-0} : 59406324dcfSchristos { 59506324dcfSchristos ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__tdata_start = .);}} 59606324dcfSchristos *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) 59706324dcfSchristos } 598440a403fSchristos .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } 599440a403fSchristos 60006324dcfSchristos ${RELOCATING+${PREINIT_ARRAY}} 601440a403fSchristos ${RELOCATING+${INIT_ARRAY}} 602440a403fSchristos ${RELOCATING+${FINI_ARRAY}} 603440a403fSchristos ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} 604440a403fSchristos ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} 605440a403fSchristos .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } 606440a403fSchristos 607440a403fSchristos ${RELOCATING+${DATARELRO}} 608440a403fSchristos ${OTHER_RELRO_SECTIONS} 609440a403fSchristos ${TEXT_DYNAMIC-${DYNAMIC}} 610440a403fSchristos ${OTHER_RELRO_SECTIONS_2} 611440a403fSchristos ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} 612440a403fSchristos ${DATA_GOT+${RELRO_NOW+${GOT}}} 613440a403fSchristos ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} 614440a403fSchristos ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} 615440a403fSchristos ${RELOCATING+${DATA_SEGMENT_RELRO_END}} 616440a403fSchristos ${INITIAL_READWRITE_SECTIONS} 617440a403fSchristos ${DATA_SDATA+${SDATA}} 618440a403fSchristos ${DATA_SDATA+${OTHER_SDATA_SECTIONS}} 619440a403fSchristos ${DATA_SDATA+${SBSS}} 620440a403fSchristos ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} 621440a403fSchristos ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} 622440a403fSchristos ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} 623440a403fSchristos 624440a403fSchristos ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} 625440a403fSchristos 626440a403fSchristos .data ${RELOCATING-0} : 627440a403fSchristos { 628440a403fSchristos ${RELOCATING+${DATA_START_SYMBOLS}} 629440a403fSchristos *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) 630440a403fSchristos ${CONSTRUCTING+SORT(CONSTRUCTORS)} 631440a403fSchristos } 632440a403fSchristos .data1 ${RELOCATING-0} : { *(.data1) } 633440a403fSchristos ${WRITABLE_RODATA+${RODATA}} 634440a403fSchristos ${OTHER_READWRITE_SECTIONS} 635440a403fSchristos ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} 636440a403fSchristos ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} 637440a403fSchristos ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}} 638440a403fSchristos ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}} 639440a403fSchristos ${SDATA_GOT+${GOT}} 640440a403fSchristos ${SDATA_GOT+${OTHER_GOT_SECTIONS}} 641440a403fSchristos ${DATA_SDATA-${SDATA}} 642440a403fSchristos ${DATA_SDATA-${OTHER_SDATA_SECTIONS}} 64306324dcfSchristos ${RELOCATING+${DATA_END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_edata = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} 644440a403fSchristos ${RELOCATING+. = .;} 64506324dcfSchristos ${RELOCATING+${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}__bss_start = .${CREATE_SHLIB+)};} 646440a403fSchristos ${RELOCATING+${OTHER_BSS_SYMBOLS}} 647440a403fSchristos ${DATA_SDATA-${SBSS}} 648440a403fSchristos ${BSS_PLT+${PLT}} 649440a403fSchristos .${BSS_NAME} ${RELOCATING-0} : 650440a403fSchristos { 65106324dcfSchristos ${RELOCATING+*(.dynbss)} 652440a403fSchristos *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) 653*b88e3e88Schristos ${RELOCATING+*(COMMON) 654440a403fSchristos /* Align here to ensure that the .bss section occupies space up to 655440a403fSchristos _end. Align after .bss to ensure correct alignment even if the 656440a403fSchristos .bss section disappears because there are no input sections. 657*b88e3e88Schristos FIXME: Why do we need it? When there is no .bss section, we do not 658440a403fSchristos pad the .data section. */ 659*b88e3e88Schristos . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 660440a403fSchristos } 661440a403fSchristos ${OTHER_BSS_SECTIONS} 662440a403fSchristos ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} 663440a403fSchristos ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} 664440a403fSchristos ${RELOCATING+. = ALIGN(${ALIGNMENT});} 665440a403fSchristosEOF 666440a403fSchristos 667440a403fSchristosLARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});" 668440a403fSchristosSHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});" 669440a403fSchristos 670440a403fSchristoscat <<EOF 671440a403fSchristos ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}} 672*b88e3e88Schristos ${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}} 673*b88e3e88Schristos ${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}} 674440a403fSchristos ${LARGE_SECTIONS} 675440a403fSchristos ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} 676440a403fSchristos ${RELOCATING+. = ALIGN(${ALIGNMENT});} 677440a403fSchristos ${RELOCATING+${OTHER_END_SYMBOLS}} 67806324dcfSchristos ${RELOCATING+${END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_end = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}end = .);}} 679440a403fSchristos ${RELOCATING+${DATA_SEGMENT_END}} 68006324dcfSchristos ${TINY_DATA_SECTION} 68106324dcfSchristos ${TINY_BSS_SECTION} 68206324dcfSchristos ${STACK_ADDR+${STACK}} 683440a403fSchristosEOF 684440a403fSchristos 685440a403fSchristostest -z "${NON_ALLOC_DYN}" || emit_dyn 686440a403fSchristos 687440a403fSchristoscat <<EOF 688440a403fSchristos /* Stabs debugging sections. */ 689440a403fSchristos .stab 0 : { *(.stab) } 690440a403fSchristos .stabstr 0 : { *(.stabstr) } 691440a403fSchristos .stab.excl 0 : { *(.stab.excl) } 692440a403fSchristos .stab.exclstr 0 : { *(.stab.exclstr) } 693440a403fSchristos .stab.index 0 : { *(.stab.index) } 694440a403fSchristos .stab.indexstr 0 : { *(.stab.indexstr) } 695440a403fSchristos 696440a403fSchristos .comment 0 : { *(.comment) } 697440a403fSchristos 698*b88e3e88Schristos .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) } 699*b88e3e88Schristos 700440a403fSchristosEOF 701440a403fSchristos 702440a403fSchristos. $srcdir/scripttempl/DWARF.sc 703440a403fSchristos 704440a403fSchristoscat <<EOF 705440a403fSchristos ${ATTRS_SECTIONS} 706440a403fSchristos ${OTHER_SECTIONS} 707440a403fSchristos ${RELOCATING+${OTHER_SYMBOLS}} 708440a403fSchristos ${RELOCATING+${DISCARDED}} 709440a403fSchristos} 710440a403fSchristosEOF 711