On Sat, 11 Oct 2014, Alex Smith wrote:
Binutils will always strip the relocation information from executable
files even if it needs it (dynamicbase/ASLR). We can work around this
by using the pic-executable flag combined with setting the correct entry
point since apparently ld forgets what that should be. This problem
affects both 32 and 64-bit mingw-w64.
We can combine the nxcompat/dynamicbase check because they were added to
binutils at the same time.
Signed-off-by: Alex Smith
---
configure | 13 +++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index a82bef7..356778b 100755
--- a/configure
+++ b/configure
@@ -3475,8 +3475,6 @@ case $target_os in
elif enabled arm; then
LIBTARGET=arm-wince
fi
-check_ldflags -Wl,--nxcompat
-check_ldflags -Wl,--dynamicbase
shlibdir_default="$bindir_default"
SLIBPREF=""
SLIBSUF=".dll"
@@ -3492,6 +3490,17 @@ case $target_os in
dlltool="${cross_prefix}dlltool"
ranlib=:
enable dos_paths
+check_ldflags -Wl,--nxcompat,--dynamicbase
Is there any particular reason for moving these checks here compared to
keeping them where they were before, other than that they're related?
+# Lets work around some stupidity in binutils.
+# ld will strip relocations from executables even though we need them
+# for dynamicbase (ASLR). Using -pie does retain the reloc section
+# however ld then forgets what the entry point should be (oops) so we
+# have to manually (re)set it.
+if enabled x86_32; then
+add_ldexeflags -Wl,--pic-executable,-e,_mainCRTStartup
+elif enabled x86_64; then
+add_ldexeflags -Wl,--pic-executable,-e,mainCRTStartup
+fi
;;
These are added without actually checking whether binutils support them,
no? Are we sure that's ok?
I did try this patch on some old mingw versions, and on mingw32ce, and it
didn't seem to break anything there though, and in general I guess it
seems ok.
// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel