X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Fscripttempl%2Felf.sc;h=c0845c5952e5e11bc0275640be40f3a7bb3a65cd;hb=6c19b93bcd0d136f7be4d1e1e3f2e8d7b5917009;hp=1a924669555885304f185bae5274ed63a531d77e;hpb=d2667025dd30611514810c28bee9709e4623012a;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 1a92466955..c0845c5952 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -1,3 +1,8 @@ +# Copyright (C) 2014-2017 Free Software Foundation, Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. # # Unusual variables checked by this code: # NOP - four byte opcode for no-op (defaults to none) @@ -10,10 +15,12 @@ # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... # (e.g., .PARISC.milli) # OTHER_TEXT_SECTIONS - these get put in .text when relocating +# INITIAL_READWRITE_SECTIONS - at start of data segment (after relro) # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... # (e.g., .PARISC.global) # OTHER_RELRO_SECTIONS - other than .data.rel.ro ... # (e.g. PPC32 .fixup, .got[12]) +# OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment # OTHER_BSS_SECTIONS - other than .bss .sbss ... # ATTRS_SECTIONS - at the end # OTHER_SECTIONS - at the end @@ -33,6 +40,7 @@ # OTHER_SDATA_SECTIONS - sections just after .sdata. # OTHER_BSS_SYMBOLS - symbols that appear at the start of the # .bss section besides __bss_start. +# PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment. # DATA_PLT - .plt should be in data segment, not text segment. # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. # BSS_PLT - .plt should be in bss segment @@ -46,9 +54,9 @@ # INPUT_FILES - INPUT command of files to always include # WRITABLE_RODATA - if set, the .rodata section should be writable # INIT_START, INIT_END - statements just before and just after -# combination of .init sections. +# combination of .init sections. # FINI_START, FINI_END - statements just before and just after -# combination of .fini sections. +# combination of .fini sections. # STACK_ADDR - start of a .stack section. # OTHER_SYMBOLS - symbols to place right at the end of the script. # ETEXT_NAME - name of a symbol for the end of the text section, @@ -112,17 +120,23 @@ test -z "${ELFSIZE}" && ELFSIZE=32 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" test "$LD_FLAG" = "N" && DATA_ADDR=. test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext -test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" -test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" -DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" -DATA_SEGMENT_RELRO_END="" -DATA_SEGMENT_END="" -if test -n "${COMMONPAGESIZE}"; then - DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" - DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" - DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" +if test -z "$DATA_SEGMENT_ALIGN"; then + test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" + test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" + DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" + DATA_SEGMENT_RELRO_END="" + DATA_SEGMENT_END="" + if test -n "${COMMONPAGESIZE}"; then + if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + else + DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + fi + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" + fi fi if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" @@ -132,7 +146,7 @@ if test -z "$PLT"; then PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} } ${IREL_IN_PLT-$IPLT}" fi -test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes +test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= if test -z "$GOT"; then if test -z "$SEPARATE_GOTPLT"; then GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }" @@ -195,12 +209,12 @@ if test -z "${NO_SMALL_DATA}"; then else NO_SMALL_DATA=" " fi -if test -z "${DATA_GOT}"; then +if test -z "${SDATA_GOT}${DATA_GOT}"; then if test -n "${NO_SMALL_DATA}"; then DATA_GOT=" " fi fi -if test -z "${SDATA_GOT}"; then +if test -z "${SDATA_GOT}${DATA_GOT}"; then if test -z "${NO_SMALL_DATA}"; then SDATA_GOT=" " fi @@ -213,8 +227,7 @@ test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" -test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS=" - ${OTHER_BSS_SECTIONS} +test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" .lbss ${RELOCATING-0} : { *(.dynlbss) @@ -234,8 +247,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" - CTORS_IN_INIT_ARRAY="KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))" - DTORS_IN_FINI_ARRAY="KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))" + CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" + DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" else SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" @@ -246,16 +259,14 @@ INIT_ARRAY=".init_array ${RELOCATING-0} : { ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} ${SORT_INIT_ARRAY} - KEEP (*(.init_array)) - ${CTORS_IN_INIT_ARRAY} + KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} }" FINI_ARRAY=".fini_array ${RELOCATING-0} : { ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} ${SORT_FINI_ARRAY} - KEEP (*(.fini_array)) - ${DTORS_IN_FINI_ARRAY} + KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} }" CTOR=".ctors ${CONSTRUCTING-0} : @@ -294,10 +305,11 @@ DTOR=".dtors ${CONSTRUCTING-0} : KEEP (*(.dtors)) ${CONSTRUCTING+${DTOR_END}} }" -STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : +STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : { ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} *(.stack) + ${RELOCATING+${STACK_SENTINEL}} }" TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" @@ -309,7 +321,7 @@ else SIZEOF_HEADERS_CODE= fi -# if this is for an embedded system, don't add SIZEOF_HEADERS. +# If this is for an embedded system, don't add SIZEOF_HEADERS. if [ -z "$EMBEDDED" ]; then test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" else @@ -317,6 +329,12 @@ else fi cat <> ldscripts/dyntmp.$$ <> ldscripts/dyntmp.$$ +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ cat >> ldscripts/dyntmp.$$ <> ldscripts/dyntmp.$$ +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ cat >> ldscripts/dyntmp.$$ <