Bug 664366 - Automatically disable elfhack when the linker creates PT_GNU_RELRO segments. r=khuey

This commit is contained in:
Mike Hommey 2011-06-17 03:41:45 +02:00
parent 9c0ad6e9b2
commit a5bc1d7d2e

View File

@ -7624,6 +7624,36 @@ if test "$USE_ELF_HACK" = 1; then
esac
fi
if test "$USE_ELF_HACK" = 1; then
dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
dnl memory addresses it maps to. The result is that by the time elfhack
dnl kicks in, it is not possible to apply relocations because of that,
dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
dnl segment. It makes elfhack mostly useless, so considering the problems
dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
dnl the linker creates PT_GNU_RELRO segments.
AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
LINK_WITH_PT_GNU_RELRO,
[echo "int main() {return 0;}" > conftest.${ac_ext}
if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
test -s conftest${ac_exeext}; then
if readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
LINK_WITH_PT_GNU_RELRO=yes
else
LINK_WITH_PT_GNU_RELRO=no
fi
else
dnl We really don't expect to get here, but just in case
AC_ERROR([couldn't compile a simple C file])
fi
rm -rf conftest*])
if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
AC_MSG_WARN([Disabling elfhack])
USE_ELF_HACK=
fi
fi
dnl ========================================================
dnl = libstdc++ compatibility hacks
dnl ========================================================