[libav-devel] [PATCH] configure: Force mingw's ld to keep the reloc section

2014-10-11 Thread Alex Smith
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.
---
 configure | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index a82bef7..60b31ec 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,18 @@ case $target_os in
 dlltool=${cross_prefix}dlltool
 ranlib=:
 enable dos_paths
+check_ldflags -Wl,--nxcompat,--dynamicbase
+# 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.
+add_ldexeflags -Wl,--pic-executable
+if enabled x86_32; then
+add_ldexeflags -Wl,-e,_mainCRTStartup
+elif enabled x86_64; then
+add_ldexeflags -Wl,-e,mainCRTStartup
+fi
 ;;
 win32|win64)
 disable symver
-- 
1.9.4.msysgit.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: Force mingw's ld to keep the reloc section

2014-10-11 Thread Luca Barbato

On 11/10/14 11:05, 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.
---
  configure | 14 --
  1 file changed, 12 insertions(+), 2 deletions(-)



Looks fine or at least it is doing what expected, mingw-w64 is aware of 
the problem?


lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] configure: Force mingw's ld to keep the reloc section

2014-10-11 Thread Alex Smith
On Sat, Oct 11, 2014 at 5:47 AM, Luca Barbato lu_z...@gentoo.org wrote:

 Looks fine or at least it is doing what expected, mingw-w64 is aware of
 the problem?

 lu


See
http://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/cagfxeqkg0j%2bax0dj-cbxggrwwt15k-arswwabn6wwsdutrh...@mail.gmail.com/

I'm not holding my breath for a fix.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel