1# 2# Unusual variables checked by this code: 3# NOP - four byte opcode for no-op (defaults to 0) 4# TRAP - four byte opcode for death (defaults to $NOP) 5# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not 6# empty. 7# SMALL_DATA_CTOR - .ctors contains small data. 8# SMALL_DATA_DTOR - .dtors contains small data. 9# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start 10# INITIAL_READONLY_SECTIONS - at start of text segment 11# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... 12# (e.g., .PARISC.milli) 13# OTHER_TEXT_SECTIONS - these get put in .text when relocating 14# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... 15# (e.g., .PARISC.global) 16# OTHER_RELRO_SECTIONS - other than .data.rel.ro ... 17# (e.g. PPC32 .fixup, .got[12]) 18# OTHER_SECTIONS - at the end 19# EXECUTABLE_SYMBOLS - symbols that must be defined for an 20# executable (e.g., _DYNAMIC_LINK) 21# TEXT_START_ADDR - the first byte of the text segment, after any 22# headers. 23# TEXT_BASE_ADDRESS - the first byte of the text segment. 24# TEXT_START_SYMBOLS - symbols that appear at the start of the 25# .text section. 26# DATA_START_SYMBOLS - symbols that appear at the start of the 27# .data section. 28# DATA_END_SYMBOLS - symbols that appear at the end of the 29# writeable data sections. 30# OTHER_GOT_SYMBOLS - symbols defined just before .got. 31# OTHER_GOT_SECTIONS - sections just after .got. 32# OTHER_SDATA_SECTIONS - sections just after .sdata. 33# OTHER_BSS_SYMBOLS - symbols that appear at the start of the 34# .bss section besides __bss_start. 35# DATA_PLT - .plt should be in data segment, not text segment. 36# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. 37# BSS_PLT - .plt should be in bss segment 38# TEXT_DYNAMIC - .dynamic in text segment, not data segment. 39# EMBEDDED - whether this is for an embedded system. 40# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set 41# start address of shared library. 42# INPUT_FILES - INPUT command of files to always include 43# WRITABLE_RODATA - if set, the .rodata section should be writable 44# INIT_START, INIT_END - statements just before and just after 45# combination of .init sections. 46# FINI_START, FINI_END - statements just before and just after 47# combination of .fini sections. 48# STACK_ADDR - start of a .stack section. 49# OTHER_SYMBOLS - symbols to place right at the end of the script. 50# ETEXT_NAME - name of a symbol for the end of the text section, 51# normally etext. 52# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, 53# so that .got can be in the RELRO area. It should be set to 54# the number of bytes in the beginning of .got.plt which can be 55# in the RELRO area as well. 56# 57# When adding sections, do note that the names of some sections are used 58# when specifying the start address of the next. 59# 60 61# Many sections come in three flavours. There is the 'real' section, 62# like ".data". Then there are the per-procedure or per-variable 63# sections, generated by -ffunction-sections and -fdata-sections in GCC, 64# and useful for --gc-sections, which for a variable "foo" might be 65# ".data.foo". Then there are the linkonce sections, for which the linker 66# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". 67# The exact correspondences are: 68# 69# Section Linkonce section 70# .text .gnu.linkonce.t.foo 71# .rodata .gnu.linkonce.r.foo 72# .data .gnu.linkonce.d.foo 73# .bss .gnu.linkonce.b.foo 74# .sdata .gnu.linkonce.s.foo 75# .sbss .gnu.linkonce.sb.foo 76# .sdata2 .gnu.linkonce.s2.foo 77# .sbss2 .gnu.linkonce.sb2.foo 78# .debug_info .gnu.linkonce.wi.foo 79# .tdata .gnu.linkonce.td.foo 80# .tbss .gnu.linkonce.tb.foo 81# .lrodata .gnu.linkonce.lr.foo 82# .ldata .gnu.linkonce.l.foo 83# .lbss .gnu.linkonce.lb.foo 84# 85# Each of these can also have corresponding .rel.* and .rela.* sections. 86 87test -z "$TRAP" && TRAP=$NOP 88test -z "$ENTRY" && ENTRY=_start 89test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 90test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 91if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 92test -z "${ELFSIZE}" && ELFSIZE=32 93test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" 94test "$LD_FLAG" = "N" && DATA_ADDR=. 95test -z "${ETEXT_NAME}" && ETEXT_NAME=etext 96test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" 97test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" 98test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT 99DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" 100DATA_SEGMENT_RELRO_END="" 101DATA_SEGMENT_END="" 102if test -n "${COMMONPAGESIZE}"; then 103 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" 104 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" 105 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" 106fi 107INTERP=".interp ${RELOCATING-0} : { *(.interp) }" 108if test -z "$PLT"; then 109 PLT=".plt ${RELOCATING-0} : { *(.plt) }" 110fi 111test -n "${PLT_BEFORE_GOT-${DATA_PLT-${BSS_PLT-text}}}" && TEXT_PLT=yes 112if test -z "$GOT"; then 113 if test -z "$SEPARATE_GOTPLT"; then 114 GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" 115 else 116 GOT=".got ${RELOCATING-0} : { *(.got) }" 117 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }" 118 fi 119fi 120DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" 121RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" 122DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }" 123STACKNOTE="/DISCARD/ : { *(.note.GNU-stack) }" 124if test -z "${NO_SMALL_DATA}"; then 125 SBSS=".sbss ${RELOCATING-0} : 126 { 127 ${RELOCATING+${SBSS_START_SYMBOLS}} 128 ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)} 129 *(.dynsbss) 130 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) 131 *(.scommon) 132 ${RELOCATING+${SBSS_END_SYMBOLS}} 133 }" 134 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" 135 SDATA="/* We want the small data sections together, so single-instruction offsets 136 can access them all, and initialized data all before uninitialized, so 137 we can shorten the on-disk segment size. */ 138 .sdata ${RELOCATING-0} : 139 { 140 ${RELOCATING+${SDATA_START_SYMBOLS}} 141 ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)} 142 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) 143 }" 144 SDATA2=".sdata2 ${RELOCATING-0} : 145 { 146 ${RELOCATING+${SDATA2_START_SYMBOLS}} 147 *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) 148 }" 149 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } 150 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" 151 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } 152 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" 153 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } 154 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" 155 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } 156 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" 157else 158 NO_SMALL_DATA=" " 159fi 160if test -z "${DATA_GOT}"; then 161 if test -n "${NO_SMALL_DATA}"; then 162 DATA_GOT=" " 163 fi 164fi 165if test -z "${SDATA_GOT}"; then 166 if test -z "${NO_SMALL_DATA}"; then 167 SDATA_GOT=" " 168 fi 169fi 170test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " 171test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" 172 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } 173 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } 174 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } 175 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } 176 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } 177 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" 178test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" 179 .lbss ${RELOCATING-0} : 180 { 181 *(.dynlbss) 182 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) 183 *(LARGE_COMMON) 184 } 185 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 186 { 187 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) 188 } 189 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : 190 { 191 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) 192 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 193 }" 194RODATA_ALIGN_ADD_VAL="${CREATE_SHLIB-${RODATA_ALIGN_ADD:-0}} ${CREATE_SHLIB+0}" 195test "$LD_FLAG" = "n" || test "$LD_FLAG" = "N" || test "${LD_FLAG%%(cpie|pie)}" = "Z" || NO_PAD="y" 196if test "$NO_PAD" = "y" ; then 197 PAD_RO0="${RELOCATING+${RODATA_ALIGN} + ${RODATA_ALIGN_ADD_VAL};}" 198 PAD_PLT0="${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));}" 199 PAD_PLT1="${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));}" 200 PAD_GOT0="${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));} .gotpad0 ${RELOCATING-0} : { ${RELOCATING+__got_start = .;} }" 201 PAD_GOT1=".gotpad1 ${RELOCATING-0} : { ${RELOCATING+__got_end = .;}} ${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));}" 202 test "$NO_PAD_CDTOR" = "y" || PAD_CDTOR= 203fi 204 205CTOR=".ctors ${CONSTRUCTING-0} : 206 { 207 ${CONSTRUCTING+${CTOR_START}} 208 /* gcc uses crtbegin.o to find the start of 209 the constructors, so we make sure it is 210 first. Because this is a wildcard, it 211 doesn't matter if the user does not 212 actually link against crtbegin.o; the 213 linker won't look for a file to match a 214 wildcard. The wildcard also means that it 215 doesn't matter which directory crtbegin.o 216 is in. */ 217 218 KEEP (*crtbegin*.o(.ctors)) 219 220 /* We don't want to include the .ctor section from 221 the crtend.o file until after the sorted ctors. 222 The .ctor section from the crtend file contains the 223 end of ctors marker and it must be last */ 224 225 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) 226 KEEP (*(SORT(.ctors.*))) 227 KEEP (*(.ctors)) 228 ${CONSTRUCTING+${CTOR_END}} 229 }" 230DTOR=".dtors ${CONSTRUCTING-0} : 231 { 232 ${CONSTRUCTING+${DTOR_START}} 233 KEEP (*crtbegin*.o(.dtors)) 234 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) 235 KEEP (*(SORT(.dtors.*))) 236 KEEP (*(.dtors)) 237 ${CONSTRUCTING+${DTOR_END}} 238 }" 239STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : 240 { 241 ${RELOCATING+_stack = .;} 242 *(.stack) 243 }" 244 245# if this is for an embedded system, don't add SIZEOF_HEADERS. 246if [ -z "$EMBEDDED" ]; then 247 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" 248else 249 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" 250fi 251 252cat <<EOF 253OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 254 "${LITTLE_OUTPUT_FORMAT}") 255OUTPUT_ARCH(${OUTPUT_ARCH}) 256ENTRY(${ENTRY}) 257 258${RELOCATING+${LIB_SEARCH_DIRS}} 259${RELOCATING+${EXECUTABLE_SYMBOLS}} 260${RELOCATING+${INPUT_FILES}} 261${RELOCATING- /* For some reason, the Solaris linker makes bad executables 262 if gld -r is used and the intermediate file has sections starting 263 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld 264 bug. But for now assigning the zero vmas works. */} 265 266SECTIONS 267{ 268 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} 269 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} 270 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} 271 ${CREATE_SHLIB-${INTERP}} 272 ${INITIAL_READONLY_SECTIONS} 273 ${TEXT_DYNAMIC+${DYNAMIC}} 274 .hash ${RELOCATING-0} : { *(.hash) } 275 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } 276 .dynsym ${RELOCATING-0} : { *(.dynsym) } 277 .dynstr ${RELOCATING-0} : { *(.dynstr) } 278 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 279 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } 280 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } 281 282EOF 283if [ "x$COMBRELOC" = x ]; then 284 COMBRELOCCAT=cat 285else 286 COMBRELOCCAT="cat > $COMBRELOC" 287fi 288eval $COMBRELOCCAT <<EOF 289 .rel.init ${RELOCATING-0} : { *(.rel.init) } 290 .rela.init ${RELOCATING-0} : { *(.rela.init) } 291 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } 292 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } 293 .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 294 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 295 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } 296 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } 297 ${OTHER_READONLY_RELOC_SECTIONS} 298 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) } 299 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) } 300 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } 301 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } 302 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } 303 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } 304 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } 305 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } 306 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 307 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 308 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 309 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 310 .rel.got ${RELOCATING-0} : { *(.rel.got) } 311 .rela.got ${RELOCATING-0} : { *(.rela.got) } 312 ${OTHER_GOT_RELOC_SECTIONS} 313 ${REL_SDATA} 314 ${REL_SBSS} 315 ${REL_SDATA2} 316 ${REL_SBSS2} 317 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } 318 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } 319 ${REL_LARGE} 320EOF 321if [ -n "$COMBRELOC" ]; then 322cat <<EOF 323 .rel.dyn ${RELOCATING-0} : 324 { 325EOF 326sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC 327cat <<EOF 328 } 329 .rela.dyn ${RELOCATING-0} : 330 { 331EOF 332sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC 333cat <<EOF 334 } 335EOF 336fi 337cat <<EOF 338 .rel.plt ${RELOCATING-0} : { *(.rel.plt) } 339 .rela.plt ${RELOCATING-0} : { *(.rela.plt) } 340 ${OTHER_PLT_RELOC_SECTIONS} 341 342 ${WRITABLE_RODATA-${RODATA}} 343 .rodata1 ${RELOCATING-0} : { *(.rodata1) } 344 ${CREATE_SHLIB-${SDATA2}} 345 ${CREATE_SHLIB-${SBSS2}} 346 ${OTHER_READONLY_SECTIONS} 347 .eh_frame_hdr : { *(.eh_frame_hdr) } 348 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } 349 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } 350 351 /* Read-only sections, merged into text segment: */ 352 ${PAD_RO+${PAD_RO0}} 353 .init ${RELOCATING-0} : 354 { 355 ${RELOCATING+${INIT_START}} 356 KEEP (*(.init)) 357 ${RELOCATING+${INIT_END}} 358 } =${NOP-0} 359 360 ${TEXT_PLT+${PLT}} 361 ${TINY_READONLY_SECTION} 362 .text ${RELOCATING-0} : 363 { 364 ${RELOCATING+${TEXT_START_SYMBOLS}} 365 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) 366 KEEP (*(.text.*personality*)) 367 /* .gnu.warning sections are handled specially by elf32.em. */ 368 *(.gnu.warning) 369 ${RELOCATING+${OTHER_TEXT_SECTIONS}} 370 } =${TRAP-0} 371 .fini ${RELOCATING-0} : 372 { 373 ${RELOCATING+${FINI_START}} 374 KEEP (*(.fini)) 375 ${RELOCATING+${FINI_END}} 376 } =${NOP-0} 377 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} 378 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} 379 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} 380 381 ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PAD_PLT+${PAD_PLT0}}}}} 382 ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}} 383 ${DATA_NONEXEC_PLT+${SDATA_GOT+${PAD_GOT+${PAD_GOT0}}}} 384 ${DATA_NONEXEC_PLT+${SDATA_GOT+${PLT}}} 385 ${DATA_NONEXEC_PLT+${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}} 386 ${DATA_NONEXEC_PLT+${SDATA_GOT+${sdata_GOT-${GOT}}}} 387 ${DATA_NONEXEC_PLT+${SDATA_GOT+${OTHER_GOT_SECTIONS}}} 388 ${DATA_NONEXEC_PLT+${SDATA_GOT+${PAD_GOT+${PAD_GOT1}}}} 389 390 /* Adjust the address for the data segment. We want to adjust up to 391 the same address within the page on the next page up. */ 392 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} 393 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 394 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 395 ${DATA_GOT+${PAD_GOT+${RELOCATING+PROVIDE_HIDDEN(__got_start = .);}}} 396 ${SDATA_GOT+${PAD_GOT+${RELOCATING+PROVIDE_HIDDEN(__got_start = .);}}} 397 398 /* Exception handling */ 399 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } 400 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 401 402 /* Thread Local Storage sections */ 403 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } 404 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } 405 406 .preinit_array ${RELOCATING-0} : 407 { 408 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_start = .);}} 409 KEEP (*(.preinit_array)) 410 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_end = .);}} 411 } 412 .init_array ${RELOCATING-0} : 413 { 414 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_start = .);}} 415 KEEP (*(SORT(.init_array.*))) 416 KEEP (*(.init_array)) 417 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_end = .);}} 418 } 419 .fini_array ${RELOCATING-0} : 420 { 421 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_start = .);}} 422 KEEP (*(.fini_array)) 423 KEEP (*(SORT(.fini_array.*))) 424 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}} 425 } 426 .openbsd.randomdata ${RELOCATING-0} : 427 { 428 *(.openbsd.randomdata${RELOCATING+ .openbsd.randomdata.*}) 429 } 430 ${PAD_CDTOR-${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}} 431 ${PAD_CDTOR-${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}} 432 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } 433 434 ${RELOCATING+${DATARELRO}} 435 ${OTHER_RELRO_SECTIONS} 436 ${TEXT_DYNAMIC-${DYNAMIC}} 437 /* If PAD_CDTOR, and separate .got and .got.plt sections, CTOR and DTOR 438 are relocated here to receive the same mprotect protection as .got */ 439 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${PAD_CDTOR+${RELOCATING+${CTOR}}}}}} 440 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${PAD_CDTOR+${RELOCATING+${DTOR}}}}}} 441 ${DATA_GOT+${RELRO_NOW+${PAD_CDTOR+${RELOCATING+${CTOR}}}}} 442 ${DATA_GOT+${RELRO_NOW+${PAD_CDTOR+${RELOCATING+${DTOR}}}}} 443 ${DATA_GOT+${DATA_NONEXEC_PLT+${PLT}}} 444 ${DATA_GOT+${RELRO_NOW+${GOT}}} 445 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} 446 ${DATA_GOT+${RELRO_NOW+${SDATA_GOT-${PAD_GOT+${RELOCATING+PROVIDE_HIDDEN(__got_end = .);}}}}} 447 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} 448 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${PAD_GOT+${PAD_GOT1}}}}} 449 450 ${DATA_NONEXEC_PLT+${DATA_GOT-${PAD_CDTOR+${RELOCATING+${CTOR}}}}} 451 ${DATA_NONEXEC_PLT+${DATA_GOT-${PAD_CDTOR+${RELOCATING+${DTOR}}}}} 452 ${DATA_NONEXEC_PLT-${DATA_GOT-${PAD_CDTOR+${RELOCATING+${CTOR}}}}} 453 ${DATA_NONEXEC_PLT-${DATA_GOT-${PAD_CDTOR+${RELOCATING+${DTOR}}}}} 454 455 ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}} 456 ${DATA_NONEXEC_PLT-${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}} 457 ${DATA_NONEXEC_PLT-${SDATA_GOT+${sdata_GOT-${GOT}}}} 458 459 ${DATA_NONEXEC_PLT-${SDATA_GOT+${OTHER_GOT_SECTIONS}}} 460 ${DATA_NONEXEC_PLT-${SDATA_GOT+${RELRO_NOW+${RELOCATING+PROVIDE_HIDDEN(__got_end = .);}}}} 461 ${DATA_NONEXEC_PLT-${SDATA_GOT+${RELRO_NOW-${RELOCATING+${PAD_GOT1}}}}} 462 463 ${BSS_PLT+${bss_PLT-${PLT}}} 464 465 ${RELOCATING+${DATA_SEGMENT_RELRO_END}} 466 467 ${SDATA} 468 ${OTHER_SDATA_SECTIONS} 469 470 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} 471 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${PAD_CDTOR+${RELOCATING+${CTOR}}}}}} 472 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${PAD_CDTOR+${RELOCATING+${DTOR}}}}}} 473 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${PAD_GOT+${PAD_GOT1}}}}} 474 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} 475 476 .data ${RELOCATING-0} : 477 { 478 ${RELOCATING+${DATA_START_SYMBOLS}} 479 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) 480 KEEP (*(.gnu.linkonce.d.*personality*)) 481 ${CONSTRUCTING+SORT(CONSTRUCTORS)} 482 } 483 .data1 ${RELOCATING-0} : { *(.data1) } 484 ${WRITABLE_RODATA+${RODATA}} 485 ${OTHER_READWRITE_SECTIONS} 486 ${PAD_CDTOR-${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}} 487 ${PAD_CDTOR-${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}} 488 489 ${RELOCATING+${DATA_END_SYMBOLS-_edata = .; PROVIDE (edata = .);}} 490 ${RELOCATING+__bss_start = .;} 491 ${RELOCATING+${OTHER_BSS_SYMBOLS}} 492 ${SBSS} 493 .bss ${RELOCATING-0} : 494 { 495 *(.dynbss) 496 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) 497 *(COMMON) 498 /* Align here to ensure that the .bss section occupies space up to 499 _end. Align after .bss to ensure correct alignment even if the 500 .bss section disappears because there are no input sections. 501 FIXME: Why do we need it? When there is no .bss section, we don't 502 pad the .data section. */ 503 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} 504 } 505 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} 506 ${RELOCATING+. = ALIGN(${ALIGNMENT});} 507 ${LARGE_SECTIONS} 508 ${RELOCATING+. = ALIGN(${ALIGNMENT});} 509 ${RELOCATING+${OTHER_END_SYMBOLS}} 510 ${RELOCATING+${END_SYMBOLS-_end = .; PROVIDE (end = .);}} 511 ${RELOCATING+${DATA_SEGMENT_END}} 512 513 /* Stabs debugging sections. */ 514 .stab 0 : { *(.stab) } 515 .stabstr 0 : { *(.stabstr) } 516 .stab.excl 0 : { *(.stab.excl) } 517 .stab.exclstr 0 : { *(.stab.exclstr) } 518 .stab.index 0 : { *(.stab.index) } 519 .stab.indexstr 0 : { *(.stab.indexstr) } 520 521 .comment 0 : { *(.comment) } 522 523 /* DWARF debug sections. 524 Symbols in the DWARF debugging sections are relative to the beginning 525 of the section so we begin them at 0. */ 526 527 /* DWARF 1 */ 528 .debug 0 : { *(.debug) } 529 .line 0 : { *(.line) } 530 531 /* GNU DWARF 1 extensions */ 532 .debug_srcinfo 0 : { *(.debug_srcinfo) } 533 .debug_sfnames 0 : { *(.debug_sfnames) } 534 535 /* DWARF 1.1 and DWARF 2 */ 536 .debug_aranges 0 : { *(.debug_aranges) } 537 .debug_pubnames 0 : { *(.debug_pubnames) } 538 539 /* DWARF 2 */ 540 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 541 .debug_abbrev 0 : { *(.debug_abbrev) } 542 .debug_line 0 : { *(.debug_line) } 543 .debug_frame 0 : { *(.debug_frame) } 544 .debug_str 0 : { *(.debug_str) } 545 .debug_loc 0 : { *(.debug_loc) } 546 .debug_macinfo 0 : { *(.debug_macinfo) } 547 548 /* SGI/MIPS DWARF 2 extensions */ 549 .debug_weaknames 0 : { *(.debug_weaknames) } 550 .debug_funcnames 0 : { *(.debug_funcnames) } 551 .debug_typenames 0 : { *(.debug_typenames) } 552 .debug_varnames 0 : { *(.debug_varnames) } 553 554 ${TINY_DATA_SECTION} 555 ${TINY_BSS_SECTION} 556 557 ${STACK_ADDR+${STACK}} 558 ${OTHER_SECTIONS} 559 ${RELOCATING+${OTHER_SYMBOLS}} 560 ${RELOCATING+${STACKNOTE}} 561} 562EOF 563