mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
afca762f59
Currently on S/390 the .got.plt always comes first which prevents the GNU_RELRO segment from being extended across the non-plt GOT entries. Just swapping both unfortunately is not that simple since our ABI requires the _GLOBAL_OFFSET_TABLE_ symbol to point to the very beginning of the entire GOT. Of the 3 magic GOT entries the first is accessed via got pointer while second and third are being accessed via DT_PLTGOT. In order to keep them together we make DT_PLTGOT to point to the .got instead of .got.plt. However, this violates an assumption in the dynamic linker prelink undo code about the GOTPLT entries starting at DT_PLTGOT + 3. We got rid of this requirement with a Glibc patch already in version 2.24: https://sourceware.org/ml/libc-alpha/2016-06/msg01302.html So the S/390 relro GOT layout will look like this with this patch: +----------------------------------+ |got[0]: DYNAMIC | <--- _GLOBAL_OFFSET_TABLE_ == DT_PLTGOT .got |got[1]: link_map parm | |got[2]: &_dl_runtime_resolve | +----------------------------------+ | | non-plt GOT entries | | | | +----------------------------------+ | | <--- .gotplt, PLT GOT entries | | | | | | +----------------------------------+ The patch detects the current layout in size_dynamic_section in order to deal also with linker scripts not generated by this ld version. With partial relro enabled we pick a linker script where .got and .got.plt are swapped which then triggers the rest of the logic. ld/ChangeLog: 2018-07-18 Andreas Krebbel <krebbel@linux.ibm.com> * emulparams/elf64_s390.sh: Define GENERATE_RELRO_SCRIPT and SEPARATE_GOTPLT. * testsuite/ld-s390/gotreloc_64-relro-1.dd: New test. * testsuite/ld-s390/gotreloc_64-norelro-1.dd: Renamed from ... * testsuite/ld-s390/gotreloc_64-1.dd: ... this. * testsuite/ld-s390/s390.exp: Split the GOT testcase into two. bfd/ChangeLog: 2018-07-18 Andreas Krebbel <krebbel@linux.ibm.com> * elf-s390-common.c (s390_gotplt_after_got_p): New function. (s390_got_pointer): New function. (s390_got_offset): New function. (s390_gotplt_offset): New function. * elf64-s390.c (allocate_dynrelocs): Adjust comment. (elf_s390_size_dynamic_sections): Move space for magic GOT entries from .got.plt to .got if necessary and pick the right location for _GLOBAL_OFFSET_TABLE_. (elf_s390_relocate_section): Use the wrapper functions from elf-s390-common.c to deal with both possible layouts (either .got or .got.plt first). (elf_s390_finish_dynamic_sections): Likewise. (elf_s390_finish_dynamic_symbol): Make the location of the GOT magic entries conditional.
41 lines
923 B
Bash
41 lines
923 B
Bash
SCRIPT_NAME=elf
|
|
ELFSIZE=64
|
|
OUTPUT_FORMAT="elf64-s390"
|
|
NO_REL_RELOCS=yes
|
|
TEXT_START_ADDR=0x1000000
|
|
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
|
|
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
|
|
ARCH="s390:64-bit"
|
|
MACHINE=
|
|
NOP=0x07070707
|
|
TEMPLATE_NAME=elf32
|
|
GENERATE_SHLIB_SCRIPT=yes
|
|
GENERATE_PIE_SCRIPT=yes
|
|
GENERATE_RELRO_SCRIPT=yes
|
|
NO_SMALL_DATA=yes
|
|
EXTRA_EM_FILE=s390
|
|
IREL_IN_PLT=
|
|
SEPARATE_GOTPLT=0
|
|
test -z "$RELRO" && unset SEPARATE_GOTPLT
|
|
|
|
# Treat a host that matches the target with the possible exception of "x"
|
|
# in the name as if it were native.
|
|
if test `echo "$host" | sed -e s/390x/390/` \
|
|
= `echo "$target" | sed -e s/390x/390/`; then
|
|
case " $EMULATION_LIBPATH " in
|
|
*" ${EMULATION_NAME} "*)
|
|
NATIVE=yes
|
|
esac
|
|
fi
|
|
|
|
# Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first
|
|
# on Linux.
|
|
case "$target" in
|
|
s390*-linux*)
|
|
case "$EMULATION_NAME" in
|
|
*64*)
|
|
LIBPATH_SUFFIX=64 ;;
|
|
esac
|
|
;;
|
|
esac
|