1# Copyright (C) 2014 Free Software Foundation, Inc. 2# 3# Copying and distribution of this file, with or without modification, 4# are permitted in any medium without royalty provided the copyright 5# notice and this notice are preserved. 6 7# This file is variant of elf.sc. For nds32, because the data will be 8# classified into different sections according to their size, this script 9# describe these sections map. The order is ".sdata_d, .sdata_w, .sdata_h, 10# .sdata_b, , sdata_f, .sbss_f, .sbss_b, .sbss_h, .sbss_w, .sbss_d". In 11# this order we do not have to consider the alignment issue between these 12# sections. 13 14if test -n "$NOP"; then 15 FILL="=$NOP" 16else 17 FILL= 18fi 19 20test -z "$RODATA_NAME" && RODATA_NAME=rodata 21test -z "$SDATA_NAME" && SDATA_NAME=sdata 22test -z "$SBSS_NAME" && SBSS_NAME=sbss 23test -z "$BSS_NAME" && BSS_NAME=bss 24test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start 25test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 26test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 27if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 28test -z "${ELFSIZE}" && ELFSIZE=32 29test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" 30test "$LD_FLAG" = "N" && DATA_ADDR=. 31test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext 32test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" 33test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" 34test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT 35test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" 36DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 37DATA_SEGMENT_RELRO_END="" 38DATA_SEGMENT_END="" 39if test -n "${COMMONPAGESIZE}"; then 40 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 41 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" 42 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" 43fi 44if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then 45 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" 46fi 47if test -z "$PLT"; then 48 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" 49 PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} } 50 ${IREL_IN_PLT-$IPLT}" 51fi 52test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= 53if test -z "$GOT"; then 54 if test -z "$SEPARATE_GOTPLT"; then 55 GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }" 56 else 57 GOT=".got ${RELOCATING-0} : { *(.got) *(.igot) }" 58 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) }" 59 fi 60fi 61REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" 62RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" 63REL_IPLT=".rel.iplt ${RELOCATING-0} : 64 { 65 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} 66 *(.rel.iplt) 67 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} 68 }" 69RELA_IPLT=".rela.iplt ${RELOCATING-0} : 70 { 71 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} 72 *(.rela.iplt) 73 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} 74 }" 75DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" 76RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" 77DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" 78DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" 79if test -z "${NO_SMALL_DATA}"; then 80 SBSS=".sbss_b ${RELOCATING-0} : 81 { 82 *(.sbss_b${RELOCATING+ .sbss_b.*}) 83 *(.scommon_b${RELOCATING+ .scommon_b.*}) 84 ${RELOCATING+. = ALIGN(2);} 85 } 86 .sbss_h ${RELOCATING-0} : 87 { 88 *(.sbss_h${RELOCATING+ .sbss_h.*}) 89 *(.scommon_h${RELOCATING+ .scommon_h.*}) 90 ${RELOCATING+. = ALIGN(4);} 91 } 92 .sbss_w ${RELOCATING-0} : 93 { 94 *(.sbss_w${RELOCATING+ .sbss_w.*}) 95 *(.scommon_w${RELOCATING+ .scommon_w.*}) 96 *(.dynsbss) 97 *(.scommon) 98 ${RELOCATING+. = ALIGN(8);} 99 } 100 .sbss_d ${RELOCATING-0} : 101 { 102 *(.sbss_d${RELOCATING+ .sbss_d.*}) 103 *(.scommon_d${RELOCATING+ .scommon_d.*}) 104 ${RELOCATING+PROVIDE (__sbss_end = .);} 105 ${RELOCATING+PROVIDE (___sbss_end = .);} 106 }" 107 SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" 108 SDATA="/* We want the small data sections together, so single-instruction offsets 109 can access them all, and initialized data all before uninitialized, so 110 we can shorten the on-disk segment size. */ 111 .${SDATA_NAME} ${RELOCATING-0} : 112 { 113 ${RELOCATING+${SDATA_START_SYMBOLS}} 114 ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} 115 *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) 116 } 117 .sdata_d ${RELOCATING-0} : 118 { 119 *(.sdata_d${RELOCATING+ .sdata_d.*}) 120 } 121 .sdata_w ${RELOCATING-0} : 122 { 123 *(.sdata_w${RELOCATING+ .sdata_w.*}) 124 } 125 .sdata_h ${RELOCATING-0} : 126 { 127 *(.sdata_h${RELOCATING+ .sdata_h.*}) 128 } 129 .sdata_b ${RELOCATING-0} : 130 { 131 *(.sdata_b${RELOCATING+ .sdata_b.*}) 132 } 133 .sdata_f ${RELOCATING-0} : 134 { 135 *(.sdata_f${RELOCATING+ .sdata_f.*}) 136 }" 137 SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : 138 { 139 ${RELOCATING+${SDATA2_START_SYMBOLS}} 140 *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) 141 }" 142 REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } 143 .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" 144 REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } 145 .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" 146 REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } 147 .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" 148 REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } 149 .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" 150else 151 NO_SMALL_DATA=" " 152fi 153if test -z "${DATA_GOT}"; then 154 if test -n "${NO_SMALL_DATA}"; then 155 DATA_GOT=" " 156 fi 157fi 158if test -z "${SDATA_GOT}"; then 159 if test -z "${NO_SMALL_DATA}"; then 160 SDATA_GOT=" " 161 fi 162fi 163test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " 164test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" 165 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } 166 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } 167 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } 168 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } 169 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } 170 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" 171test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" 172 .lbss ${RELOCATING-0} : 173 { 174 *(.dynlbss) 175 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) 176 *(LARGE_COMMON) 177 }" 178test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" 179 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 180 { 181 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) 182 } 183 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 184 { 185 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) 186 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 187 }" 188if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then 189 SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" 190 SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" 191 CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" 192 DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" 193else 194 SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" 195 SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" 196 CTORS_IN_INIT_ARRAY= 197 DTORS_IN_FINI_ARRAY= 198fi 199INIT_ARRAY=".init_array ${RELOCATING-0} : 200 { 201 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} 202 ${SORT_INIT_ARRAY} 203 KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) 204 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} 205 }" 206FINI_ARRAY=".fini_array ${RELOCATING-0} : 207 { 208 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} 209 ${SORT_FINI_ARRAY} 210 KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) 211 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} 212 }" 213CTOR=".ctors ${CONSTRUCTING-0} : 214 { 215 ${CONSTRUCTING+${CTOR_START}} 216 /* gcc uses crtbegin.o to find the start of 217 the constructors, so we make sure it is 218 first. Because this is a wildcard, it 219 doesn't matter if the user does not 220 actually link against crtbegin.o; the 221 linker won't look for a file to match a 222 wildcard. The wildcard also means that it 223 doesn't matter which directory crtbegin.o 224 is in. */ 225 226 KEEP (*crtbegin.o(.ctors)) 227 KEEP (*crtbegin?.o(.ctors)) 228 229 /* We don't want to include the .ctor section from 230 the crtend.o file until after the sorted ctors. 231 The .ctor section from the crtend file contains the 232 end of ctors marker and it must be last */ 233 234 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) 235 KEEP (*(SORT(.ctors.*))) 236 KEEP (*(.ctors)) 237 ${CONSTRUCTING+${CTOR_END}} 238 }" 239DTOR=".dtors ${CONSTRUCTING-0} : 240 { 241 ${CONSTRUCTING+${DTOR_START}} 242 KEEP (*crtbegin.o(.dtors)) 243 KEEP (*crtbegin?.o(.dtors)) 244 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) 245 KEEP (*(SORT(.dtors.*))) 246 KEEP (*(.dtors)) 247 ${CONSTRUCTING+${DTOR_END}} 248 }" 249STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : 250 { 251 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} 252 *(.stack) 253 }" 254 255TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" 256SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" 257 258if [ -z "$SEPARATE_CODE" ]; then 259 SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" 260else 261 SIZEOF_HEADERS_CODE= 262fi 263 264# If this is for an embedded system, don't add SIZEOF_HEADERS. 265if [ -z "$EMBEDDED" ]; then 266 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" 267 NDS32_INIT="" 268else 269 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" 270 NDS32_INIT=".nds32_init : { KEEP(*(.nds32_init)) }" 271fi 272 273cat <<EOF 274/* Copyright (C) 2014 Free Software Foundation, Inc. 275 276 Copying and distribution of this script, with or without modification, 277 are permitted in any medium without royalty provided the copyright 278 notice and this notice are preserved. */ 279 280OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 281 "${LITTLE_OUTPUT_FORMAT}") 282OUTPUT_ARCH(${OUTPUT_ARCH}) 283${RELOCATING+ENTRY(${ENTRY})} 284 285${RELOCATING+${LIB_SEARCH_DIRS}} 286${RELOCATING+${EXECUTABLE_SYMBOLS}} 287${RELOCATING+${INPUT_FILES}} 288${RELOCATING- /* For some reason, the Solaris linker makes bad executables 289 if gld -r is used and the intermediate file has sections starting 290 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld 291 bug. But for now assigning the zero vmas works. */} 292 293SECTIONS 294{ 295 /* Read-only sections, merged into text segment: */ 296 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} 297 /* Sections saved crt0 and crt1. */ 298 ${NDS32_INIT} 299 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 300 ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} 301EOF 302 303emit_early_ro() 304{ 305 cat <<EOF 306 ${INITIAL_READONLY_SECTIONS} 307 .note.gnu.build-id : { *(.note.gnu.build-id) } 308EOF 309} 310 311test -n "${SEPARATE_CODE}" || emit_early_ro 312 313test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN 314test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= 315cat > ldscripts/dyntmp.$$ <<EOF 316 ${TEXT_DYNAMIC+${DYNAMIC}} 317 .hash ${RELOCATING-0} : { *(.hash) } 318 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } 319 .dynsym ${RELOCATING-0} : { *(.dynsym) } 320 .dynstr ${RELOCATING-0} : { *(.dynstr) } 321 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 322 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } 323 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } 324EOF 325 326if [ "x$COMBRELOC" = x ]; then 327 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" 328else 329 COMBRELOCCAT="cat > $COMBRELOC" 330fi 331eval $COMBRELOCCAT <<EOF 332 ${INITIAL_RELOC_SECTIONS} 333 .rel.init ${RELOCATING-0} : { *(.rel.init) } 334 .rela.init ${RELOCATING-0} : { *(.rela.init) } 335 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } 336 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } 337 .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 338 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 339 .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } 340 .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } 341 ${OTHER_READONLY_RELOC_SECTIONS} 342 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) } 343 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) } 344 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } 345 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } 346 ${OTHER_READWRITE_RELOC_SECTIONS} 347 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } 348 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } 349 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } 350 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } 351 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 352 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 353 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 354 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 355 .rel.got ${RELOCATING-0} : { *(.rel.got) } 356 .rela.got ${RELOCATING-0} : { *(.rela.got) } 357 ${OTHER_GOT_RELOC_SECTIONS} 358 ${REL_SDATA} 359 ${REL_SBSS} 360 ${REL_SDATA2} 361 ${REL_SBSS2} 362 .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } 363 .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } 364 ${REL_LARGE} 365 ${IREL_IN_PLT+$REL_IFUNC} 366 ${IREL_IN_PLT+$RELA_IFUNC} 367 ${IREL_IN_PLT-$REL_IPLT} 368 ${IREL_IN_PLT-$RELA_IPLT} 369EOF 370 371if [ -n "$COMBRELOC" ]; then 372cat >> ldscripts/dyntmp.$$ <<EOF 373 .rel.dyn ${RELOCATING-0} : 374 { 375EOF 376sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 377cat >> ldscripts/dyntmp.$$ <<EOF 378 } 379 .rela.dyn ${RELOCATING-0} : 380 { 381EOF 382sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ 383cat >> ldscripts/dyntmp.$$ <<EOF 384 } 385EOF 386fi 387 388cat >> ldscripts/dyntmp.$$ <<EOF 389 .rel.plt ${RELOCATING-0} : 390 { 391 *(.rel.plt) 392 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} 393 ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} 394 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} 395 } 396 .rela.plt ${RELOCATING-0} : 397 { 398 *(.rela.plt) 399 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} 400 ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} 401 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} 402 } 403 ${OTHER_PLT_RELOC_SECTIONS} 404EOF 405 406emit_dyn() 407{ 408 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then 409 cat ldscripts/dyntmp.$$ 410 else 411 if test -z "${NO_REL_RELOCS}"; then 412 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$ 413 fi 414 if test -z "${NO_RELA_RELOCS}"; then 415 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$ 416 fi 417 fi 418 rm -f ldscripts/dyntmp.$$ 419} 420 421test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn 422 423cat <<EOF 424 .init ${RELOCATING-0} : 425 { 426 ${RELOCATING+${INIT_START}} 427 KEEP (*(SORT_NONE(.init))) 428 ${RELOCATING+${INIT_END}} 429 } ${FILL} 430 431 ${TEXT_PLT+${PLT_NEXT_DATA-${PLT}}} 432 ${TINY_READONLY_SECTION} 433 .text ${RELOCATING-0} : 434 { 435 ${RELOCATING+${TEXT_START_SYMBOLS}} 436 ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)} 437 ${RELOCATING+*(.text.exit .text.exit.*)} 438 ${RELOCATING+*(.text.startup .text.startup.*)} 439 ${RELOCATING+*(.text.hot .text.hot.*)} 440 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) 441 /* .gnu.warning sections are handled specially by elf32.em. */ 442 *(.gnu.warning) 443 ${RELOCATING+${OTHER_TEXT_SECTIONS}} 444 } ${FILL} 445 .fini ${RELOCATING-0} : 446 { 447 ${RELOCATING+${FINI_START}} 448 KEEP (*(SORT_NONE(.fini))) 449 ${RELOCATING+${FINI_END}} 450 } ${FILL} 451 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} 452 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} 453 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} 454EOF 455 456if test -n "${SEPARATE_CODE}"; then 457 if test -n "${RODATA_ADDR}"; then 458 RODATA_ADDR="\ 459SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS" 460 else 461 RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 462 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})" 463 fi 464 if test -n "${SHLIB_RODATA_ADDR}"; then 465 SHLIB_RODATA_ADDR="\ 466SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" 467 else 468 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" 469 SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 470 fi 471 cat <<EOF 472 /* Adjust the address for the rodata segment. We want to adjust up to 473 the same address within the page on the next page up. */ 474 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}} 475 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} 476 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} 477EOF 478 emit_early_ro 479 emit_dyn 480fi 481 482cat <<EOF 483 ${WRITABLE_RODATA-${RODATA}} 484 .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } 485 ${CREATE_SHLIB-${SDATA2}} 486 ${CREATE_SHLIB-${SBSS2}} 487 ${OTHER_READONLY_SECTIONS} 488 .eh_frame_hdr : { *(.eh_frame_hdr) } 489 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } 490 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table 491 .gcc_except_table.*) } 492 /* These sections are generated by the Sun/Oracle C++ compiler. */ 493 .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges 494 .exception_ranges*) } 495 ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}} 496 497 /* Adjust the address for the data segment. We want to adjust up to 498 the same address within the page on the next page up. */ 499 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} 500 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 501 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 502 503 /* Exception handling */ 504 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } 505 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 506 .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } 507 508 /* Thread Local Storage sections */ 509 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } 510 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } 511 512 .preinit_array ${RELOCATING-0} : 513 { 514 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} 515 KEEP (*(.preinit_array)) 516 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} 517 } 518 ${RELOCATING+${INIT_ARRAY}} 519 ${RELOCATING+${FINI_ARRAY}} 520 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} 521 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} 522 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } 523 524 ${RELOCATING+${DATARELRO}} 525 ${OTHER_RELRO_SECTIONS} 526 ${TEXT_DYNAMIC-${DYNAMIC}} 527 ${DATA_GOT+${RELRO_NOW+${GOT}}} 528 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} 529 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} 530 ${RELOCATING+${DATA_SEGMENT_RELRO_END}} 531 ${INITIAL_READWRITE_SECTIONS} 532 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} 533 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} 534 535 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} 536 537 /* For _SDA_BASE_ aligment. */ 538 ${RELOCATING+. = ALIGN(4);} 539 540 .data ${RELOCATING-0} : 541 { 542 ${RELOCATING+${DATA_START_SYMBOLS}} 543 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) 544 ${CONSTRUCTING+SORT(CONSTRUCTORS)} 545 } 546 .data1 ${RELOCATING-0} : { *(.data1) } 547 ${WRITABLE_RODATA+${RODATA}} 548 ${OTHER_READWRITE_SECTIONS} 549 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} 550 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} 551 ${RELOCATING+. = ALIGN(4);} 552 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} 553 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}} 554 ${SDATA_GOT+${GOT}} 555 ${SDATA_GOT+${OTHER_GOT_SECTIONS}} 556 ${SDATA} 557 ${OTHER_SDATA_SECTIONS} 558 ${RELOCATING+. = ALIGN(4);} 559 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} 560 ${RELOCATING+. = .;} 561 ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;} 562 ${RELOCATING+${OTHER_BSS_SYMBOLS}} 563 ${SBSS} 564 ${BSS_PLT+${PLT}} 565 .${BSS_NAME} ${RELOCATING-0} : 566 { 567 *(.dyn${BSS_NAME}) 568 *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) 569 *(COMMON) 570 /* Align here to ensure that the .bss section occupies space up to 571 _end. Align after .bss to ensure correct alignment even if the 572 .bss section disappears because there are no input sections. 573 FIXME: Why do we need it? When there is no .bss section, we don't 574 pad the .data section. */ 575 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 576 } 577 ${OTHER_BSS_SECTIONS} 578 ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} 579 ${RELOCATING+_end = .;} 580 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} 581 ${RELOCATING+. = ALIGN(${ALIGNMENT});} 582EOF 583 584LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});" 585SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});" 586 587 cat <<EOF 588 ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}} 589 ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}} 590 ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}} 591 ${LARGE_SECTIONS} 592 ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} 593 ${RELOCATING+. = ALIGN(${ALIGNMENT});} 594 ${RELOCATING+${OTHER_END_SYMBOLS}} 595 ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} 596 ${RELOCATING+${DATA_SEGMENT_END}} 597EOF 598 599test -z "${NON_ALLOC_DYN}" || emit_dyn 600 601cat <<EOF 602 /* Stabs debugging sections. */ 603 .stab 0 : { *(.stab) } 604 .stabstr 0 : { *(.stabstr) } 605 .stab.excl 0 : { *(.stab.excl) } 606 .stab.exclstr 0 : { *(.stab.exclstr) } 607 .stab.index 0 : { *(.stab.index) } 608 .stab.indexstr 0 : { *(.stab.indexstr) } 609 610 .comment 0 : { *(.comment) } 611 612EOF 613 614. $srcdir/scripttempl/DWARF.sc 615 616cat <<EOF 617 618 ${TINY_DATA_SECTION} 619 ${TINY_BSS_SECTION} 620 621 ${STACK_ADDR+${STACK}} 622 ${ATTRS_SECTIONS} 623 ${OTHER_SECTIONS} 624 ${RELOCATING+${OTHER_SYMBOLS}} 625 ${RELOCATING+${DISCARDED}} 626} 627EOF 628