[x264-devel] mingw: Enable high-entropy ASLR on 64-bit Windows

Henrik Gramner git at videolan.org
Tue Apr 12 20:36:14 CEST 2016


x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Thu Jan 28 18:37:37 2016 +0100| [c01bf42117b811a0469f9f6c374f4a0daa98716d] | committer: Henrik Gramner

mingw: Enable high-entropy ASLR on 64-bit Windows

To fully utilize HEASLR the image base address must also be set above
4 GiB. For consistency use the same address as MSVC uses by default.

This requires binutils 2.25 which isn't available on all common
distributions, so only enable it after checking that it's supported.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=c01bf42117b811a0469f9f6c374f4a0daa98716d
---

 configure |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 09643db..0d40a92 100755
--- a/configure
+++ b/configure
@@ -693,10 +693,15 @@ case $host_cpu in
             fi
         elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
             ASFLAGS="$ASFLAGS -f win64"
-            # only the GNU toolchain is inconsistent in prefixing function names with _
-            [ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
-            [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
-            [ $compiler = GNU ] && RCFLAGS="--target=pe-x86-64 $RCFLAGS"
+            if [ $compiler = GNU ]; then
+                # only the GNU toolchain is inconsistent in prefixing function names with _
+                cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
+                cc_check "" "-Wl,--high-entropy-va" && LDFLAGS="$LDFLAGS -Wl,--high-entropy-va"
+                LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
+                LDFLAGSCLI="$LDFLAGSCLI -Wl,--image-base,0x140000000"
+                SOFLAGS="$SOFLAGS -Wl,--image-base,0x180000000"
+                RCFLAGS="--target=pe-x86-64 $RCFLAGS"
+            fi
         else
             ASFLAGS="$ASFLAGS -f elf64"
         fi
@@ -1389,7 +1394,7 @@ if [ "$shared" = "yes" ]; then
             grep "extern.*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264\w*\)\W.*/\1 DATA/;" >> x264.def
         else
             echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
-            echo "SOFLAGS=-shared -Wl,--out-implib,\$(IMPLIBNAME) -Wl,--enable-auto-image-base $SOFLAGS" >> config.mak
+            echo "SOFLAGS=-shared -Wl,--out-implib,\$(IMPLIBNAME) $SOFLAGS" >> config.mak
         fi
     elif [ "$SYS" = "MACOSX" ]; then
         echo "SOSUFFIX=dylib" >> config.mak



More information about the x264-devel mailing list