From 08a741a1a58641f7d9df899491c0ba08398e7887 Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Thu, 25 May 2017 11:10:06 +0300 Subject: [PATCH 1/1] Introduce --enable-new-dtags configure option. ld/configure --enable-new-dtags sets ld.bfd --enable-new-dtags option by default. The ld option switches on generation of DT_RUNPATH tag instead of DT_RPATH tag which is deprecated and breaks LD_LIBRARY_PATH usage. Debian binutils bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835859 * ld/configure.ac: Add --enable-new-dtags option. * ld/ldmain.c: Set link_info.new_dtags to 1 if when --enable-new-dtags is switched on. * ld/configure: Regenerate. * ld/config.in: Regenerate. * packaging/binutils.spec: Switch on --enable-new-dtags. * packaging/binutils-armv7l.spec: Regenerate. * packaging/binutils-aarch64.spec: Regenerate. Change-Id: I0ec86f61a8b97d55c29bb441a9ae4db94060ea22 Signed-off-by: Slava Barinov --- ld/config.in | 4 ++++ ld/configure | 26 ++++++++++++++++++++++++-- ld/configure.ac | 18 ++++++++++++++++++ ld/ldmain.c | 3 +++ packaging/binutils-aarch64.spec | 3 ++- packaging/binutils-armv7l.spec | 3 ++- packaging/binutils.spec | 3 ++- 7 files changed, 55 insertions(+), 5 deletions(-) diff --git a/ld/config.in b/ld/config.in index 2c6d698..5d91380 100644 --- a/ld/config.in +++ b/ld/config.in @@ -13,6 +13,10 @@ /* Define to 1 if you want to enable -z relro in ELF linker by default. */ #undef DEFAULT_LD_Z_RELRO +/* Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default. + */ +#undef DEFAULT_NEW_DTAGS + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS diff --git a/ld/configure b/ld/configure index c6f871d..1cd12d3 100755 --- a/ld/configure +++ b/ld/configure @@ -791,6 +791,7 @@ with_sysroot enable_gold enable_got enable_compressed_debug_sections +enable_new_dtags enable_relro enable_werror enable_build_warnings @@ -1450,6 +1451,7 @@ Optional Features: multigot) --enable-compressed-debug-sections={all,ld,none} compress debug sections by default] + --enable-new-dtags set DT_RUNPATH instead of DT_RPATH by default] --enable-relro enable -z relro in ELF linker by default --enable-werror treat compile warnings as errors --enable-build-warnings enable build-time compiler warnings @@ -11723,7 +11725,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11726 "configure" +#line 11728 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11829,7 +11831,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11832 "configure" +#line 11834 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15543,6 +15545,17 @@ if test "${enable_compressed_debug_sections+set}" = set; then : esac fi +# Decide setting DT_RUNPATH instead of DT_RPATH by default +ac_default_new_dtags=unset +# Provide a configure time option to override our default. +# Check whether --enable-new_dtags was given. +if test "${enable_new_dtags+set}" = set; then : + enableval=$enable_new_dtags; case "${enableval}" in + yes) ac_default_new_dtags=1 ;; + no) ac_default_new_dtags=0 ;; +esac +fi + # Decide if -z relro should be enabled in ELF linker by default. ac_default_ld_z_relro=unset # Provide a configure time option to override our default. @@ -17160,6 +17173,15 @@ $as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h fi +if test "${ac_default_new_dtags}" = unset; then + ac_default_new_dtags=0 +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_NEW_DTAGS $ac_default_new_dtags +_ACEOF + + if test "${ac_default_ld_z_relro}" = unset; then ac_default_ld_z_relro=0 fi diff --git a/ld/configure.ac b/ld/configure.ac index d17281f..dbf70c2 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -155,6 +155,17 @@ AC_ARG_ENABLE(compressed_debug_sections, ,no, | ,none,) ac_default_compressed_debug_sections=no ;; esac])dnl +# Decide setting DT_RUNPATH instead of DT_RPATH by default +ac_default_new_dtags=unset +# Provide a configure time option to override our default. +AC_ARG_ENABLE(new_dtags, + AS_HELP_STRING([--enable-new-dtags], + [set DT_RUNPATH instead of DT_RPATH by default])], +[case "${enableval}" in + yes) ac_default_new_dtags=1 ;; + no) ac_default_new_dtags=0 ;; +esac])dnl + # Decide if -z relro should be enabled in ELF linker by default. ac_default_ld_z_relro=unset # Provide a configure time option to override our default. @@ -387,6 +398,13 @@ if test x$ac_default_compressed_debug_sections = xyes ; then AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) fi +if test "${ac_default_new_dtags}" = unset; then + ac_default_new_dtags=0 +fi +AC_DEFINE_UNQUOTED(DEFAULT_NEW_DTAGS, + $ac_default_new_dtags, + [Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default.]) + if test "${ac_default_ld_z_relro}" = unset; then ac_default_ld_z_relro=0 fi diff --git a/ld/ldmain.c b/ld/ldmain.c index e7a8dff..6a33431 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -285,6 +285,9 @@ main (int argc, char **argv) #ifdef DEFAULT_FLAG_COMPRESS_DEBUG link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB; #endif +#ifdef DEFAULT_NEW_DTAGS + link_info.new_dtags = TRUE; +#endif ldfile_add_arch (""); emulation = get_emulation (argc, argv); diff --git a/packaging/binutils-aarch64.spec b/packaging/binutils-aarch64.spec index 56dce89..ea628b8 100644 --- a/packaging/binutils-aarch64.spec +++ b/packaging/binutils-aarch64.spec @@ -100,7 +100,8 @@ cd build-dir } \ --enable-plugins \ --enable-gold \ - --enable-shared + --enable-shared \ + --enable-new-dtags make %{?_smp_mflags} diff --git a/packaging/binutils-armv7l.spec b/packaging/binutils-armv7l.spec index 4f94202..6ef2038 100644 --- a/packaging/binutils-armv7l.spec +++ b/packaging/binutils-armv7l.spec @@ -100,7 +100,8 @@ cd build-dir } \ --enable-plugins \ --enable-gold \ - --enable-shared + --enable-shared \ + --enable-new-dtags make %{?_smp_mflags} diff --git a/packaging/binutils.spec b/packaging/binutils.spec index cb05a89..b6826cc 100644 --- a/packaging/binutils.spec +++ b/packaging/binutils.spec @@ -97,7 +97,8 @@ cd build-dir } \ --enable-plugins \ --enable-gold \ - --enable-shared + --enable-shared \ + --enable-new-dtags make %{?_smp_mflags} -- 2.7.4