From c050bd03569e2ffce68f275038b0c0afca577a97 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 12 Jul 2013 09:15:10 +0900 Subject: [PATCH] Bug 892355 - Force enable elfhack with --enable-elf-hack. r=ted --- browser/config/mozconfigs/linux32/nightly | 1 + browser/config/mozconfigs/linux64/nightly | 1 + build/unix/mozconfig.linux | 2 ++ configure.in | 26 ++++++++++++++----- .../android/config/mozconfigs/android/nightly | 1 + mobile/android/config/mozconfigs/common | 2 ++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/browser/config/mozconfigs/linux32/nightly b/browser/config/mozconfigs/linux32/nightly index 8daaec36e3d..f0b34f1e3e3 100644 --- a/browser/config/mozconfigs/linux32/nightly +++ b/browser/config/mozconfigs/linux32/nightly @@ -3,6 +3,7 @@ ac_add_options --enable-codesighs ac_add_options --enable-signmar ac_add_options --enable-profiling +ac_add_options --disable-elf-hack # --enable-elf-hack conflicts with --enable-profiling # Nightlies only since this has a cost in performance ac_add_options --enable-js-diagnostics diff --git a/browser/config/mozconfigs/linux64/nightly b/browser/config/mozconfigs/linux64/nightly index 223624b630f..024c986662e 100644 --- a/browser/config/mozconfigs/linux64/nightly +++ b/browser/config/mozconfigs/linux64/nightly @@ -3,6 +3,7 @@ ac_add_options --enable-codesighs ac_add_options --enable-signmar ac_add_options --enable-profiling +ac_add_options --disable-elf-hack # --enable-elf-hack conflicts with --enable-profiling # Nightlies only since this has a cost in performance ac_add_options --enable-js-diagnostics diff --git a/build/unix/mozconfig.linux b/build/unix/mozconfig.linux index 6324ba71853..60fc174c91f 100644 --- a/build/unix/mozconfig.linux +++ b/build/unix/mozconfig.linux @@ -2,3 +2,5 @@ CC="/tools/gcc-4.7.2-0moz1/bin/gcc" CXX="/tools/gcc-4.7.2-0moz1/bin/g++" + +ac_add_options --enable-elf-hack diff --git a/configure.in b/configure.in index 24854d53138..842f7bbd0c8 100644 --- a/configure.in +++ b/configure.in @@ -7566,13 +7566,16 @@ dnl ======================================================== USE_ELF_HACK=1 MOZ_ARG_DISABLE_BOOL(elf-hack, [ --disable-elf-hack Disable elf hacks], - USE_ELF_HACK=, - USE_ELF_HACK=1) + [USE_ELF_HACK=], + [USE_ELF_HACK=F # Force enable elf-hack]) # Disable elf hack for profiling because the built in profiler # doesn't read the segments properly with elf hack. This is # temporary and should be fixed soon in the profiler. if test "$MOZ_PROFILING" = 1; then + if test "$USE_ELF_HACK" = F; then + AC_ERROR([--enable-elf-hack is not compatible with --enable-profiling]) + fi USE_ELF_HACK= fi @@ -7595,7 +7598,7 @@ if test "$USE_ELF_HACK" = 1; then esac fi -if test "$USE_ELF_HACK" = 1; then +if test -n "$USE_ELF_HACK"; 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, @@ -7603,7 +7606,8 @@ if test "$USE_ELF_HACK" = 1; then 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. + dnl the linker creates PT_GNU_RELRO segments. However, when we do want + dnl elfhack enabled, disable PT_GNU_RELRO instead. AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments], LINK_WITH_PT_GNU_RELRO, [echo "int main() {return 0;}" > conftest.${ac_ext} @@ -7620,8 +7624,18 @@ if test "$USE_ELF_HACK" = 1; then fi rm -rf conftest*]) if test "$LINK_WITH_PT_GNU_RELRO" = yes; then - AC_MSG_WARN([Disabling elfhack]) - USE_ELF_HACK= + if test "$USE_ELF_HACK" = F; then + AC_MSG_CHECKING([for -z norelro option to ld]) + _SAVE_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-z,norelro" + AC_TRY_LINK(,,AC_MSG_RESULT([yes]) + [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"], + AC_ERROR([--enable-elf-hack is not compatible with a linker creating a PT_GNU_RELRO segment and that doesn't support the "-z norelro" option.])) + USE_ELF_HACK=1 + else + AC_MSG_WARN([Disabling elfhack]) + USE_ELF_HACK= + fi fi fi diff --git a/mobile/android/config/mozconfigs/android/nightly b/mobile/android/config/mozconfigs/android/nightly index ef284434137..3d01b3b8406 100644 --- a/mobile/android/config/mozconfigs/android/nightly +++ b/mobile/android/config/mozconfigs/android/nightly @@ -19,6 +19,7 @@ ac_add_options --with-android-version=9 ac_add_options --with-system-zlib ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL} ac_add_options --enable-profiling +ac_add_options --disable-elf-hack # --enable-elf-hack conflicts with --enable-profiling export JAVA_HOME=/tools/jdk6 export MOZILLA_OFFICIAL=1 diff --git a/mobile/android/config/mozconfigs/common b/mobile/android/config/mozconfigs/common index 821ad13afec..2aa12deb037 100644 --- a/mobile/android/config/mozconfigs/common +++ b/mobile/android/config/mozconfigs/common @@ -10,3 +10,5 @@ # much slower and we didn't want to slow down developers builds. # Has no effect when MOZ_ENABLE_SZIP is not set in mobile/android/confvars.sh. MOZ_SZIP_FLAGS="-D auto -f auto" + +ac_add_options --enable-elf-hack