From 95f25c8a5d22e79ab9e3ed6598e938b070c13c1e Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 23 Aug 2018 18:00:29 +0900 Subject: [PATCH] Bug 1485610 - Avoid copy relocations in binaries we build. r=froydnj See bug 1485562 for an example of bad things that can happen with such relocations, and see also https://github.com/llvm-mirror/lld/blob/c90379ddfe5eefdcb8edcaca5fa90a831505ae18/ELF/Relocations.cpp#L496-L537 --- build/unix/mozconfig.lto | 3 +++ js/src/old-configure.in | 7 +++++++ old-configure.in | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/build/unix/mozconfig.lto b/build/unix/mozconfig.lto index d825ac6158a7..c62104f8c857 100644 --- a/build/unix/mozconfig.lto +++ b/build/unix/mozconfig.lto @@ -17,5 +17,8 @@ if [ -e "$topsrcdir/gcc/bin/ld" ]; then fi ac_add_options --enable-lto +# Until it's either made the default or we figure a way to remove the +# copy locations that LTO induces in non-PIE executables. +ac_add_options --enable-pie . "$topsrcdir/build/unix/mozconfig.stdcxx" diff --git a/js/src/old-configure.in b/js/src/old-configure.in index ba016082eec6..70dd46dc7319 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -485,6 +485,13 @@ if test "$GNU_CC"; then AC_MSG_RESULT([no]) LDFLAGS=$_SAVE_LDFLAGS) + AC_MSG_CHECKING([for -z nocopyreloc option to ld]) + _SAVE_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc" + AC_TRY_LINK(,,AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + LDFLAGS=$_SAVE_LDFLAGS) + AC_MSG_CHECKING([for --build-id option to ld]) _SAVE_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -Wl,--build-id" diff --git a/old-configure.in b/old-configure.in index 30ed601d8423..880def074ddc 100644 --- a/old-configure.in +++ b/old-configure.in @@ -545,6 +545,13 @@ if test "$GNU_CC"; then AC_MSG_RESULT([no]) LDFLAGS=$_SAVE_LDFLAGS) + AC_MSG_CHECKING([for -z nocopyreloc option to ld]) + _SAVE_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc" + AC_TRY_LINK(,,AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + LDFLAGS=$_SAVE_LDFLAGS) + AC_MSG_CHECKING([for --build-id option to ld]) _SAVE_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -Wl,--build-id"