On Sun, 7 Aug 2016, Philip Guenther wrote: > On Sun, 7 Aug 2016, Mark Kettenis wrote: > ... > > Going to give this a go on hppa to see if I can spot any issues there. > > It works there just as well as before for me, with no new failures in my > "try lots of ld option combinations" test. Since it has an executable > .plt, to make relro work will require a layout more like sparc64, with the > .plt section hoisted to before the data. I need to see what the > limitations on .plt<-->.got distance are to see where .got goes for that.
New diff, adding relro support for hppa! Yay! Still need to fix powerpc! Boo! I'm looking for anyone with alpha or landisk that can test relro there. Just add "|| defined(__alpha__) || defined(__sh__)" to the #if in the first chunk below, then: cd gnu/usr.bin/binutils-2.17 make -f Makefile.bsd-wrapper doas make -f Makefile.bsd-wrapper install ...and apply the lib/csu and libexec/ld.so diffs, rebuild and install in ld.so and lib/csu, then try building the world! Philip Index: gnu/usr.bin/binutils-2.17/ld/ldmain.c =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/ldmain.c,v retrieving revision 1.9 diff -u -p -r1.9 ldmain.c --- gnu/usr.bin/binutils-2.17/ld/ldmain.c 21 Jun 2016 02:55:57 -0000 1.9 +++ gnu/usr.bin/binutils-2.17/ld/ldmain.c 8 Aug 2016 02:31:00 -0000 @@ -299,7 +299,12 @@ main (int argc, char **argv) link_info.new_dtags = FALSE; link_info.combreloc = TRUE; link_info.eh_frame_hdr = FALSE; +#if defined(__amd64__) || defined(__arm__) || defined(__i386__) || \ + defined(__hppa__) || defined(__sparc64__) + link_info.relro = TRUE; +#else link_info.relro = FALSE; +#endif link_info.strip_discarded = TRUE; link_info.strip = strip_none; link_info.discard = discard_sec_merge; Index: gnu/usr.bin/binutils-2.17/ld/emulparams/armelf_obsd.sh =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/emulparams/armelf_obsd.sh,v retrieving revision 1.1 diff -u -p -r1.1 armelf_obsd.sh --- gnu/usr.bin/binutils-2.17/ld/emulparams/armelf_obsd.sh 24 Apr 2011 20:19:25 -0000 1.1 +++ gnu/usr.bin/binutils-2.17/ld/emulparams/armelf_obsd.sh 19 Jul 2016 15:29:16 -0000 @@ -1,8 +1,10 @@ . ${srcdir}/emulparams/armelf.sh -. ${srcdir}/emulparams/elf_obsd.sh MAXPAGESIZE=0x8000 +COMMONPAGESIZE=0x1000 TEXT_START_ADDR=0x00008000 TARGET2_TYPE=got-rel unset EMBEDDED + +. ${srcdir}/emulparams/elf_obsd.sh Index: gnu/usr.bin/binutils-2.17/ld/emulparams/elf32ppc_obsd.sh =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/emulparams/elf32ppc_obsd.sh,v retrieving revision 1.3 diff -u -p -r1.3 elf32ppc_obsd.sh --- gnu/usr.bin/binutils-2.17/ld/emulparams/elf32ppc_obsd.sh 23 Aug 2015 15:19:32 -0000 1.3 +++ gnu/usr.bin/binutils-2.17/ld/emulparams/elf32ppc_obsd.sh 4 Jul 2016 01:57:30 -0000 @@ -1,7 +1,2 @@ -. ${srcdir}/emulparams/elf32ppccommon.sh -# We deliberately keep the traditional OpenBSD W^X layout for both the -# old BSS-PLT and the new Secure-PLT ABI. -BSS_PLT= -OTHER_TEXT_SECTIONS="*(.glink)" -EXTRA_EM_FILE=ppc32elf +. ${srcdir}/emulparams/elf32ppc.sh . ${srcdir}/emulparams/elf_obsd.sh Index: gnu/usr.bin/binutils-2.17/ld/emulparams/elf64btsmip_obsd.sh =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/emulparams/elf64btsmip_obsd.sh,v retrieving revision 1.2 diff -u -p -r1.2 elf64btsmip_obsd.sh --- gnu/usr.bin/binutils-2.17/ld/emulparams/elf64btsmip_obsd.sh 16 Jun 2015 20:25:35 -0000 1.2 +++ gnu/usr.bin/binutils-2.17/ld/emulparams/elf64btsmip_obsd.sh 4 Jul 2016 01:57:30 -0000 @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/elf64btsmip.sh MAXPAGESIZE=0x10000 +COMMONPAGESIZE=0x1000 TEXT_START_ADDR="0x10000000" . ${srcdir}/emulparams/elf_obsd.sh # XXX causes GOT oflows Index: gnu/usr.bin/binutils-2.17/ld/emulparams/elf64ltsmip_obsd.sh =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/emulparams/elf64ltsmip_obsd.sh,v retrieving revision 1.2 diff -u -p -r1.2 elf64ltsmip_obsd.sh --- gnu/usr.bin/binutils-2.17/ld/emulparams/elf64ltsmip_obsd.sh 16 Jun 2015 20:25:35 -0000 1.2 +++ gnu/usr.bin/binutils-2.17/ld/emulparams/elf64ltsmip_obsd.sh 4 Jul 2016 01:57:30 -0000 @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/elf64ltsmip.sh MAXPAGESIZE=0x10000 +COMMONPAGESIZE=0x1000 TEXT_START_ADDR="0x10000000" . ${srcdir}/emulparams/elf_obsd.sh # XXX causes GOT oflows Index: gnu/usr.bin/binutils-2.17/ld/emulparams/hppaobsd.sh =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/emulparams/hppaobsd.sh,v retrieving revision 1.3 diff -u -p -r1.3 hppaobsd.sh --- gnu/usr.bin/binutils-2.17/ld/emulparams/hppaobsd.sh 21 Mar 2013 22:32:30 -0000 1.3 +++ gnu/usr.bin/binutils-2.17/ld/emulparams/hppaobsd.sh 8 Aug 2016 01:58:55 -0000 @@ -7,6 +7,7 @@ OUTPUT_FORMAT="elf32-hppa" # other necessary defines, similar but not the same as linux. MAXPAGESIZE=0x1000 +COMMONPAGESIZE=0x1000 ENTRY="__start" MACHINE=hppa1.1 # We use 1.1 specific features. OTHER_READONLY_SECTIONS=".PARISC.unwind ${RELOCATING-0} : { *(.PARISC.unwind) }" Index: gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc =================================================================== RCS file: /data/src/openbsd/src/gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc,v retrieving revision 1.8 diff -u -p -r1.8 elf.sc --- gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc 9 Aug 2014 04:49:47 -0000 1.8 +++ gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc 8 Aug 2016 02:22:54 -0000 @@ -267,6 +267,35 @@ SECTIONS ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + + ${TEXT_PLT+${PLT}} + ${TINY_READONLY_SECTION} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + KEEP (*(.text.*personality*)) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} + + ${PAD_RO+${PAD_RO0}} ${CREATE_SHLIB-${INTERP}} ${INITIAL_READONLY_SECTIONS} ${TEXT_DYNAMIC+${DYNAMIC}} @@ -337,34 +366,6 @@ cat <<EOF .rela.plt ${RELOCATING-0} : { *(.rela.plt) } ${OTHER_PLT_RELOC_SECTIONS} - .init ${RELOCATING-0} : - { - ${RELOCATING+${INIT_START}} - KEEP (*(.init)) - ${RELOCATING+${INIT_END}} - } =${NOP-0} - - ${TEXT_PLT+${PLT}} - ${TINY_READONLY_SECTION} - .text ${RELOCATING-0} : - { - ${RELOCATING+${TEXT_START_SYMBOLS}} - *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) - KEEP (*(.text.*personality*)) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - ${RELOCATING+${OTHER_TEXT_SECTIONS}} - } =${NOP-0} - .fini ${RELOCATING-0} : - { - ${RELOCATING+${FINI_START}} - KEEP (*(.fini)) - ${RELOCATING+${FINI_END}} - } =${NOP-0} - ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} - ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} - ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} - ${PAD_RO+${PAD_RO0}} ${WRITABLE_RODATA-${RODATA}} .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${CREATE_SHLIB-${SDATA2}} @@ -374,11 +375,21 @@ cat <<EOF .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PAD_PLT+${PAD_PLT0}}}}} + ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}} + ${DATA_NONEXEC_PLT+${SDATA_GOT+${PAD_GOT+${PAD_GOT0}}}} + ${DATA_NONEXEC_PLT+${SDATA_GOT+${PLT}}} + ${DATA_NONEXEC_PLT+${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}} + ${DATA_NONEXEC_PLT+${SDATA_GOT+${GOT}}} + ${DATA_NONEXEC_PLT+${SDATA_GOT+${OTHER_GOT_SECTIONS}}} + ${DATA_NONEXEC_PLT+${SDATA_GOT+${PAD_GOT+${PAD_GOT1}}}} + /* Adjust the address for the data segment. We want to adjust up to the same address within the page on the next page up. */ ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${DATA_GOT+${RELRO_NOW+${PAD_GOT+${RELOCATING+PROVIDE_HIDDEN(__got_start = .);}}}} /* Exception handling */ .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } @@ -419,17 +430,21 @@ cat <<EOF ${RELOCATING+${DATARELRO}} ${OTHER_RELRO_SECTIONS} ${TEXT_DYNAMIC-${DYNAMIC}} - ${DATA_GOT+${PAD_GOT+${PAD_GOT0}}} + ${DATA_GOT+${RELRO_NOW-${PAD_GOT+${PAD_GOT0}}}} ${DATA_GOT+${DATA_NONEXEC_PLT+${PLT}}} ${DATA_GOT+${RELRO_NOW+${GOT}}} ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} - ${DATA_GOT+${RELRO_NOW+${PAD_GOT+${PAD_GOT1}}}} + ${DATA_GOT+${RELRO_NOW+${PAD_CDTOR+${RELOCATING+${CTOR}}}}} + ${DATA_GOT+${RELRO_NOW+${PAD_CDTOR+${RELOCATING+${DTOR}}}}} + ${DATA_GOT+${RELRO_NOW+${PAD_GOT+${RELOCATING+PROVIDE_HIDDEN(__got_end = .);}}}} ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} /* If PAD_CDTOR, and separate .got and .got.plt sections, CTOR and DTOR are relocated here to receive the same mprotect protection as .got */ ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${PAD_CDTOR+${RELOCATING+${CTOR}}}}}} ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${PAD_CDTOR+${RELOCATING+${DTOR}}}}}} ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${PAD_GOT+${PAD_GOT1}}}}} + ${DATA_NONEXEC_PLT+${DATA_GOT-${PAD_CDTOR+${RELOCATING+${CTOR}}}}} + ${DATA_NONEXEC_PLT+${DATA_GOT-${PAD_CDTOR+${RELOCATING+${DTOR}}}}} ${RELOCATING+${DATA_SEGMENT_RELRO_END}} ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${PAD_CDTOR+${RELOCATING+${CTOR}}}}}} @@ -437,10 +452,6 @@ cat <<EOF ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${PAD_GOT+${PAD_GOT1}}}}} ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} - ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PAD_PLT+${PAD_PLT0}}}}} - ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}} - ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT-${PAD_PLT+${PAD_PLT1}}}}} - .data ${RELOCATING-0} : { ${RELOCATING+${DATA_START_SYMBOLS}} @@ -457,18 +468,15 @@ cat <<EOF ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT+${PAD_PLT+${PAD_PLT0}}}}} ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}} ${DATA_NONEXEC_PLT-${DATA_PLT+${PLT_BEFORE_GOT+${PAD_PLT+${PAD_PLT1}}}}} - ${SDATA_GOT+${PAD_GOT+${PAD_GOT0}}} - ${SDATA_GOT+${DATA_NONEXEC_PLT+${PLT}}} - ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}} - ${SDATA_GOT+${GOT}} + ${DATA_NONEXEC_PLT-${SDATA_GOT+${PAD_GOT+${PAD_GOT0}}}} + ${DATA_NONEXEC_PLT-${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}} + ${DATA_NONEXEC_PLT-${SDATA_GOT+${GOT}}} - ${DATA_GOT+${RELRO_NOW+${PAD_CDTOR+${RELOCATING+${CTOR}}}}} - ${DATA_GOT+${RELRO_NOW+${PAD_CDTOR+${RELOCATING+${DTOR}}}}} - ${DATA_GOT-${PAD_CDTOR+${RELOCATING+${CTOR}}}} - ${DATA_GOT-${PAD_CDTOR+${RELOCATING+${DTOR}}}} + ${DATA_NONEXEC_PLT-${DATA_GOT-${PAD_CDTOR+${RELOCATING+${CTOR}}}}} + ${DATA_NONEXEC_PLT-${DATA_GOT-${PAD_CDTOR+${RELOCATING+${DTOR}}}}} - ${SDATA_GOT+${OTHER_GOT_SECTIONS}} - ${SDATA_GOT+${PAD_GOT+${PAD_GOT1}}} + ${DATA_NONEXEC_PLT-${SDATA_GOT+${OTHER_GOT_SECTIONS}}} + ${DATA_NONEXEC_PLT-${SDATA_GOT+${PAD_GOT+${PAD_GOT1}}}} ${SDATA} ${OTHER_SDATA_SECTIONS}