summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/ld
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2004-05-30 22:05:41 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2004-05-30 22:05:41 +0000
commit513fcf4400d7426048333ce05ca24deb5bf5d091 (patch)
treea11598c14f9cd37f76183d921d8b45fe29c61135 /gnu/usr.bin/binutils/ld
parent9bebcfe960ad199afc860fbbefb3177ae0d005cd (diff)
emacs undump is very sensative to the section ordering, For W^X a couple
of sections were moved for protections purposes. This causes problems with emacs undump. Only move the sections if the W^X padding is active. Generate the scripts properly for newer binutils, on i386 if -Z is active, move the executable start address back to the classic base address.
Diffstat (limited to 'gnu/usr.bin/binutils/ld')
-rw-r--r--gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh5
-rw-r--r--gnu/usr.bin/binutils/ld/genscripts.sh7
-rw-r--r--gnu/usr.bin/binutils/ld/scripttempl/elf.sc13
3 files changed, 18 insertions, 7 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 f3449fe290a..e3e102ab1fb 100644
--- a/gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh
+++ b/gnu/usr.bin/binutils/ld/emulparams/elf_i386_obsd.sh
@@ -1,7 +1,12 @@
. ${srcdir}/emulparams/elf_i386.sh
. ${srcdir}/emulparams/elf_obsd.sh
+if test "$LD_FLAG" = "Z"
+then
+TEXT_START_ADDR=0x08048000
+else
TEXT_START_ADDR=0x1C000000
+fi
RODATA_PADSIZE=0x20000000
RODATA_ALIGN=". = ALIGN(${RODATA_PADSIZE})"
diff --git a/gnu/usr.bin/binutils/ld/genscripts.sh b/gnu/usr.bin/binutils/ld/genscripts.sh
index d80357a4924..b3fe1ce6b01 100644
--- a/gnu/usr.bin/binutils/ld/genscripts.sh
+++ b/gnu/usr.bin/binutils/ld/genscripts.sh
@@ -220,13 +220,16 @@ if test -n "$GENERATE_SHLIB_SCRIPT"; then
rm -f ${COMBRELOC}
COMBRELOC=
fi
+ unset CREATE_SHLIB
fi
LD_FLAG=Z
DATA_ALIGNMENT=${DATA_ALIGNMENT_}
RELOCATING=" "
-(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
- ldscripts/${EMULATION_NAME}.xz
+( echo "/* Script for -Z: traditional binaries with no PLT/GOT padding */"
+ . ${srcdir}/emulparams/${EMULATION_NAME}.sh
+ . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
+) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xz
case " $EMULATION_LIBPATH " in
*" ${EMULATION_NAME} "*) COMPILE_IN=true;;
diff --git a/gnu/usr.bin/binutils/ld/scripttempl/elf.sc b/gnu/usr.bin/binutils/ld/scripttempl/elf.sc
index fb4b168e350..a83739d1cc0 100644
--- a/gnu/usr.bin/binutils/ld/scripttempl/elf.sc
+++ b/gnu/usr.bin/binutils/ld/scripttempl/elf.sc
@@ -121,6 +121,7 @@ test "$NO_PAD" = "y" && PAD_PLT0="${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. &
test "$NO_PAD" = "y" && PAD_PLT1=".pltpad1 ${RELOCATING-0} : { ${RELOCATING+__plt_end = .;}} ${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));}"
test "$NO_PAD" = "y" && PAD_GOT0="${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));} .gotpad0 ${RELOCATING-0} : { ${RELOCATING+__got_start = .;} }"
test "$NO_PAD" = "y" && PAD_GOT1=".gotpad1 ${RELOCATING-0} : { ${RELOCATING+__got_end = .;}} ${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1));}"
+test "$NO_PAD" = "y" && PAD_CDTOR=
CTOR=".ctors ${CONSTRUCTING-0} :
{
@@ -326,6 +327,8 @@ cat <<EOF
${WRITABLE_RODATA+${RODATA}}
${OTHER_READWRITE_SECTIONS}
${TEXT_DYNAMIC-${DYNAMIC}}
+ ${PAD_CDTOR-${RELOCATING+${CTOR}}}
+ ${PAD_CDTOR-${RELOCATING+${DTOR}}}
.jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
/* pad CTOR/DTOR, GOT (and PLT if DATA_PLT) to page aligned if PAD_GOT */
@@ -336,12 +339,12 @@ cat <<EOF
${DATA_NONEXEC_PLT+${PLT}}
${RELOCATING+${OTHER_GOT_SYMBOLS}}
.got ${RELOCATING-0} : { *(.got.plt) *(.got) }
- /* CTOR and DTOR relocated here to receive mprotect protection after,
- relocation are finished same as GOT */
- ${RELOCATING+${CTOR}}
- ${RELOCATING+${DTOR}}
- ${PAD_GOT+${PAD_GOT1}}
+ /* If PAD_CDTOR, CTOR and DTOR relocated here to receive mprotect
+ protection after relocation are finished same as GOT */
+ ${PAD_CDTOR+${RELOCATING+${CTOR}}}
+ ${PAD_CDTOR+${RELOCATING+${DTOR}}}
${OTHER_GOT_SECTIONS}
+ ${PAD_GOT+${PAD_GOT1}}
${CREATE_SHLIB+${SDATA2}}
${CREATE_SHLIB+${SBSS2}}
${SDATA}