Bug 1485610 - Avoid copy relocations in binaries we build. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 23 Aug 2018 18:00:29 +0900
changeset 490990 7d4ae67397e207d28f6fa51cadef94a14d482d85
parent 490989 4fffa63b528ba3e7c57886e8670a816974941d13
child 490991 d1049dde16ddb13fbb7b05d362a028a9aa24839f
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1485610, 1485562
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
js/src/old-configure.in
old-configure.in
--- a/build/unix/mozconfig.lto
+++ b/build/unix/mozconfig.lto
@@ -12,10 +12,13 @@ export CXX="$topsrcdir/clang/bin/clang++
 
 # Use a newer binutils, from the tooltool gcc package, if it's there
 if [ -e "$topsrcdir/gcc/bin/ld" ]; then
     export CC="$CC -B $topsrcdir/gcc/bin"
     export CXX="$CXX -B $topsrcdir/gcc/bin"
 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"
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -480,16 +480,23 @@ if test "$GNU_CC"; then
 
     AC_MSG_CHECKING([for -z relro option to ld])
     _SAVE_LDFLAGS=$LDFLAGS
     LDFLAGS="$LDFLAGS -Wl,-z,relro"
     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
                   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"
     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
                   AC_MSG_RESULT([no])
                   LDFLAGS=$_SAVE_LDFLAGS)
 
     _DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
--- a/old-configure.in
+++ b/old-configure.in
@@ -540,16 +540,23 @@ if test "$GNU_CC"; then
 
     AC_MSG_CHECKING([for -z relro option to ld])
     _SAVE_LDFLAGS=$LDFLAGS
     LDFLAGS="$LDFLAGS -Wl,-z,relro"
     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
                   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"
     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
                   AC_MSG_RESULT([no])
                   LDFLAGS=$_SAVE_LDFLAGS)
 
     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])