From be2c2e39a9d05fca8c6a2b82f1a0674da0aa35fb Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Thu, 12 May 2005 00:31:22 +0000 Subject: [PATCH] * scripttempl/elfxtensa.sc: Sync up with elf.sc. * emulparams/elf32xtensa.sh (PLT, GOT): Define. --- ld/ChangeLog | 5 ++ ld/emulparams/elf32xtensa.sh | 2 + ld/scripttempl/elfxtensa.sc | 97 ++++++++++++++++++++++++------------ 3 files changed, 73 insertions(+), 31 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index e9d188cdb0..34ab8cf110 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2005-05-11 Bob Wilson + + * scripttempl/elfxtensa.sc: Sync up with elf.sc. + * emulparams/elf32xtensa.sh (PLT, GOT): Define. + 2005-05-11 Alan Modra * ldgram.y: Add SPECIAL token. diff --git a/ld/emulparams/elf32xtensa.sh b/ld/emulparams/elf32xtensa.sh index cf456c7ab0..c4b13b9a51 100644 --- a/ld/emulparams/elf32xtensa.sh +++ b/ld/emulparams/elf32xtensa.sh @@ -15,6 +15,8 @@ MACHINE= GENERATE_SHLIB_SCRIPT=yes GENERATE_COMBRELOC_SCRIPT=yes NO_SMALL_DATA=yes +PLT="/* .plt* sections are embedded in .text */" +GOT=".got ${RELOCATING-0} : { *(.got) }" OTHER_READONLY_SECTIONS=" .got.loc ${RELOCATING-0} : { *(.got.loc) } .xt_except_table ${RELOCATING-0} : { KEEP (*(.xt_except_table)) } diff --git a/ld/scripttempl/elfxtensa.sc b/ld/scripttempl/elfxtensa.sc index 632cf6dc48..94ebe46408 100644 --- a/ld/scripttempl/elfxtensa.sc +++ b/ld/scripttempl/elfxtensa.sc @@ -3,6 +3,8 @@ # NOP - four byte opcode for no-op (defaults to 0) # NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not # empty. +# SMALL_DATA_CTOR - .ctors contains small data. +# SMALL_DATA_DTOR - .dtors contains small data. # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start # INITIAL_READONLY_SECTIONS - at start of text segment # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... @@ -16,15 +18,23 @@ # OTHER_SECTIONS - at the end # EXECUTABLE_SYMBOLS - symbols that must be defined for an # executable (e.g., _DYNAMIC_LINK) +# TEXT_START_ADDR - the first byte of the text segment, after any +# headers. +# TEXT_BASE_ADDRESS - the first byte of the text segment. # TEXT_START_SYMBOLS - symbols that appear at the start of the # .text section. # DATA_START_SYMBOLS - symbols that appear at the start of the # .data section. +# DATA_END_SYMBOLS - symbols that appear at the end of the +# writeable data sections. # OTHER_GOT_SYMBOLS - symbols defined just before .got. # OTHER_GOT_SECTIONS - sections just after .got. # OTHER_SDATA_SECTIONS - sections just after .sdata. # OTHER_BSS_SYMBOLS - symbols that appear at the start of the # .bss section besides __bss_start. +# 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 # TEXT_DYNAMIC - .dynamic in text segment, not data segment. # EMBEDDED - whether this is for an embedded system. # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set @@ -37,6 +47,12 @@ # combination of .fini sections. # STACK_ADDR - start of a .stack section. # OTHER_END_SYMBOLS - symbols to place right at the end of the script. +# ETEXT_NAME - name of a symbol for the end of the text section, +# normally etext. +# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, +# so that .got can be in the RELRO area. It should be set to +# the number of bytes in the beginning of .got.plt which can be +# in the RELRO area as well. # # When adding sections, do note that the names of some sections are used # when specifying the start address of the next. @@ -66,22 +82,35 @@ # Each of these can also have corresponding .rel.* and .rela.* sections. test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi test -z "${ELFSIZE}" && ELFSIZE=32 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" test "$LD_FLAG" = "N" && DATA_ADDR=. +test -z "${ETEXT_NAME}" && ETEXT_NAME=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 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 (.);" + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" fi INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +if test -z "$PLT"; then + PLT=".plt ${RELOCATING-0} : { *(.plt) }" +fi if test -z "$GOT"; then + if test -z "$SEPARATE_GOTPLT"; then + GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" + else GOT=".got ${RELOCATING-0} : { *(.got) }" + GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }" + fi fi DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" @@ -94,13 +123,10 @@ FINI=".fini 0 : { *(.fini) }" if test -z "${NO_SMALL_DATA}"; then SBSS=".sbss ${RELOCATING-0} : { - ${RELOCATING+PROVIDE (__sbss_start = .);} - ${RELOCATING+PROVIDE (___sbss_start = .);} + ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)} *(.dynsbss) *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) *(.scommon) - ${RELOCATING+PROVIDE (__sbss_end = .);} - ${RELOCATING+PROVIDE (___sbss_end = .);} }" SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" SDATA="/* We want the small data sections together, so single-instruction offsets @@ -109,6 +135,7 @@ if test -z "${NO_SMALL_DATA}"; then .sdata ${RELOCATING-0} : { ${RELOCATING+${SDATA_START_SYMBOLS}} + ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)} *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) }" SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }" @@ -123,6 +150,17 @@ if test -z "${NO_SMALL_DATA}"; then else NO_SMALL_DATA=" " fi +if test -z "${DATA_GOT}"; then + if test -n "${NO_SMALL_DATA}"; then + DATA_GOT=" " + fi +fi +if test -z "${SDATA_GOT}"; then + if test -z "${NO_SMALL_DATA}"; then + SDATA_GOT=" " + fi +fi +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " CTOR=".ctors ${CONSTRUCTING-0} : { ${CONSTRUCTING+${CTOR_START}} @@ -261,6 +299,7 @@ cat <