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
c90379ddfe/ELF/Relocations.cpp (L496-L537)
This commit is contained in:
Mike Hommey 2018-08-23 18:00:29 +09:00
parent 366b9d8e49
commit 95f25c8a5d
3 changed files with 17 additions and 0 deletions

View file

@ -17,5 +17,8 @@ if [ -e "$topsrcdir/gcc/bin/ld" ]; then
fi fi
ac_add_options --enable-lto 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" . "$topsrcdir/build/unix/mozconfig.stdcxx"

View file

@ -485,6 +485,13 @@ if test "$GNU_CC"; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
LDFLAGS=$_SAVE_LDFLAGS) 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]) AC_MSG_CHECKING([for --build-id option to ld])
_SAVE_LDFLAGS=$LDFLAGS _SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--build-id" LDFLAGS="$LDFLAGS -Wl,--build-id"

View file

@ -545,6 +545,13 @@ if test "$GNU_CC"; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
LDFLAGS=$_SAVE_LDFLAGS) 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]) AC_MSG_CHECKING([for --build-id option to ld])
_SAVE_LDFLAGS=$LDFLAGS _SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--build-id" LDFLAGS="$LDFLAGS -Wl,--build-id"