Skip to content

Commit

Permalink
configure: Force mingw's ld to keep the reloc section
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
TheRyuu authored and michaelni committed Sep 22, 2015
1 parent 0544c95 commit 91b668a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4392,6 +4392,16 @@ case $target_os in
objformat="win32"
ranlib=:
enable dos_paths
# 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
;;
win32|win64)
disable symver
Expand Down

0 comments on commit 91b668a

Please sign in to comment.