From c32b45b7537a82b63613ea95e00f8468d31a25d9 Mon Sep 17 00:00:00 2001 From: "Andreas K. Hüttel" Date: Tue, 20 Jul 2021 21:52:55 +0200 Subject: Renumber patches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas K. Hüttel --- ...-ld-add-support-for-poisoned-system-direc.patch | 336 +++++++++++++++++++++ ...iberty-install-PIC-version-of-libiberty.a.patch | 34 +++ ...-ld-add-support-for-poisoned-system-direc.patch | 336 --------------------- ...des-link-against-libbfd.la-for-rpath-deps.patch | 49 +++ ...oo-add-with-extra-soversion-suffix-option.patch | 146 +++++++++ ...iberty-install-PIC-version-of-libiberty.a.patch | 34 --- ...nable-new-dtags-by-default-for-linux-gnu-.patch | 49 +++ ...des-link-against-libbfd.la-for-rpath-deps.patch | 49 --- 9999/0006-Gentoo-Pass-hash-style-sysv.patch | 61 ++++ ...oo-add-with-extra-soversion-suffix-option.patch | 146 --------- ...nable-new-dtags-by-default-for-linux-gnu-.patch | 49 --- 9999/0009-Gentoo-Pass-hash-style-sysv.patch | 61 ---- 12 files changed, 675 insertions(+), 675 deletions(-) create mode 100644 9999/0001-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch create mode 100644 9999/0002-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch delete mode 100644 9999/0003-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch create mode 100644 9999/0003-Gentoo-opcodes-link-against-libbfd.la-for-rpath-deps.patch create mode 100644 9999/0004-Gentoo-add-with-extra-soversion-suffix-option.patch delete mode 100644 9999/0004-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch create mode 100644 9999/0005-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch delete mode 100644 9999/0005-Gentoo-opcodes-link-against-libbfd.la-for-rpath-deps.patch create mode 100644 9999/0006-Gentoo-Pass-hash-style-sysv.patch delete mode 100644 9999/0006-Gentoo-add-with-extra-soversion-suffix-option.patch delete mode 100644 9999/0007-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch delete mode 100644 9999/0009-Gentoo-Pass-hash-style-sysv.patch diff --git a/9999/0001-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch b/9999/0001-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch new file mode 100644 index 0000000..f7443bf --- /dev/null +++ b/9999/0001-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch @@ -0,0 +1,336 @@ +From 8a82f64de912f26e840b20eec9d8a463fd0e242b Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Tue, 20 Jul 2021 21:08:31 +0200 +Subject: [PATCH 1/6] Gentoo: gold/ld: add support for poisoned system + directories +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is based on the old CodeSourcery patch written by Joseph Myers to add +support to the link for detecting & rejecting bad -L paths when using a +cross-compiler. The differences here: +* The command line flags are always available. +* We can turn on & off the warning via the command line. +* The configure option controls the default warning behavior. +* Add support for gold. + +It is not currently upstream, nor has it been submitted at all. There are +no plans to do so currently either. + +BUG=chromium:488360 +TEST=`cbuildbot chromiumos-sdk` passes # tests arm/amd64/mipsel/x86 +TEST=`cbuildbot panther_moblab-full whirlwind-release` pass +TEST=`cbuildbot {x32,arm64}-generic-full` has no new failures +TEST=x86_64-cros-linux-gnu-ld throws warnings when using -L/lib (gold & bfd) + +Reviewed-on: https://chromium-review.googlesource.com/272083 +(cherry picked from commit f92dbf35c00ab13cee36f6be8ae5ca46454d9000) + +Ported to binutils 2.37 Andreas K. Hütte +--- + gold/options.cc | 33 +++++++++++++++++++++++++++++++++ + gold/options.h | 7 +++++++ + ld/config.in | 3 +++ + ld/configure | 14 ++++++++++++++ + ld/configure.ac | 10 ++++++++++ + ld/ld.h | 7 +++++++ + ld/ld.texi | 18 ++++++++++++++++++ + ld/ldfile.c | 20 ++++++++++++++++++++ + ld/ldlex.h | 3 +++ + ld/ldmain.c | 7 +++++++ + ld/lexsup.c | 24 ++++++++++++++++++++++++ + 11 files changed, 146 insertions(+) + +diff --git a/gold/options.cc b/gold/options.cc +index 5a55bd8ba6d..f7940c75f5a 100644 +--- a/gold/options.cc ++++ b/gold/options.cc +@@ -1355,6 +1355,39 @@ General_options::finalize() + // in the path, as appropriate. + this->add_sysroot(); + ++ // Now check if library_path is poisoned. ++ if (this->warn_poison_system_directories()) ++ { ++ std::vector bad_paths; ++ ++ bad_paths.push_back("/lib"); ++ // TODO: This check is disabled for now due to a bunch of packages that ++ // use libtool and relink with -L/usr/lib paths (albeit after the right ++ // sysroot path). Once those are fixed we can enable. ++ // We also need to adjust it so it only rejects one or two levels deep. ++ // Gcc's internal paths also live below /usr/lib. ++ // http://crbug.com/488360 ++ // bad_paths.push_back("/usr/lib"); ++ bad_paths.push_back("/usr/local/lib"); ++ bad_paths.push_back("/usr/X11R6/lib"); ++ ++ for (std::vector::const_iterator b = bad_paths.begin(); ++ b != bad_paths.end(); ++ ++b) ++ for (Dir_list::iterator p = this->library_path_.value.begin(); ++ p != this->library_path_.value.end(); ++ ++p) ++ if (!p->name().compare(0, b->size(), *b)) ++ { ++ if (this->error_poison_system_directories()) ++ gold_fatal(_("library search path \"%s\" is unsafe for " ++ "cross-compilation"), p->name().c_str()); ++ else ++ gold_warning(_("library search path \"%s\" is unsafe for " ++ "cross-compilation"), p->name().c_str()); ++ } ++ } ++ + // Now that we've normalized the options, check for contradictory ones. + if (this->shared() && this->is_static()) + gold_fatal(_("-shared and -static are incompatible")); +diff --git a/gold/options.h b/gold/options.h +index 757ebf18fec..490b4cbd7d4 100644 +--- a/gold/options.h ++++ b/gold/options.h +@@ -1394,6 +1394,13 @@ class General_options + DEFINE_bool(warn_multiple_gp, options::TWO_DASHES, '\0', false, + N_("Ignored"), NULL); + ++ DEFINE_bool(warn_poison_system_directories, options::TWO_DASHES, '\0', false, ++ N_("Warn for -L options using system directories"), ++ N_("Do not warn for -L options using system directories")); ++ DEFINE_bool(error_poison_system_directories, options::TWO_DASHES, '\0', false, ++ N_("Give an error for -L options using system directories"), ++ NULL); ++ + DEFINE_bool(warn_search_mismatch, options::TWO_DASHES, '\0', true, + N_("Warn when skipping an incompatible library"), + N_("Don't warn when skipping an incompatible library")); +diff --git a/ld/config.in b/ld/config.in +index 26d55a00d47..ffad464783c 100644 +--- a/ld/config.in ++++ b/ld/config.in +@@ -43,6 +43,9 @@ + language is requested. */ + #undef ENABLE_NLS + ++/* Define to warn for use of native system library directories */ ++#undef ENABLE_POISON_SYSTEM_DIRECTORIES ++ + /* Additional extension a shared object might have. */ + #undef EXTRA_SHLIB_EXTENSION + +diff --git a/ld/configure b/ld/configure +index c197aaef3cb..882263aa43f 100755 +--- a/ld/configure ++++ b/ld/configure +@@ -829,6 +829,7 @@ with_lib_path + enable_targets + enable_64_bit_bfd + with_sysroot ++enable_poison_system_directories + enable_gold + enable_got + enable_compressed_debug_sections +@@ -1498,6 +1499,8 @@ Optional Features: + --enable-checking enable run-time checks + --enable-targets alternative target configurations + --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes) ++ --enable-poison-system-directories ++ warn for use of native system library directories + --enable-gold[=ARG] build gold [ARG={default,yes,no}] + --enable-got= GOT handling scheme (target, single, negative, + multigot) +@@ -15236,7 +15239,18 @@ else + fi + + ++# Check whether --enable-poison-system-directories was given. ++if test "${enable_poison_system_directories+set}" = set; then : ++ enableval=$enable_poison_system_directories; ++else ++ enable_poison_system_directories=no ++fi ++ ++if test "x${enable_poison_system_directories}" = "xyes"; then + ++$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h ++ ++fi + + # Check whether --enable-got was given. + if test "${enable_got+set}" = set; then : +diff --git a/ld/configure.ac b/ld/configure.ac +index 8ea97c43cd4..0f246db67d8 100644 +--- a/ld/configure.ac ++++ b/ld/configure.ac +@@ -106,6 +106,16 @@ AC_SUBST(use_sysroot) + AC_SUBST(TARGET_SYSTEM_ROOT) + AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) + ++AC_ARG_ENABLE([poison-system-directories], ++ AS_HELP_STRING([--enable-poison-system-directories], ++ [warn for use of native system library directories]),, ++ [enable_poison_system_directories=no]) ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], ++ [1], ++ [Define to warn for use of native system library directories]) ++fi ++ + dnl Use --enable-gold to decide if this linker should be the default. + dnl "install_as_default" is set to false if gold is the default linker. + dnl "installed_linker" is the installed BFD linker name. +diff --git a/ld/ld.h b/ld/ld.h +index 35fafebfaed..4152278b8f4 100644 +--- a/ld/ld.h ++++ b/ld/ld.h +@@ -162,6 +162,13 @@ typedef struct + in the linker script. */ + bool force_group_allocation; + ++ /* If true warn for uses of system directories when cross linking. */ ++ bool warn_poison_system_directories; ++ ++ /* If true (default false) give an error for uses of system ++ directories when cross linking instead of a warning. */ ++ bool error_poison_system_directories; ++ + /* Big or little endian as set on command line. */ + enum endian_enum endian; + +diff --git a/ld/ld.texi b/ld/ld.texi +index dd8f571d4e4..0aee4a4e9f1 100644 +--- a/ld/ld.texi ++++ b/ld/ld.texi +@@ -2863,6 +2863,24 @@ string identifying the original linked file does not change. + + Passing @code{none} for @var{style} disables the setting from any + @code{--build-id} options earlier on the command line. ++ ++@kindex --warn-poison-system-directories ++@item --warn-poison-system-directories ++Warn for @option{-L} options using system directories such as ++@file{/usr/lib} when cross linking. This option is intended for use ++in environments that want to detect and reject incorrect link settings. ++ ++@kindex --no-warn-poison-system-directories ++@item --no-warn-poison-system-directories ++Do not warn for @option{-L} options using system directories such as ++@file{/usr/lib} when cross linking. This option is intended for use ++in chroot environments when such directories contain the correct ++libraries for the target system rather than the host. ++ ++@kindex --error-poison-system-directories ++@item --error-poison-system-directories ++Give an error instead of a warning for @option{-L} options using ++system directories when cross linking. + @end table + + @c man end +diff --git a/ld/ldfile.c b/ld/ldfile.c +index 9d0af06f1f6..f4a83acca93 100644 +--- a/ld/ldfile.c ++++ b/ld/ldfile.c +@@ -117,6 +117,26 @@ ldfile_add_library_path (const char *name, bool cmdline) + new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL); + else + new_dirs->name = xstrdup (name); ++ ++ if (command_line.warn_poison_system_directories ++ && (!strncmp (name, "/lib", 4) ++ /* TODO: This check is disabled for now due to a bunch of packages that ++ * use libtool and relink with -L/usr/lib paths (albeit after the right ++ * sysroot path). Once those are fixed we can enable. ++ * We also need to adjust it so it only rejects one or two levels deep. ++ * Gcc's internal paths also live below /usr/lib. ++ * http://crbug.com/488360 */ ++ /* || !strncmp (name, "/usr/lib", 8) */ ++ || !strncmp (name, "/usr/local/lib", 14) ++ || !strncmp (name, "/usr/X11R6/lib", 14))) ++ { ++ if (command_line.error_poison_system_directories) ++ einfo (_("%X%P: error: library search path \"%s\" is unsafe for " ++ "cross-compilation\n"), name); ++ else ++ einfo (_("%P: warning: library search path \"%s\" is unsafe for " ++ "cross-compilation\n"), name); ++ } + } + + /* Try to open a BFD for a lang_input_statement. */ +diff --git a/ld/ldlex.h b/ld/ldlex.h +index 9e8bf5fb835..3baed822a22 100644 +--- a/ld/ldlex.h ++++ b/ld/ldlex.h +@@ -148,6 +148,9 @@ enum option_values + OPTION_PRINT_OUTPUT_FORMAT, + OPTION_PRINT_SYSROOT, + OPTION_IGNORE_UNRESOLVED_SYMBOL, ++ OPTION_WARN_POISON_SYSTEM_DIRECTORIES, ++ OPTION_NO_WARN_POISON_SYSTEM_DIRECTORIES, ++ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES, + OPTION_PUSH_STATE, + OPTION_POP_STATE, + OPTION_DISABLE_MULTIPLE_DEFS_ABS, +diff --git a/ld/ldmain.c b/ld/ldmain.c +index 42660eb9a3c..c78009b760c 100644 +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -321,6 +321,13 @@ main (int argc, char **argv) + command_line.warn_mismatch = true; + command_line.warn_search_mismatch = true; + command_line.check_section_addresses = -1; ++ command_line.warn_poison_system_directories = ++#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES ++ true; ++#else ++ false; ++#endif ++ command_line.error_poison_system_directories = false; + + /* We initialize DEMANGLING based on the environment variable + COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the +diff --git a/ld/lexsup.c b/ld/lexsup.c +index 00274c500d0..a19cce9967c 100644 +--- a/ld/lexsup.c ++++ b/ld/lexsup.c +@@ -566,6 +566,18 @@ static const struct ld_option ld_options[] = + OPTION_IGNORE_UNRESOLVED_SYMBOL}, + '\0', N_("SYMBOL"), + N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES }, ++ { {"warn-poison-system-directories", no_argument, NULL, ++ OPTION_WARN_POISON_SYSTEM_DIRECTORIES}, ++ '\0', NULL, N_("Warn for -L options using system directories"), ++ TWO_DASHES }, ++ { {"no-warn-poison-system-directories", no_argument, NULL, ++ OPTION_NO_WARN_POISON_SYSTEM_DIRECTORIES}, ++ '\0', NULL, N_("Do not warn for -L options using system directories"), ++ TWO_DASHES }, ++ { {"error-poison-system-directories", no_argument, NULL, ++ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES}, ++ '\0', NULL, N_("Give an error for -L options using system directories"), ++ TWO_DASHES }, + { {"push-state", no_argument, NULL, OPTION_PUSH_STATE}, + '\0', NULL, N_("Push state of flags governing input file handling"), + TWO_DASHES }, +@@ -1643,6 +1655,18 @@ parse_args (unsigned argc, char **argv) + } + break; + ++ case OPTION_WARN_POISON_SYSTEM_DIRECTORIES: ++ command_line.warn_poison_system_directories = true; ++ break; ++ ++ case OPTION_NO_WARN_POISON_SYSTEM_DIRECTORIES: ++ command_line.warn_poison_system_directories = false; ++ break; ++ ++ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES: ++ command_line.error_poison_system_directories = true; ++ break; ++ + case OPTION_PUSH_STATE: + input_flags.pushed = xmemdup (&input_flags, + sizeof (input_flags), +-- +2.31.1 + diff --git a/9999/0002-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch b/9999/0002-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch new file mode 100644 index 0000000..4d5ed11 --- /dev/null +++ b/9999/0002-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch @@ -0,0 +1,34 @@ +From 6536761c1e2756ec39fdc33c400757be3744510c Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Fri, 7 Jan 2005 00:15:53 -0500 +Subject: [PATCH 2/6] Gentoo: libiberty: install PIC version of libiberty.a + +This will install a PIC version of libiberty.a by overwriting the non-PIC +version of libiberty.a while compiling. We do this because there is no +shared version of libiberty for random apps to link against which means if +someone wants to use this in a shared library or PIE, they're out of luck. +It's arguable whether people should be able to use this in a shared lib, +but usage in PIE should be fine. You could argue that this penalizes the +non-PIE users, but the counter point is that people using this library in +general are fairly low, and we'd rather have things work for all of them. + +(cherry picked from commit 112aff9ad3e2675556370c4281117a6df0a879d9) +--- + libiberty/Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in +index d19e14a2aca..cd02be1c2fb 100644 +--- a/libiberty/Makefile.in ++++ b/libiberty/Makefile.in +@@ -257,6 +257,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) + $(AR) $(AR_FLAGS) $(TARGETLIB) \ + $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \ + $(RANLIB) $(TARGETLIB); \ ++ cp $(TARGETLIB) ../ ; \ + cd ..; \ + else true; fi; \ + if [ x"$(NOASANFLAG)" != x ]; then \ +-- +2.31.1 + diff --git a/9999/0003-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch b/9999/0003-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch deleted file mode 100644 index f7443bf..0000000 --- a/9999/0003-Gentoo-gold-ld-add-support-for-poisoned-system-direc.patch +++ /dev/null @@ -1,336 +0,0 @@ -From 8a82f64de912f26e840b20eec9d8a463fd0e242b Mon Sep 17 00:00:00 2001 -From: Mike Frysinger -Date: Tue, 20 Jul 2021 21:08:31 +0200 -Subject: [PATCH 1/6] Gentoo: gold/ld: add support for poisoned system - directories -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This is based on the old CodeSourcery patch written by Joseph Myers to add -support to the link for detecting & rejecting bad -L paths when using a -cross-compiler. The differences here: -* The command line flags are always available. -* We can turn on & off the warning via the command line. -* The configure option controls the default warning behavior. -* Add support for gold. - -It is not currently upstream, nor has it been submitted at all. There are -no plans to do so currently either. - -BUG=chromium:488360 -TEST=`cbuildbot chromiumos-sdk` passes # tests arm/amd64/mipsel/x86 -TEST=`cbuildbot panther_moblab-full whirlwind-release` pass -TEST=`cbuildbot {x32,arm64}-generic-full` has no new failures -TEST=x86_64-cros-linux-gnu-ld throws warnings when using -L/lib (gold & bfd) - -Reviewed-on: https://chromium-review.googlesource.com/272083 -(cherry picked from commit f92dbf35c00ab13cee36f6be8ae5ca46454d9000) - -Ported to binutils 2.37 Andreas K. Hütte ---- - gold/options.cc | 33 +++++++++++++++++++++++++++++++++ - gold/options.h | 7 +++++++ - ld/config.in | 3 +++ - ld/configure | 14 ++++++++++++++ - ld/configure.ac | 10 ++++++++++ - ld/ld.h | 7 +++++++ - ld/ld.texi | 18 ++++++++++++++++++ - ld/ldfile.c | 20 ++++++++++++++++++++ - ld/ldlex.h | 3 +++ - ld/ldmain.c | 7 +++++++ - ld/lexsup.c | 24 ++++++++++++++++++++++++ - 11 files changed, 146 insertions(+) - -diff --git a/gold/options.cc b/gold/options.cc -index 5a55bd8ba6d..f7940c75f5a 100644 ---- a/gold/options.cc -+++ b/gold/options.cc -@@ -1355,6 +1355,39 @@ General_options::finalize() - // in the path, as appropriate. - this->add_sysroot(); - -+ // Now check if library_path is poisoned. -+ if (this->warn_poison_system_directories()) -+ { -+ std::vector bad_paths; -+ -+ bad_paths.push_back("/lib"); -+ // TODO: This check is disabled for now due to a bunch of packages that -+ // use libtool and relink with -L/usr/lib paths (albeit after the right -+ // sysroot path). Once those are fixed we can enable. -+ // We also need to adjust it so it only rejects one or two levels deep. -+ // Gcc's internal paths also live below /usr/lib. -+ // http://crbug.com/488360 -+ // bad_paths.push_back("/usr/lib"); -+ bad_paths.push_back("/usr/local/lib"); -+ bad_paths.push_back("/usr/X11R6/lib"); -+ -+ for (std::vector::const_iterator b = bad_paths.begin(); -+ b != bad_paths.end(); -+ ++b) -+ for (Dir_list::iterator p = this->library_path_.value.begin(); -+ p != this->library_path_.value.end(); -+ ++p) -+ if (!p->name().compare(0, b->size(), *b)) -+ { -+ if (this->error_poison_system_directories()) -+ gold_fatal(_("library search path \"%s\" is unsafe for " -+ "cross-compilation"), p->name().c_str()); -+ else -+ gold_warning(_("library search path \"%s\" is unsafe for " -+ "cross-compilation"), p->name().c_str()); -+ } -+ } -+ - // Now that we've normalized the options, check for contradictory ones. - if (this->shared() && this->is_static()) - gold_fatal(_("-shared and -static are incompatible")); -diff --git a/gold/options.h b/gold/options.h -index 757ebf18fec..490b4cbd7d4 100644 ---- a/gold/options.h -+++ b/gold/options.h -@@ -1394,6 +1394,13 @@ class General_options - DEFINE_bool(warn_multiple_gp, options::TWO_DASHES, '\0', false, - N_("Ignored"), NULL); - -+ DEFINE_bool(warn_poison_system_directories, options::TWO_DASHES, '\0', false, -+ N_("Warn for -L options using system directories"), -+ N_("Do not warn for -L options using system directories")); -+ DEFINE_bool(error_poison_system_directories, options::TWO_DASHES, '\0', false, -+ N_("Give an error for -L options using system directories"), -+ NULL); -+ - DEFINE_bool(warn_search_mismatch, options::TWO_DASHES, '\0', true, - N_("Warn when skipping an incompatible library"), - N_("Don't warn when skipping an incompatible library")); -diff --git a/ld/config.in b/ld/config.in -index 26d55a00d47..ffad464783c 100644 ---- a/ld/config.in -+++ b/ld/config.in -@@ -43,6 +43,9 @@ - language is requested. */ - #undef ENABLE_NLS - -+/* Define to warn for use of native system library directories */ -+#undef ENABLE_POISON_SYSTEM_DIRECTORIES -+ - /* Additional extension a shared object might have. */ - #undef EXTRA_SHLIB_EXTENSION - -diff --git a/ld/configure b/ld/configure -index c197aaef3cb..882263aa43f 100755 ---- a/ld/configure -+++ b/ld/configure -@@ -829,6 +829,7 @@ with_lib_path - enable_targets - enable_64_bit_bfd - with_sysroot -+enable_poison_system_directories - enable_gold - enable_got - enable_compressed_debug_sections -@@ -1498,6 +1499,8 @@ Optional Features: - --enable-checking enable run-time checks - --enable-targets alternative target configurations - --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes) -+ --enable-poison-system-directories -+ warn for use of native system library directories - --enable-gold[=ARG] build gold [ARG={default,yes,no}] - --enable-got= GOT handling scheme (target, single, negative, - multigot) -@@ -15236,7 +15239,18 @@ else - fi - - -+# Check whether --enable-poison-system-directories was given. -+if test "${enable_poison_system_directories+set}" = set; then : -+ enableval=$enable_poison_system_directories; -+else -+ enable_poison_system_directories=no -+fi -+ -+if test "x${enable_poison_system_directories}" = "xyes"; then - -+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h -+ -+fi - - # Check whether --enable-got was given. - if test "${enable_got+set}" = set; then : -diff --git a/ld/configure.ac b/ld/configure.ac -index 8ea97c43cd4..0f246db67d8 100644 ---- a/ld/configure.ac -+++ b/ld/configure.ac -@@ -106,6 +106,16 @@ AC_SUBST(use_sysroot) - AC_SUBST(TARGET_SYSTEM_ROOT) - AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) - -+AC_ARG_ENABLE([poison-system-directories], -+ AS_HELP_STRING([--enable-poison-system-directories], -+ [warn for use of native system library directories]),, -+ [enable_poison_system_directories=no]) -+if test "x${enable_poison_system_directories}" = "xyes"; then -+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], -+ [1], -+ [Define to warn for use of native system library directories]) -+fi -+ - dnl Use --enable-gold to decide if this linker should be the default. - dnl "install_as_default" is set to false if gold is the default linker. - dnl "installed_linker" is the installed BFD linker name. -diff --git a/ld/ld.h b/ld/ld.h -index 35fafebfaed..4152278b8f4 100644 ---- a/ld/ld.h -+++ b/ld/ld.h -@@ -162,6 +162,13 @@ typedef struct - in the linker script. */ - bool force_group_allocation; - -+ /* If true warn for uses of system directories when cross linking. */ -+ bool warn_poison_system_directories; -+ -+ /* If true (default false) give an error for uses of system -+ directories when cross linking instead of a warning. */ -+ bool error_poison_system_directories; -+ - /* Big or little endian as set on command line. */ - enum endian_enum endian; - -diff --git a/ld/ld.texi b/ld/ld.texi -index dd8f571d4e4..0aee4a4e9f1 100644 ---- a/ld/ld.texi -+++ b/ld/ld.texi -@@ -2863,6 +2863,24 @@ string identifying the original linked file does not change. - - Passing @code{none} for @var{style} disables the setting from any - @code{--build-id} options earlier on the command line. -+ -+@kindex --warn-poison-system-directories -+@item --warn-poison-system-directories -+Warn for @option{-L} options using system directories such as -+@file{/usr/lib} when cross linking. This option is intended for use -+in environments that want to detect and reject incorrect link settings. -+ -+@kindex --no-warn-poison-system-directories -+@item --no-warn-poison-system-directories -+Do not warn for @option{-L} options using system directories such as -+@file{/usr/lib} when cross linking. This option is intended for use -+in chroot environments when such directories contain the correct -+libraries for the target system rather than the host. -+ -+@kindex --error-poison-system-directories -+@item --error-poison-system-directories -+Give an error instead of a warning for @option{-L} options using -+system directories when cross linking. - @end table - - @c man end -diff --git a/ld/ldfile.c b/ld/ldfile.c -index 9d0af06f1f6..f4a83acca93 100644 ---- a/ld/ldfile.c -+++ b/ld/ldfile.c -@@ -117,6 +117,26 @@ ldfile_add_library_path (const char *name, bool cmdline) - new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL); - else - new_dirs->name = xstrdup (name); -+ -+ if (command_line.warn_poison_system_directories -+ && (!strncmp (name, "/lib", 4) -+ /* TODO: This check is disabled for now due to a bunch of packages that -+ * use libtool and relink with -L/usr/lib paths (albeit after the right -+ * sysroot path). Once those are fixed we can enable. -+ * We also need to adjust it so it only rejects one or two levels deep. -+ * Gcc's internal paths also live below /usr/lib. -+ * http://crbug.com/488360 */ -+ /* || !strncmp (name, "/usr/lib", 8) */ -+ || !strncmp (name, "/usr/local/lib", 14) -+ || !strncmp (name, "/usr/X11R6/lib", 14))) -+ { -+ if (command_line.error_poison_system_directories) -+ einfo (_("%X%P: error: library search path \"%s\" is unsafe for " -+ "cross-compilation\n"), name); -+ else -+ einfo (_("%P: warning: library search path \"%s\" is unsafe for " -+ "cross-compilation\n"), name); -+ } - } - - /* Try to open a BFD for a lang_input_statement. */ -diff --git a/ld/ldlex.h b/ld/ldlex.h -index 9e8bf5fb835..3baed822a22 100644 ---- a/ld/ldlex.h -+++ b/ld/ldlex.h -@@ -148,6 +148,9 @@ enum option_values - OPTION_PRINT_OUTPUT_FORMAT, - OPTION_PRINT_SYSROOT, - OPTION_IGNORE_UNRESOLVED_SYMBOL, -+ OPTION_WARN_POISON_SYSTEM_DIRECTORIES, -+ OPTION_NO_WARN_POISON_SYSTEM_DIRECTORIES, -+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES, - OPTION_PUSH_STATE, - OPTION_POP_STATE, - OPTION_DISABLE_MULTIPLE_DEFS_ABS, -diff --git a/ld/ldmain.c b/ld/ldmain.c -index 42660eb9a3c..c78009b760c 100644 ---- a/ld/ldmain.c -+++ b/ld/ldmain.c -@@ -321,6 +321,13 @@ main (int argc, char **argv) - command_line.warn_mismatch = true; - command_line.warn_search_mismatch = true; - command_line.check_section_addresses = -1; -+ command_line.warn_poison_system_directories = -+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES -+ true; -+#else -+ false; -+#endif -+ command_line.error_poison_system_directories = false; - - /* We initialize DEMANGLING based on the environment variable - COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the -diff --git a/ld/lexsup.c b/ld/lexsup.c -index 00274c500d0..a19cce9967c 100644 ---- a/ld/lexsup.c -+++ b/ld/lexsup.c -@@ -566,6 +566,18 @@ static const struct ld_option ld_options[] = - OPTION_IGNORE_UNRESOLVED_SYMBOL}, - '\0', N_("SYMBOL"), - N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES }, -+ { {"warn-poison-system-directories", no_argument, NULL, -+ OPTION_WARN_POISON_SYSTEM_DIRECTORIES}, -+ '\0', NULL, N_("Warn for -L options using system directories"), -+ TWO_DASHES }, -+ { {"no-warn-poison-system-directories", no_argument, NULL, -+ OPTION_NO_WARN_POISON_SYSTEM_DIRECTORIES}, -+ '\0', NULL, N_("Do not warn for -L options using system directories"), -+ TWO_DASHES }, -+ { {"error-poison-system-directories", no_argument, NULL, -+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES}, -+ '\0', NULL, N_("Give an error for -L options using system directories"), -+ TWO_DASHES }, - { {"push-state", no_argument, NULL, OPTION_PUSH_STATE}, - '\0', NULL, N_("Push state of flags governing input file handling"), - TWO_DASHES }, -@@ -1643,6 +1655,18 @@ parse_args (unsigned argc, char **argv) - } - break; - -+ case OPTION_WARN_POISON_SYSTEM_DIRECTORIES: -+ command_line.warn_poison_system_directories = true; -+ break; -+ -+ case OPTION_NO_WARN_POISON_SYSTEM_DIRECTORIES: -+ command_line.warn_poison_system_directories = false; -+ break; -+ -+ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES: -+ command_line.error_poison_system_directories = true; -+ break; -+ - case OPTION_PUSH_STATE: - input_flags.pushed = xmemdup (&input_flags, - sizeof (input_flags), --- -2.31.1 - diff --git a/9999/0003-Gentoo-opcodes-link-against-libbfd.la-for-rpath-deps.patch b/9999/0003-Gentoo-opcodes-link-against-libbfd.la-for-rpath-deps.patch new file mode 100644 index 0000000..f3c9f8e --- /dev/null +++ b/9999/0003-Gentoo-opcodes-link-against-libbfd.la-for-rpath-deps.patch @@ -0,0 +1,49 @@ +From c55536c61ec7e4c2e983e15f51f56f7a7c340889 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Tue, 5 Jul 2016 20:24:00 +0545 +Subject: [PATCH 3/6] Gentoo: opcodes: link against libbfd.la for rpath deps + +The reason opcodes doesn't link against libbfd.la is to workaround a +libtool bug where it uses installed -L paths ahead of DESTDIR paths. +The downside is that the library itself lacks rpath tags to find the +right version of libbfd.so. + +Since Gentoo has patched the libtool bug for a while, we don't need +the workaround. Use the .la file so we get the rpath tags. + +URL: https://bugs.gentoo.org/563934 +(cherry picked from commit 662586237b0b00ee881e79b56f6234ff36e8bfe6) +--- + opcodes/configure | 2 +- + opcodes/configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/opcodes/configure b/opcodes/configure +index a3da5987f1b..22a05245286 100755 +--- a/opcodes/configure ++++ b/opcodes/configure +@@ -12142,7 +12142,7 @@ if test "$enable_shared" = "yes"; then + SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}" + ;; + *) +- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}" ++ SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}" + ;; + esac + SHARED_DEPENDENCIES="../bfd/libbfd.la" +diff --git a/opcodes/configure.ac b/opcodes/configure.ac +index e564f067334..fb6254cd69d 100644 +--- a/opcodes/configure.ac ++++ b/opcodes/configure.ac +@@ -203,7 +203,7 @@ if test "$enable_shared" = "yes"; then + SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}" + ;; + *) +- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}" ++ SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}" + ;; + esac + SHARED_DEPENDENCIES="../bfd/libbfd.la" +-- +2.31.1 + diff --git a/9999/0004-Gentoo-add-with-extra-soversion-suffix-option.patch b/9999/0004-Gentoo-add-with-extra-soversion-suffix-option.patch new file mode 100644 index 0000000..1051543 --- /dev/null +++ b/9999/0004-Gentoo-add-with-extra-soversion-suffix-option.patch @@ -0,0 +1,146 @@ +From 235f1f862fb9bf77e2b9f62c24db0ca801c4a057 Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Tue, 20 Jul 2021 21:12:38 +0200 +Subject: [PATCH 4/6] Gentoo: add --with-extra-soversion-suffix= option +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--with-extra-soversion-suffix= will allow Gentoo to +distinct libbfd.so and libopcodes.so to have more precise +SONAME. + +Today --enable-targets=all and --enable-64-bit-bfd change +libbfd.so ABI: +--enable-targets=all adds new symbols to the library +--enable-64-bit-bfd modifies BFD_ARCH_SIZE default and +changes sizes of integer parameters and fields to most +APIs. + +--with-extra-soversion-suffix= will allow Gentoo to inject +additional keys into SONAME to indicate ABI change and avoid +hard to diagnose crashes when user reinstalls libbfd.so +built with different flags (see https://bugs.gentoo.org/663690). + +Bug: https://bugs.gentoo.org/666100 +Signed-off-by: Sergei Trofimovich + +Ported to binutils 2.37 Andreas K. Hüttel +--- + bfd/Makefile.am | 5 +++++ + bfd/Makefile.in | 4 ++++ + bfd/configure | 13 +++++++++++++ + bfd/configure.ac | 7 +++++++ + 4 files changed, 29 insertions(+) + +diff --git a/bfd/Makefile.am b/bfd/Makefile.am +index ed2f701805d..dab3bfc8ed7 100644 +--- a/bfd/Makefile.am ++++ b/bfd/Makefile.am +@@ -59,6 +59,8 @@ bfdinclude_HEADERS += $(INCDIR)/plugin-api.h + LIBDL = @lt_cv_dlopen_libs@ + endif + ++EXTRA_SOVERSION_SUFFIX = @EXTRA_SOVERSION_SUFFIX@ ++ + # bfd.h goes here, for now + BFD_H = bfd.h + +@@ -952,6 +954,9 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in + bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ + bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ + fi ;\ ++ if test x"$(EXTRA_SOVERSION_SUFFIX)" != x ; then \ ++ bfd_soversion="$${bfd_soversion}.$(EXTRA_SOVERSION_SUFFIX)" ;\ ++ fi ;\ + $(SED) -e "s,@bfd_version@,$$bfd_version," \ + -e "s,@bfd_version_string@,$$bfd_version_string," \ + -e "s,@bfd_version_package@,$$bfd_version_package," \ +diff --git a/bfd/Makefile.in b/bfd/Makefile.in +index 12807d99760..572df143487 100644 +--- a/bfd/Makefile.in ++++ b/bfd/Makefile.in +@@ -318,6 +318,7 @@ ECHO_T = @ECHO_T@ + EGREP = @EGREP@ + EXEEXT = @EXEEXT@ + EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ ++EXTRA_SOVERSION_SUFFIX = @EXTRA_SOVERSION_SUFFIX@ + FGREP = @FGREP@ + GENCAT = @GENCAT@ + GMSGFMT = @GMSGFMT@ +@@ -2063,6 +2064,9 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in + bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ + bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ + fi ;\ ++ if test x"$(EXTRA_SOVERSION_SUFFIX)" != x ; then \ ++ bfd_soversion="$${bfd_soversion}.$(EXTRA_SOVERSION_SUFFIX)" ;\ ++ fi ;\ + $(SED) -e "s,@bfd_version@,$$bfd_version," \ + -e "s,@bfd_version_string@,$$bfd_version_string," \ + -e "s,@bfd_version_package@,$$bfd_version_package," \ +diff --git a/bfd/configure b/bfd/configure +index 41586f00f93..f0acf160913 100755 +--- a/bfd/configure ++++ b/bfd/configure +@@ -696,6 +696,7 @@ WARN_CFLAGS + REPORT_BUGS_TEXI + REPORT_BUGS_TO + PKGVERSION ++EXTRA_SOVERSION_SUFFIX + DEBUGDIR + PLUGINS_FALSE + PLUGINS_TRUE +@@ -835,6 +836,7 @@ enable_secureplt + enable_separate_code + enable_leading_mingw64_underscores + with_separate_debug_dir ++with_extra_soversion_suffix + with_pkgversion + with_bugurl + enable_werror +@@ -1511,6 +1513,8 @@ Optional Packages: + --with-separate-debug-dir=DIR + Look for global separate debug info in DIR + [[default=LIBDIR/debug]] ++ --with-extra-soversion-suffix=SUFFIX ++ Append '.SUFFIX' to SONAME [default=] + --with-pkgversion=PKG Use PKG in the version string in place of "GNU + Binutils" + --with-bugurl=URL Direct users to URL to report a bug +@@ -11913,6 +11917,15 @@ fi + + + ++EXTRA_SOVERSION_SUFFIX= ++ ++# Check whether --with-extra-soversion-suffix was given. ++if test "${with_extra_soversion_suffix+set}" = set; then : ++ withval=$with_extra_soversion_suffix; EXTRA_SOVERSION_SUFFIX="${withval}" ++fi ++ ++ ++ + + + # Check whether --with-pkgversion was given. +diff --git a/bfd/configure.ac b/bfd/configure.ac +index fec067b2135..8c9ef9a04c0 100644 +--- a/bfd/configure.ac ++++ b/bfd/configure.ac +@@ -169,6 +169,13 @@ AC_ARG_WITH(separate-debug-dir, + [DEBUGDIR="${withval}"]) + AC_SUBST(DEBUGDIR) + ++EXTRA_SOVERSION_SUFFIX= ++AC_ARG_WITH(extra-soversion-suffix, ++ AS_HELP_STRING([--with-extra-soversion-suffix=SUFFIX], ++ [Append '.SUFFIX' to SONAME [[default=]]]), ++[EXTRA_SOVERSION_SUFFIX="${withval}"]) ++AC_SUBST(EXTRA_SOVERSION_SUFFIX) ++ + ACX_PKGVERSION([GNU Binutils]) + ACX_BUGURL([https://www.sourceware.org/bugzilla/]) + +-- +2.31.1 + diff --git a/9999/0004-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch b/9999/0004-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch deleted file mode 100644 index 4d5ed11..0000000 --- a/9999/0004-Gentoo-libiberty-install-PIC-version-of-libiberty.a.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 6536761c1e2756ec39fdc33c400757be3744510c Mon Sep 17 00:00:00 2001 -From: Mike Frysinger -Date: Fri, 7 Jan 2005 00:15:53 -0500 -Subject: [PATCH 2/6] Gentoo: libiberty: install PIC version of libiberty.a - -This will install a PIC version of libiberty.a by overwriting the non-PIC -version of libiberty.a while compiling. We do this because there is no -shared version of libiberty for random apps to link against which means if -someone wants to use this in a shared library or PIE, they're out of luck. -It's arguable whether people should be able to use this in a shared lib, -but usage in PIE should be fine. You could argue that this penalizes the -non-PIE users, but the counter point is that people using this library in -general are fairly low, and we'd rather have things work for all of them. - -(cherry picked from commit 112aff9ad3e2675556370c4281117a6df0a879d9) ---- - libiberty/Makefile.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in -index d19e14a2aca..cd02be1c2fb 100644 ---- a/libiberty/Makefile.in -+++ b/libiberty/Makefile.in -@@ -257,6 +257,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) - $(AR) $(AR_FLAGS) $(TARGETLIB) \ - $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \ - $(RANLIB) $(TARGETLIB); \ -+ cp $(TARGETLIB) ../ ; \ - cd ..; \ - else true; fi; \ - if [ x"$(NOASANFLAG)" != x ]; then \ --- -2.31.1 - diff --git a/9999/0005-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch b/9999/0005-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch new file mode 100644 index 0000000..c6e5299 --- /dev/null +++ b/9999/0005-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch @@ -0,0 +1,49 @@ +From f4ecba77ec1eb0576b8731c749336ea3889eba73 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= +Date: Sun, 13 Oct 2019 05:25:28 +0200 +Subject: [PATCH 5/6] Gentoo: ld: enable new dtags by default for linux/gnu + targets + +Original author: Mike Frysinger + +The "new" dtags options have been around for 14+ years now, so for Linux +and GNU targets, enable them by default. + +2012-01-21 Mike Frysinger + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set + link_info.new_dtags to TRUE for linux/gnu targets. + * NEWS: Mention new dtags default. + +2013-01-22 Roland McGrath + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set + new_dtags to TRUE for *-*-nacl* targets. +--- + ld/emultempl/elf.em | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em +index bfaf8130a3e..c4c42b7371a 100644 +--- a/ld/emultempl/elf.em ++++ b/ld/emultempl/elf.em +@@ -81,6 +81,16 @@ gld${EMULATION_NAME}_before_parse (void) + input_flags.dynamic = ${DYNAMIC_LINK-true}; + config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`; + config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo true ; else echo false ; fi`; ++EOF ++ ++case ${target} in ++ *-*-linux-* | *-*-k*bsd*-* | *-*-gnu* | *-*-nacl*) ++ fragment < -Date: Tue, 5 Jul 2016 20:24:00 +0545 -Subject: [PATCH 3/6] Gentoo: opcodes: link against libbfd.la for rpath deps - -The reason opcodes doesn't link against libbfd.la is to workaround a -libtool bug where it uses installed -L paths ahead of DESTDIR paths. -The downside is that the library itself lacks rpath tags to find the -right version of libbfd.so. - -Since Gentoo has patched the libtool bug for a while, we don't need -the workaround. Use the .la file so we get the rpath tags. - -URL: https://bugs.gentoo.org/563934 -(cherry picked from commit 662586237b0b00ee881e79b56f6234ff36e8bfe6) ---- - opcodes/configure | 2 +- - opcodes/configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/opcodes/configure b/opcodes/configure -index a3da5987f1b..22a05245286 100755 ---- a/opcodes/configure -+++ b/opcodes/configure -@@ -12142,7 +12142,7 @@ if test "$enable_shared" = "yes"; then - SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}" - ;; - *) -- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}" -+ SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}" - ;; - esac - SHARED_DEPENDENCIES="../bfd/libbfd.la" -diff --git a/opcodes/configure.ac b/opcodes/configure.ac -index e564f067334..fb6254cd69d 100644 ---- a/opcodes/configure.ac -+++ b/opcodes/configure.ac -@@ -203,7 +203,7 @@ if test "$enable_shared" = "yes"; then - SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}" - ;; - *) -- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}" -+ SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}" - ;; - esac - SHARED_DEPENDENCIES="../bfd/libbfd.la" --- -2.31.1 - diff --git a/9999/0006-Gentoo-Pass-hash-style-sysv.patch b/9999/0006-Gentoo-Pass-hash-style-sysv.patch new file mode 100644 index 0000000..41b6a33 --- /dev/null +++ b/9999/0006-Gentoo-Pass-hash-style-sysv.patch @@ -0,0 +1,61 @@ +From 905bf3c180f4f7fd07024eb9ff7851898593f3f8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= +Date: Tue, 20 Jul 2021 21:15:24 +0200 +Subject: [PATCH 6/6] Gentoo: Pass --hash-style=sysv to ld in the testsuite + +--- + binutils/testsuite/lib/binutils-common.exp | 2 +- + ld/testsuite/lib/ld-lib.exp | 16 ++++++++++++++-- + 2 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp +index 59e25df99b0..401a05b5c32 100644 +--- a/binutils/testsuite/lib/binutils-common.exp ++++ b/binutils/testsuite/lib/binutils-common.exp +@@ -1279,7 +1279,7 @@ proc run_dump_test { name {extra_options {}} } { + + # Add -L$srcdir/$subdir so that the linker command can use + # linker scripts in the source directory. +- set cmd "$LD $ld_extra_opt $LDFLAGS -L$srcdir/$subdir \ ++ set cmd "$LD --hash-style=sysv $ld_extra_opt $LDFLAGS -L$srcdir/$subdir \ + $opts(ld) -o $objfile $objfiles $opts(ld_after_inputfiles)" + + # If needed then check for, or add a -Map option. +diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp +index 8fd14afc63e..adbeaa3bd08 100644 +--- a/ld/testsuite/lib/ld-lib.exp ++++ b/ld/testsuite/lib/ld-lib.exp +@@ -167,7 +167,7 @@ proc default_ld_relocate { ld target objects } { + global HOSTING_EMU + + remote_file host delete $target +- return [run_host_cmd_yesno "$ld" "$HOSTING_EMU -o $target -r $objects"] ++ return [run_host_cmd_yesno "$ld" "$HOSTING_EMU --hash-style=sysv -o $target -r $objects"] + } + + # Check to see if ld is being invoked with a non-endian output format +@@ -198,8 +198,20 @@ proc default_ld_link { ld target objects } { + set flags [big_or_little_endian] + } + ++ # Hilariously, this procedure is called sometimes with $CC and sometimes ++ # with $ld as parameter. If we want to change the default behaviour, we ++ # need to take the different option formats into account. ++ # We check the $ld parameter for ++ # - ld-new -> we're working with the new linker ++ # - otherwise -> we're likely working with the system compiler ++ if {[regexp {ld-new$} $ld]} { ++ set gentoosysv "--hash-style=sysv" ++ } else { ++ set gentoosysv "-Wl,--hash-style=sysv" ++ } ++ + remote_file host delete $target +- set exec_output [run_host_cmd "$ld" "$flags -o $target $objects"] ++ set exec_output [run_host_cmd "$ld" "$gentoosysv $flags -o $target $objects"] + set exec_output [prune_warnings $exec_output] + + # We don't care if we get a warning about a non-existent start +-- +2.31.1 + diff --git a/9999/0006-Gentoo-add-with-extra-soversion-suffix-option.patch b/9999/0006-Gentoo-add-with-extra-soversion-suffix-option.patch deleted file mode 100644 index 1051543..0000000 --- a/9999/0006-Gentoo-add-with-extra-soversion-suffix-option.patch +++ /dev/null @@ -1,146 +0,0 @@ -From 235f1f862fb9bf77e2b9f62c24db0ca801c4a057 Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Tue, 20 Jul 2021 21:12:38 +0200 -Subject: [PATCH 4/6] Gentoo: add --with-extra-soversion-suffix= option -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---with-extra-soversion-suffix= will allow Gentoo to -distinct libbfd.so and libopcodes.so to have more precise -SONAME. - -Today --enable-targets=all and --enable-64-bit-bfd change -libbfd.so ABI: ---enable-targets=all adds new symbols to the library ---enable-64-bit-bfd modifies BFD_ARCH_SIZE default and -changes sizes of integer parameters and fields to most -APIs. - ---with-extra-soversion-suffix= will allow Gentoo to inject -additional keys into SONAME to indicate ABI change and avoid -hard to diagnose crashes when user reinstalls libbfd.so -built with different flags (see https://bugs.gentoo.org/663690). - -Bug: https://bugs.gentoo.org/666100 -Signed-off-by: Sergei Trofimovich - -Ported to binutils 2.37 Andreas K. Hüttel ---- - bfd/Makefile.am | 5 +++++ - bfd/Makefile.in | 4 ++++ - bfd/configure | 13 +++++++++++++ - bfd/configure.ac | 7 +++++++ - 4 files changed, 29 insertions(+) - -diff --git a/bfd/Makefile.am b/bfd/Makefile.am -index ed2f701805d..dab3bfc8ed7 100644 ---- a/bfd/Makefile.am -+++ b/bfd/Makefile.am -@@ -59,6 +59,8 @@ bfdinclude_HEADERS += $(INCDIR)/plugin-api.h - LIBDL = @lt_cv_dlopen_libs@ - endif - -+EXTRA_SOVERSION_SUFFIX = @EXTRA_SOVERSION_SUFFIX@ -+ - # bfd.h goes here, for now - BFD_H = bfd.h - -@@ -952,6 +954,9 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in - bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ - bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ - fi ;\ -+ if test x"$(EXTRA_SOVERSION_SUFFIX)" != x ; then \ -+ bfd_soversion="$${bfd_soversion}.$(EXTRA_SOVERSION_SUFFIX)" ;\ -+ fi ;\ - $(SED) -e "s,@bfd_version@,$$bfd_version," \ - -e "s,@bfd_version_string@,$$bfd_version_string," \ - -e "s,@bfd_version_package@,$$bfd_version_package," \ -diff --git a/bfd/Makefile.in b/bfd/Makefile.in -index 12807d99760..572df143487 100644 ---- a/bfd/Makefile.in -+++ b/bfd/Makefile.in -@@ -318,6 +318,7 @@ ECHO_T = @ECHO_T@ - EGREP = @EGREP@ - EXEEXT = @EXEEXT@ - EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ -+EXTRA_SOVERSION_SUFFIX = @EXTRA_SOVERSION_SUFFIX@ - FGREP = @FGREP@ - GENCAT = @GENCAT@ - GMSGFMT = @GMSGFMT@ -@@ -2063,6 +2064,9 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in - bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ - bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ - fi ;\ -+ if test x"$(EXTRA_SOVERSION_SUFFIX)" != x ; then \ -+ bfd_soversion="$${bfd_soversion}.$(EXTRA_SOVERSION_SUFFIX)" ;\ -+ fi ;\ - $(SED) -e "s,@bfd_version@,$$bfd_version," \ - -e "s,@bfd_version_string@,$$bfd_version_string," \ - -e "s,@bfd_version_package@,$$bfd_version_package," \ -diff --git a/bfd/configure b/bfd/configure -index 41586f00f93..f0acf160913 100755 ---- a/bfd/configure -+++ b/bfd/configure -@@ -696,6 +696,7 @@ WARN_CFLAGS - REPORT_BUGS_TEXI - REPORT_BUGS_TO - PKGVERSION -+EXTRA_SOVERSION_SUFFIX - DEBUGDIR - PLUGINS_FALSE - PLUGINS_TRUE -@@ -835,6 +836,7 @@ enable_secureplt - enable_separate_code - enable_leading_mingw64_underscores - with_separate_debug_dir -+with_extra_soversion_suffix - with_pkgversion - with_bugurl - enable_werror -@@ -1511,6 +1513,8 @@ Optional Packages: - --with-separate-debug-dir=DIR - Look for global separate debug info in DIR - [[default=LIBDIR/debug]] -+ --with-extra-soversion-suffix=SUFFIX -+ Append '.SUFFIX' to SONAME [default=] - --with-pkgversion=PKG Use PKG in the version string in place of "GNU - Binutils" - --with-bugurl=URL Direct users to URL to report a bug -@@ -11913,6 +11917,15 @@ fi - - - -+EXTRA_SOVERSION_SUFFIX= -+ -+# Check whether --with-extra-soversion-suffix was given. -+if test "${with_extra_soversion_suffix+set}" = set; then : -+ withval=$with_extra_soversion_suffix; EXTRA_SOVERSION_SUFFIX="${withval}" -+fi -+ -+ -+ - - - # Check whether --with-pkgversion was given. -diff --git a/bfd/configure.ac b/bfd/configure.ac -index fec067b2135..8c9ef9a04c0 100644 ---- a/bfd/configure.ac -+++ b/bfd/configure.ac -@@ -169,6 +169,13 @@ AC_ARG_WITH(separate-debug-dir, - [DEBUGDIR="${withval}"]) - AC_SUBST(DEBUGDIR) - -+EXTRA_SOVERSION_SUFFIX= -+AC_ARG_WITH(extra-soversion-suffix, -+ AS_HELP_STRING([--with-extra-soversion-suffix=SUFFIX], -+ [Append '.SUFFIX' to SONAME [[default=]]]), -+[EXTRA_SOVERSION_SUFFIX="${withval}"]) -+AC_SUBST(EXTRA_SOVERSION_SUFFIX) -+ - ACX_PKGVERSION([GNU Binutils]) - ACX_BUGURL([https://www.sourceware.org/bugzilla/]) - --- -2.31.1 - diff --git a/9999/0007-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch b/9999/0007-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch deleted file mode 100644 index c6e5299..0000000 --- a/9999/0007-Gentoo-ld-enable-new-dtags-by-default-for-linux-gnu-.patch +++ /dev/null @@ -1,49 +0,0 @@ -From f4ecba77ec1eb0576b8731c749336ea3889eba73 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= -Date: Sun, 13 Oct 2019 05:25:28 +0200 -Subject: [PATCH 5/6] Gentoo: ld: enable new dtags by default for linux/gnu - targets - -Original author: Mike Frysinger - -The "new" dtags options have been around for 14+ years now, so for Linux -and GNU targets, enable them by default. - -2012-01-21 Mike Frysinger - - * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set - link_info.new_dtags to TRUE for linux/gnu targets. - * NEWS: Mention new dtags default. - -2013-01-22 Roland McGrath - - * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set - new_dtags to TRUE for *-*-nacl* targets. ---- - ld/emultempl/elf.em | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em -index bfaf8130a3e..c4c42b7371a 100644 ---- a/ld/emultempl/elf.em -+++ b/ld/emultempl/elf.em -@@ -81,6 +81,16 @@ gld${EMULATION_NAME}_before_parse (void) - input_flags.dynamic = ${DYNAMIC_LINK-true}; - config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`; - config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo true ; else echo false ; fi`; -+EOF -+ -+case ${target} in -+ *-*-linux-* | *-*-k*bsd*-* | *-*-gnu* | *-*-nacl*) -+ fragment < -Date: Tue, 20 Jul 2021 21:15:24 +0200 -Subject: [PATCH 6/6] Gentoo: Pass --hash-style=sysv to ld in the testsuite - ---- - binutils/testsuite/lib/binutils-common.exp | 2 +- - ld/testsuite/lib/ld-lib.exp | 16 ++++++++++++++-- - 2 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp -index 59e25df99b0..401a05b5c32 100644 ---- a/binutils/testsuite/lib/binutils-common.exp -+++ b/binutils/testsuite/lib/binutils-common.exp -@@ -1279,7 +1279,7 @@ proc run_dump_test { name {extra_options {}} } { - - # Add -L$srcdir/$subdir so that the linker command can use - # linker scripts in the source directory. -- set cmd "$LD $ld_extra_opt $LDFLAGS -L$srcdir/$subdir \ -+ set cmd "$LD --hash-style=sysv $ld_extra_opt $LDFLAGS -L$srcdir/$subdir \ - $opts(ld) -o $objfile $objfiles $opts(ld_after_inputfiles)" - - # If needed then check for, or add a -Map option. -diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp -index 8fd14afc63e..adbeaa3bd08 100644 ---- a/ld/testsuite/lib/ld-lib.exp -+++ b/ld/testsuite/lib/ld-lib.exp -@@ -167,7 +167,7 @@ proc default_ld_relocate { ld target objects } { - global HOSTING_EMU - - remote_file host delete $target -- return [run_host_cmd_yesno "$ld" "$HOSTING_EMU -o $target -r $objects"] -+ return [run_host_cmd_yesno "$ld" "$HOSTING_EMU --hash-style=sysv -o $target -r $objects"] - } - - # Check to see if ld is being invoked with a non-endian output format -@@ -198,8 +198,20 @@ proc default_ld_link { ld target objects } { - set flags [big_or_little_endian] - } - -+ # Hilariously, this procedure is called sometimes with $CC and sometimes -+ # with $ld as parameter. If we want to change the default behaviour, we -+ # need to take the different option formats into account. -+ # We check the $ld parameter for -+ # - ld-new -> we're working with the new linker -+ # - otherwise -> we're likely working with the system compiler -+ if {[regexp {ld-new$} $ld]} { -+ set gentoosysv "--hash-style=sysv" -+ } else { -+ set gentoosysv "-Wl,--hash-style=sysv" -+ } -+ - remote_file host delete $target -- set exec_output [run_host_cmd "$ld" "$flags -o $target $objects"] -+ set exec_output [run_host_cmd "$ld" "$gentoosysv $flags -o $target $objects"] - set exec_output [prune_warnings $exec_output] - - # We don't care if we get a warning about a non-existent start --- -2.31.1 - -- cgit v1.2.3-65-gdbad