summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkurt <kurt@openbsd.org>2008-06-13 23:33:32 +0000
committerkurt <kurt@openbsd.org>2008-06-13 23:33:32 +0000
commit1c90c84b1a7086d22205ee4f0b5d486f81367317 (patch)
tree3e27e27dc42dfe646b0a37a5402485e854cae57f
parentDo not log carp state transitions from or to INIT by default. (diff)
downloadwireguard-openbsd-1c90c84b1a7086d22205ee4f0b5d486f81367317.tar.xz
wireguard-openbsd-1c90c84b1a7086d22205ee4f0b5d486f81367317.zip
Fixup ldscripts for i386 when linked with -pie (no change to non-pie
ldscripts). Correct the xd and xdc ldscripts (pie and pie + combreloc) on i386 and add two new variants for pie + combreloc + Z and pie + Z on all arches. ok drahn@
-rw-r--r--gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh19
-rw-r--r--gnu/usr.bin/binutils/ld/emultempl/elf32.em8
-rw-r--r--gnu/usr.bin/binutils/ld/genscripts.sh13
-rw-r--r--gnu/usr.bin/binutils/ld/scripttempl/elf.sc2
4 files changed, 36 insertions, 6 deletions
diff --git a/gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh b/gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh
index e3e102ab1fb..ae7ba0e3d29 100644
--- a/gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh
+++ b/gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh
@@ -1,14 +1,23 @@
. ${srcdir}/emulparams/elf_i386.sh
. ${srcdir}/emulparams/elf_obsd.sh
-if test "$LD_FLAG" = "Z"
-then
-TEXT_START_ADDR=0x08048000
+if test "${LD_FLAG#"${LD_FLAG%pie}"}" = "pie"; then
+ TEXT_START_ADDR=0x0
+ if test "${LD_FLAG%%(cpie|pie)}" = "Z"; then
+ RODATA_PADSIZE=${MAXPAGESIZE}
+ else
+ RODATA_PADSIZE=0x20000000
+ fi
else
-TEXT_START_ADDR=0x1C000000
+ if test "${LD_FLAG%%(cpie|pie)}" = "Z"; then
+ TEXT_START_ADDR=0x08048000
+ RODATA_PADSIZE=${MAXPAGESIZE}
+ else
+ TEXT_START_ADDR=0x1C000000
+ RODATA_PADSIZE=0x20000000
+ fi
fi
-RODATA_PADSIZE=0x20000000
RODATA_ALIGN=". = ALIGN(${RODATA_PADSIZE})"
RODATA_ALIGN_ADD="${TEXT_START_ADDR}"
diff --git a/gnu/usr.bin/binutils/ld/emultempl/elf32.em b/gnu/usr.bin/binutils/ld/emultempl/elf32.em
index 151ec198dab..f58e848b00b 100644
--- a/gnu/usr.bin/binutils/ld/emultempl/elf32.em
+++ b/gnu/usr.bin/binutils/ld/emultempl/elf32.em
@@ -1740,9 +1740,13 @@ sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
fi
if test -n "$GENERATE_PIE_SCRIPT" ; then
if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
+echo ' ; else if (link_info.pie && link_info.combreloc && config.data_bss_contig == TRUE) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xdcz >> e${EMULATION_NAME}.c
echo ' ; else if (link_info.pie && link_info.combreloc) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
fi
+echo ' ; else if (link_info.pie && config.data_bss_contig == TRUE) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xdz >> e${EMULATION_NAME}.c
echo ' ; else if (link_info.pie) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
fi
@@ -1788,11 +1792,15 @@ fi
if test -n "$GENERATE_PIE_SCRIPT" ; then
if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
cat >>e${EMULATION_NAME}.c <<EOF
+ else if (link_info.pie && link_info.combreloc && config.data_bss_contig == TRUE)
+ return "ldscripts/${EMULATION_NAME}.xdcz";
else if (link_info.pie && link_info.combreloc)
return "ldscripts/${EMULATION_NAME}.xdc";
EOF
fi
cat >>e${EMULATION_NAME}.c <<EOF
+ else if (link_info.pie && config.data_bss_contig == TRUE)
+ return "ldscripts/${EMULATION_NAME}.xdz";
else if (link_info.pie)
return "ldscripts/${EMULATION_NAME}.xd";
EOF
diff --git a/gnu/usr.bin/binutils/ld/genscripts.sh b/gnu/usr.bin/binutils/ld/genscripts.sh
index ceb705c9b89..f03db18149e 100644
--- a/gnu/usr.bin/binutils/ld/genscripts.sh
+++ b/gnu/usr.bin/binutils/ld/genscripts.sh
@@ -319,8 +319,21 @@ if test -n "$GENERATE_PIE_SCRIPT"; then
. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdc
rm -f ${COMBRELOC}
+ LD_FLAG=Zcpie
+ ( echo "/* Script for -pie -z combreloc, -Z: position independent executable, combine & sort relocs, no PLT/GOT padding */"
+ . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME}
+ . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
+ ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdcz
+ rm -f ${COMBRELOC}
COMBRELOC=
fi
+ LD_FLAG=Zpie
+ DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}}
+ (
+ echo "/* Script for ld -pie -Z: link position independent executable, no PLT/GOT padding */"
+ . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME}
+ . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
+ ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdz
unset CREATE_PIE
fi
diff --git a/gnu/usr.bin/binutils/ld/scripttempl/elf.sc b/gnu/usr.bin/binutils/ld/scripttempl/elf.sc
index dc95d85569c..28a5a4fb2c7 100644
--- a/gnu/usr.bin/binutils/ld/scripttempl/elf.sc
+++ b/gnu/usr.bin/binutils/ld/scripttempl/elf.sc
@@ -117,7 +117,7 @@ if test -z "${NO_SMALL_DATA}"; then
.rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
fi
RODATA_ALIGN_ADD_VAL="${CREATE_SHLIB-${RODATA_ALIGN_ADD:-0}} ${CREATE_SHLIB+0}"
-test "$LD_FLAG" = "n" || test "$LD_FLAG" = "N" || test "$LD_FLAG" = "Z" || NO_PAD="y"
+test "$LD_FLAG" = "n" || test "$LD_FLAG" = "N" || test "${LD_FLAG%%(cpie|pie)}" = "Z" || NO_PAD="y"
if test "$NO_PAD" = "y" ; then
PAD_RO0="${RELOCATING+${RODATA_ALIGN} + ${RODATA_ALIGN_ADD_VAL};}"
PAD_PLT0="${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));} .pltpad0 ${RELOCATING-0} : { ${RELOCATING+__plt_start = .;} }"