comment "Legacy options removed in 2020.08"
+config BR2_BINUTILS_VERSION_2_31_X
+ bool "binutils version 2.31.1 support removed"
+ select BR2_LEGACY
+ help
+ Support for binutils version 2.31.1 has been removed. The
+ current default version (2.33.1 or later) has been selected
+ instead.
+
config BR2_PACKAGE_KODI_PERIPHERAL_STEAMCONTROLLER
bool "kodi-peripheral-steamcontroller package was removed"
select BR2_LEGACY
+++ /dev/null
-From ac36af7d97d7920512068316fac6159aead97a01 Mon Sep 17 00:00:00 2001
-From: Romain Naour <romain.naour@gmail.com>
-Date: Fri, 25 Dec 2015 11:38:13 +0100
-Subject: [PATCH] sh-conf
-
-Likewise, binutils has no idea about any of these new targets either, so we
-fix that up too.. now we're able to actually build a real toolchain for
-sh2a_nofpu- and other more ineptly named toolchains (and yes, there are more
-inept targets than that one, really. Go look, I promise).
-
-[Romain: rebase on top of 2.26]
-Signed-off-by: Romain Naour <romain.naour@gmail.com>
-[Thomas: rebase on top of 2.29, in which sh64 support was removed.]
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
----
- configure | 2 +-
- configure.ac | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/configure b/configure
-index 462ad053066..27cb5571d0d 100755
---- a/configure
-+++ b/configure
-@@ -3855,7 +3855,7 @@ case "${target}" in
- nvptx*-*-*)
- noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
- ;;
-- sh-*-*)
-+ sh*-*-*)
- case "${target}" in
- sh*-*-elf)
- ;;
-diff --git a/configure.ac b/configure.ac
-index a638f694134..2fd7bce1576 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1152,7 +1152,7 @@ case "${target}" in
- nvptx*-*-*)
- noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
- ;;
-- sh-*-*)
-+ sh*-*-*)
- case "${target}" in
- sh*-*-elf)
- ;;
---
-2.14.4
-
+++ /dev/null
-From 7d1e6ed1d57e839207e0ece7561bd4709032de9f Mon Sep 17 00:00:00 2001
-From: Romain Naour <romain.naour@gmail.com>
-Date: Fri, 25 Dec 2015 11:45:38 +0100
-Subject: [PATCH] poison-system-directories
-
-Patch adapted to binutils 2.23.2 and extended to use
-BR_COMPILER_PARANOID_UNSAFE_PATH by Thomas Petazzoni.
-
-[Romain: rebase on top of 2.26]
-Signed-off-by: Romain Naour <romain.naour@gmail.com>
-[Gustavo: adapt to binutils 2.25]
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
-
-Upstream-Status: Inappropriate [distribution: codesourcery]
-
-Patch originally created by Mark Hatle, forward-ported to
-binutils 2.21 by Scott Garman.
-
-purpose: warn for uses of system directories when cross linking
-
-Code Merged from Sourcery G++ binutils 2.19 - 4.4-277
-
-2008-07-02 Joseph Myers <joseph@codesourcery.com>
-
- ld/
- * ld.h (args_type): Add error_poison_system_directories.
- * ld.texinfo (--error-poison-system-directories): Document.
- * ldfile.c (ldfile_add_library_path): Check
- command_line.error_poison_system_directories.
- * ldmain.c (main): Initialize
- command_line.error_poison_system_directories.
- * lexsup.c (enum option_values): Add
- OPTION_ERROR_POISON_SYSTEM_DIRECTORIES.
- (ld_options): Add --error-poison-system-directories.
- (parse_args): Handle new option.
-
-2007-06-13 Joseph Myers <joseph@codesourcery.com>
-
- ld/
- * config.in: Regenerate.
- * ld.h (args_type): Add poison_system_directories.
- * ld.texinfo (--no-poison-system-directories): Document.
- * ldfile.c (ldfile_add_library_path): Check
- command_line.poison_system_directories.
- * ldmain.c (main): Initialize
- command_line.poison_system_directories.
- * lexsup.c (enum option_values): Add
- OPTION_NO_POISON_SYSTEM_DIRECTORIES.
- (ld_options): Add --no-poison-system-directories.
- (parse_args): Handle new option.
-
-2007-04-20 Joseph Myers <joseph@codesourcery.com>
-
- Merge from Sourcery G++ binutils 2.17:
-
- 2007-03-20 Joseph Myers <joseph@codesourcery.com>
- Based on patch by Mark Hatle <mark.hatle@windriver.com>.
- ld/
- * configure.ac (--enable-poison-system-directories): New option.
- * configure, config.in: Regenerate.
- * ldfile.c (ldfile_add_library_path): If
- ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of /lib,
- /usr/lib, /usr/local/lib or /usr/X11R6/lib.
-
-Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
-Signed-off-by: Scott Garman <scott.a.garman@intel.com>
----
- ld/config.in | 3 +++
- ld/configure | 14 ++++++++++++++
- ld/configure.ac | 10 ++++++++++
- ld/ld.h | 8 ++++++++
- ld/ld.texi | 12 ++++++++++++
- ld/ldfile.c | 17 +++++++++++++++++
- ld/ldlex.h | 2 ++
- ld/ldmain.c | 2 ++
- ld/lexsup.c | 21 +++++++++++++++++++++
- 9 files changed, 89 insertions(+)
-
-diff --git a/ld/config.in b/ld/config.in
-index d93c9b0..5da2742 100644
---- a/ld/config.in
-+++ b/ld/config.in
-@@ -31,6 +31,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 300a272..d68890f 100755
---- a/ld/configure
-+++ b/ld/configure
-@@ -822,6 +822,7 @@ with_lib_path
- enable_targets
- enable_64_bit_bfd
- with_sysroot
-+enable_poison_system_directories
- enable_gold
- enable_got
- enable_compressed_debug_sections
-@@ -1486,6 +1487,8 @@ Optional Features:
- --disable-largefile omit support for large files
- --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=<type> GOT handling scheme (target, single, negative,
- multigot)
-@@ -15803,7 +15806,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 d10c553..9f1b57b 100644
---- a/ld/configure.ac
-+++ b/ld/configure.ac
-@@ -94,6 +94,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 ba914b9..9df17da 100644
---- a/ld/ld.h
-+++ b/ld/ld.h
-@@ -180,6 +180,14 @@ typedef struct
- in the linker script. */
- bfd_boolean force_group_allocation;
-
-+ /* If TRUE (the default) warn for uses of system directories when
-+ cross linking. */
-+ bfd_boolean poison_system_directories;
-+
-+ /* If TRUE (default FALSE) give an error for uses of system
-+ directories when cross linking instead of a warning. */
-+ bfd_boolean 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 40d79dd..137d46c 100644
---- a/ld/ld.texi
-+++ b/ld/ld.texi
-@@ -2479,6 +2479,18 @@ 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 --no-poison-system-directories
-+@item --no-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 b3d166c..3dcbf66 100644
---- a/ld/ldfile.c
-+++ b/ld/ldfile.c
-@@ -116,6 +116,23 @@ ldfile_add_library_path (const char *name, bfd_boolean cmdline)
- new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL);
- else
- new_dirs->name = xstrdup (name);
-+
-+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
-+ if (command_line.poison_system_directories
-+ && ((!strncmp (name, "/lib", 4))
-+ || (!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);
-+ }
-+#endif
-+
- }
-
- /* Try to open a BFD for a lang_input_statement. */
-diff --git a/ld/ldlex.h b/ld/ldlex.h
-index 04d6fd5..d7df005 100644
---- a/ld/ldlex.h
-+++ b/ld/ldlex.h
-@@ -148,6 +148,8 @@ enum option_values
- OPTION_REQUIRE_DEFINED_SYMBOL,
- OPTION_ORPHAN_HANDLING,
- OPTION_FORCE_GROUP_ALLOCATION,
-+ OPTION_NO_POISON_SYSTEM_DIRECTORIES,
-+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES,
- };
-
- /* The initial parser states. */
-diff --git a/ld/ldmain.c b/ld/ldmain.c
-index f31eeb2..25f8497 100644
---- a/ld/ldmain.c
-+++ b/ld/ldmain.c
-@@ -268,6 +268,8 @@ main (int argc, char **argv)
- command_line.warn_mismatch = TRUE;
- command_line.warn_search_mismatch = TRUE;
- command_line.check_section_addresses = -1;
-+ command_line.poison_system_directories = TRUE;
-+ 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 86a033a..f07f095 100644
---- a/ld/lexsup.c
-+++ b/ld/lexsup.c
-@@ -543,6 +543,14 @@ static const struct ld_option ld_options[] =
- { {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
- '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
- TWO_DASHES },
-+ { {"no-poison-system-directories", no_argument, NULL,
-+ OPTION_NO_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 },
- };
-
- #define OPTION_COUNT ARRAY_SIZE (ld_options)
-@@ -555,6 +563,7 @@ parse_args (unsigned argc, char **argv)
- int ingroup = 0;
- char *default_dirlist = NULL;
- char *shortopts;
-+ char *BR_paranoid_env;
- struct option *longopts;
- struct option *really_longopts;
- int last_optind;
-@@ -1543,6 +1552,14 @@ parse_args (unsigned argc, char **argv)
- }
- break;
-
-+ case OPTION_NO_POISON_SYSTEM_DIRECTORIES:
-+ command_line.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),
-@@ -1586,6 +1603,10 @@ parse_args (unsigned argc, char **argv)
- command_line.soname = NULL;
- }
-
-+ BR_paranoid_env = getenv("BR_COMPILER_PARANOID_UNSAFE_PATH");
-+ if (BR_paranoid_env && strlen(BR_paranoid_env) > 0)
-+ command_line.error_poison_system_directories = TRUE;
-+
- while (ingroup)
- {
- lang_leave_group ();
---
-2.7.4
-
+++ /dev/null
-From d930affa2d475d1cc6792f1e6d56bef3d6c617db Mon Sep 17 00:00:00 2001
-From: Cupertino Miranda <cmiranda@synopsys.com>
-Date: Fri, 2 Mar 2018 17:16:21 +0100
-Subject: [PATCH] Refactored location where GOT information is collected.
-
-Change location where GOT information is collected for ARC target, avoiding
-posible use conflicts of the previous .got field in the symbols hash_entry.
-
-bfd/
-2018-03-01 Cupertino Miranda <cmiranda@synopsys.com>
-
- * arc-got.h (get_got_entry_list_for_symbol): Changed.
- * ef32-arc.c (struct elf_arc_link_hash_entry): Moved and changed.
- (elf_arc_link_hash_newfunc): Changed.
- (arc_elf_link_hash_table_create): Removed old initializations.
- (elf_arc_relocate_section, elf_arc_finish_dynamic_symbol): Changed.
-
-Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
-[Romain: rebase on top of 2.31]
-Signed-off-by: Romain Naour <romain.naour@gmail.com>
----
- bfd/arc-got.h | 6 +++--
- bfd/elf32-arc.c | 77 +++++++++++++++++++++++++++++++--------------------------
- 2 files changed, 46 insertions(+), 37 deletions(-)
-
-diff --git a/bfd/arc-got.h b/bfd/arc-got.h
-index a86061bcb38..81ce88fe21a 100644
---- a/bfd/arc-got.h
-+++ b/bfd/arc-got.h
-@@ -156,9 +156,11 @@ get_got_entry_list_for_symbol (bfd *abfd,
- unsigned long r_symndx,
- struct elf_link_hash_entry *h)
- {
-- if (h != NULL)
-+ struct elf_arc_link_hash_entry *h1 =
-+ ((struct elf_arc_link_hash_entry *) h);
-+ if (h1 != NULL)
- {
-- return &h->got.glist;
-+ return &h1->got_ents;
- }
- else
- {
-diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
-index a48ef0ca15f..ab84de43815 100644
---- a/bfd/elf32-arc.c
-+++ b/bfd/elf32-arc.c
-@@ -160,6 +160,18 @@ struct arc_relocation_data
- const char * symbol_name;
- };
-
-+/* ARC ELF linker hash entry. */
-+struct elf_arc_link_hash_entry
-+{
-+ struct elf_link_hash_entry root;
-+
-+ /* Track dynamic relocs copied for this symbol. */
-+ struct elf_dyn_relocs *dyn_relocs;
-+
-+ struct got_entry *got_ents;
-+};
-+
-+
- /* Should be included at this location due to static declarations
- defined before this point. */
- #include "arc-got.h"
-@@ -281,15 +293,6 @@ struct arc_reloc_map
- unsigned char elf_reloc_val;
- };
-
--/* ARC ELF linker hash entry. */
--struct elf_arc_link_hash_entry
--{
-- struct elf_link_hash_entry root;
--
-- /* Track dynamic relocs copied for this symbol. */
-- struct elf_dyn_relocs *dyn_relocs;
--};
--
- /* ARC ELF linker hash table. */
- struct elf_arc_link_hash_table
- {
-@@ -301,28 +304,28 @@ elf_arc_link_hash_newfunc (struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string)
- {
-+ struct elf_arc_link_hash_entry * ret =
-+ (struct elf_arc_link_hash_entry *) entry;
-+
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
-- if (entry == NULL)
-- {
-- entry = (struct bfd_hash_entry *)
-- bfd_hash_allocate (table,
-- sizeof (struct elf_arc_link_hash_entry));
-- if (entry == NULL)
-- return entry;
-- }
-+ if (ret == NULL)
-+ ret = (struct elf_arc_link_hash_entry *)
-+ bfd_hash_allocate (table, sizeof (struct elf_arc_link_hash_entry));
-+ if (ret == NULL)
-+ return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
-- entry = _bfd_elf_link_hash_newfunc (entry, table, string);
-- if (entry != NULL)
-+ ret = ((struct elf_arc_link_hash_entry *)
-+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
-+ table, string));
-+ if (ret != NULL)
- {
-- struct elf_arc_link_hash_entry *eh;
--
-- eh = (struct elf_arc_link_hash_entry *) entry;
-- eh->dyn_relocs = NULL;
-+ ret->dyn_relocs = NULL;
-+ ret->got_ents = NULL;
- }
-
-- return entry;
-+ return (struct bfd_hash_entry *) ret;
- }
-
- /* Destroy an ARC ELF linker hash table. */
-@@ -352,11 +355,6 @@ arc_elf_link_hash_table_create (bfd *abfd)
- return NULL;
- }
-
-- ret->elf.init_got_refcount.refcount = 0;
-- ret->elf.init_got_refcount.glist = NULL;
-- ret->elf.init_got_offset.offset = 0;
-- ret->elf.init_got_offset.glist = NULL;
--
- ret->elf.root.hash_table_free = elf_arc_link_hash_table_free;
-
- return &ret->elf.root;
-@@ -1615,10 +1613,14 @@ elf_arc_relocate_section (bfd * output_bfd,
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- {
-- struct elf_link_hash_entry *h_old = h;
-+ struct elf_arc_link_hash_entry *ah_old =
-+ (struct elf_arc_link_hash_entry *) h;
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
-- if (h->got.glist == 0 && h_old->got.glist != h->got.glist)
-- h->got.glist = h_old->got.glist;
-+ struct elf_arc_link_hash_entry *ah =
-+ (struct elf_arc_link_hash_entry *) h;
-+
-+ if (ah->got_ents == 0 && ah_old->got_ents != ah->got_ents)
-+ ah->got_ents = ah_old->got_ents;
- }
-
- /* TODO: Need to validate what was the intention. */
-@@ -1636,6 +1638,8 @@ elf_arc_relocate_section (bfd * output_bfd,
-
- if (is_reloc_for_GOT (howto) && !bfd_link_pic (info))
- {
-+ struct elf_arc_link_hash_entry *ah =
-+ (struct elf_arc_link_hash_entry *) h;
- /* TODO: Change it to use arc_do_relocation with
- ARC_32 reloc. Try to use ADD_RELA macro. */
- bfd_vma relocation =
-@@ -1645,8 +1649,8 @@ elf_arc_relocate_section (bfd * output_bfd,
- + reloc_data.sym_section->output_section->vma)
- : 0);
-
-- BFD_ASSERT (h->got.glist);
-- bfd_vma got_offset = h->got.glist->offset;
-+ BFD_ASSERT (ah->got_ents);
-+ bfd_vma got_offset = ah->got_ents->offset;
- bfd_put_32 (output_bfd, relocation,
- htab->sgot->contents + got_offset);
- }
-@@ -1958,6 +1962,7 @@ elf_arc_check_relocs (bfd * abfd,
- else /* Global one. */
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-
-+
- switch (r_type)
- {
- case R_ARC_32:
-@@ -2404,7 +2409,9 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
- create respective dynamic relocs. */
- /* TODO: Make function to get list and not access the list directly. */
- /* TODO: Move function to relocate_section create this relocs eagerly. */
-- create_got_dynrelocs_for_got_info (&h->got.glist,
-+ struct elf_arc_link_hash_entry *ah =
-+ (struct elf_arc_link_hash_entry *) h;
-+ create_got_dynrelocs_for_got_info (&ah->got_ents,
- output_bfd,
- info,
- h);
---
-2.14.4
-
+++ /dev/null
-From 955176bd999fe80c5b937ab8786665079e35c387 Mon Sep 17 00:00:00 2001
-From: Cupertino Miranda <cmiranda@synopsys.com>
-Date: Fri, 2 Mar 2018 17:33:48 +0100
-Subject: [PATCH] Improved robustness. Return FALSE in case of NULL pointer.
-
-bfd/
-2018-03-01 Cupertino Miranda <cmiranda@synopsys.com>
-
- * elf32-arc.c (elf_arc_finish_dynamic_symbol) Return FALSE in case
- arc_htab is NULL.
-
-Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
-[Romain: rebase on top of 2.31]
-Signed-off-by: Romain Naour <romain.naour@gmail.com>
----
- bfd/elf32-arc.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
-index ab84de43815..33fc72cff6e 100644
---- a/bfd/elf32-arc.c
-+++ b/bfd/elf32-arc.c
-@@ -2420,6 +2420,9 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
- {
- struct elf_arc_link_hash_table *arc_htab = elf_arc_hash_table (info);
-
-+ if(arc_htab == NULL)
-+ return FALSE;
-+
- if (h->dynindx == -1
- || (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
---
-2.14.4
-
+++ /dev/null
-From 9d09ce14b4eef2b56f24660fd69a44acd45128b2 Mon Sep 17 00:00:00 2001
-From: Cupertino Miranda <cmiranda@synopsys.com>
-Date: Fri, 2 Mar 2018 17:38:14 +0100
-Subject: [PATCH] Make sure global symbol is not an indirect or warning.
-
-Problem identified in the context of glibc with latest upstream binutils.
-Dynamic symbol space was being reserved but, no actual information for the
-symbol was being set. Data for the symbol was kept initialized with -1.
-No easy test case was possible to be created.
-
-bfd/
-2018-03-01 Cupertino Miranda <cmiranda@synopsys.com>
-
- * elf32-arc.c (elf_arc_check_relocs): Changed.
-
-Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
-[Romain: rebase on top of 2.31]
-Signed-off-by: Romain Naour <romain.naour@gmail.com>
----
- bfd/elf32-arc.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
-index 33fc72cff6e..9b72c5b4f4f 100644
---- a/bfd/elf32-arc.c
-+++ b/bfd/elf32-arc.c
-@@ -1960,7 +1960,12 @@ elf_arc_check_relocs (bfd * abfd,
- if (r_symndx < symtab_hdr->sh_info) /* Is a local symbol. */
- h = NULL;
- else /* Global one. */
-- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-+ {
-+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-+ while (h->root.type == bfd_link_hash_indirect
-+ || h->root.type == bfd_link_hash_warning)
-+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
-+ }
-
-
- switch (r_type)
---
-2.14.4
-
+++ /dev/null
-From e4861c68067cb2166b4c2bb9c052abeb6ad9aaa1 Mon Sep 17 00:00:00 2001
-From: Cupertino Miranda <cmiranda@synopsys.com>
-Date: Fri, 2 Mar 2018 17:44:29 +0100
-Subject: [PATCH] PLT information was still being generated when symbol was
- forced_local.
-
-A change upstream reveiled this issue, triggering an assert when linking glibc.
-
-bfd/
-2018-03-01 Cupertino Miranda <cmiranda@synopsys.com>
-
- * elf32-arc.c (elf_arc_check_relocs): Changed.
-
-Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
-[Romain: rebase on top of 2.31]
-Signed-off-by: Romain Naour <romain.naour@gmail.com>
----
- bfd/elf32-arc.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
-index 9b72c5b4f4f..b40b463d34d 100644
---- a/bfd/elf32-arc.c
-+++ b/bfd/elf32-arc.c
-@@ -2041,7 +2041,8 @@ elf_arc_check_relocs (bfd * abfd,
- if (h == NULL)
- continue;
- else
-- h->needs_plt = 1;
-+ if(h->forced_local == 0)
-+ h->needs_plt = 1;
- }
-
- /* Add info to the symbol got_entry_list. */
---
-2.14.4
-
+++ /dev/null
-From 5d3a462f05cba5b0c0c96de899b84fb84155c760 Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Sun, 22 Jul 2018 13:52:28 -0700
-Subject: [PATCH] xtensa: fix relaxation of undefined weak references in
- shared objects
-
-The change c451bb34ae8b ("xtensa: don't emit dynamic relocation for weak
-undefined symbol") didn't properly handle shrinking of relocation
-sections due to coalescing of references to a dynamic undefined weak
-symbol in a shared object, which resulted in the following assertion
-failure in ld when linking uClibc-ng libthread_db for xtensa:
-
- BFD (GNU Binutils) 2.31 internal error, aborting at elf32-xtensa.c:3269
- in elf_xtensa_finish_dynamic_sections
-
-Shrink dynamic relocations section for dynamic undefined weak symbols
-when linking a shared object.
-
-bfd/
-2018-07-23 Max Filippov <jcmvbkbc@gmail.com>
-
- * elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic
- relocations section for dynamic undefined weak symbols when
- linking a shared object.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-Backported from: 5d3a462f05cba5b0c0c96de899b84fb84155c760
----
- bfd/elf32-xtensa.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
-index f7f569d0c086..a4b046e445f1 100644
---- a/bfd/elf32-xtensa.c
-+++ b/bfd/elf32-xtensa.c
-@@ -10022,7 +10022,8 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
- if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
- && (input_section->flags & SEC_ALLOC) != 0
- && (dynamic_symbol || bfd_link_pic (info))
-- && (!h || h->root.type != bfd_link_hash_undefweak))
-+ && (!h || h->root.type != bfd_link_hash_undefweak
-+ || (dynamic_symbol && bfd_link_dll (info))))
- {
- asection *srel;
- bfd_boolean is_plt = FALSE;
---
-2.11.0
-
+++ /dev/null
-From f82863d797e461b936dff2b659a3aa65088ee87e Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Sun, 22 Jul 2018 18:59:11 -0700
-Subject: [PATCH] xtensa: move dynamic relocations sections consistency
- check
-
-The function elf_xtensa_finish_dynamic_sections checks that sizes of
-sections .rela.dyn and .rela.plt match number of corresponding relocation
-records, but the check is only done when .rela.plt is non-empty, so, e.g.
-it is never run for the static PIE.
-Rearrange the test so that .rela.dyn and .rela.plt are checked always.
-
-bfd/
-2018-07-23 Max Filippov <jcmvbkbc@gmail.com>
-
- * elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Move
- relocation sections consistency check to always check both
- .rela.dyn and .rela.plt when they exist. Rearrange variable
- definition and assignment places.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-Backported from: f82863d797e461b936dff2b659a3aa65088ee87e
----
- bfd/elf32-xtensa.c | 22 +++++++++++-----------
- 1 file changed, 11 insertions(+), 11 deletions(-)
-
-diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
-index a4b046e445f1..cf085b7b0751 100644
---- a/bfd/elf32-xtensa.c
-+++ b/bfd/elf32-xtensa.c
-@@ -3156,7 +3156,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
- {
- struct elf_xtensa_link_hash_table *htab;
- bfd *dynobj;
-- asection *sdyn, *srelplt, *sgot, *sxtlit, *sgotloc;
-+ asection *sdyn, *srelplt, *srelgot, *sgot, *sxtlit, *sgotloc;
- Elf32_External_Dyn *dyncon, *dynconend;
- int num_xtlit_entries = 0;
-
-@@ -3186,15 +3186,15 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
- }
-
- srelplt = htab->elf.srelplt;
-+ srelgot = htab->elf.srelgot;
- if (srelplt && srelplt->size != 0)
- {
-- asection *sgotplt, *srelgot, *spltlittbl;
-+ asection *sgotplt, *spltlittbl;
- int chunk, plt_chunks, plt_entries;
- Elf_Internal_Rela irela;
- bfd_byte *loc;
- unsigned rtld_reloc;
-
-- srelgot = htab->elf.srelgot;
- spltlittbl = htab->spltlittbl;
- BFD_ASSERT (srelgot != NULL && spltlittbl != NULL);
-
-@@ -3260,14 +3260,6 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
- spltlittbl->contents + (chunk * 8) + 4);
- }
-
-- /* All the dynamic relocations have been emitted at this point.
-- Make sure the relocation sections are the correct size. */
-- if (srelgot->size != (sizeof (Elf32_External_Rela)
-- * srelgot->reloc_count)
-- || srelplt->size != (sizeof (Elf32_External_Rela)
-- * srelplt->reloc_count))
-- abort ();
--
- /* The .xt.lit.plt section has just been modified. This must
- happen before the code below which combines adjacent literal
- table entries, and the .xt.lit.plt contents have to be forced to
-@@ -3282,6 +3274,14 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
- spltlittbl->flags &= ~SEC_HAS_CONTENTS;
- }
-
-+ /* All the dynamic relocations have been emitted at this point.
-+ Make sure the relocation sections are the correct size. */
-+ if ((srelgot && srelgot->size != (sizeof (Elf32_External_Rela)
-+ * srelgot->reloc_count))
-+ || (srelplt && srelplt->size != (sizeof (Elf32_External_Rela)
-+ * srelplt->reloc_count)))
-+ abort ();
-+
- /* Combine adjacent literal table entries. */
- BFD_ASSERT (! bfd_link_relocatable (info));
- sxtlit = bfd_get_section_by_name (output_bfd, ".xt.lit");
---
-2.11.0
-
+++ /dev/null
-From 6737a6b34f4823deb7142f27b4074831a37ac1e1 Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Fri, 20 Jul 2018 09:18:47 -0700
-Subject: [PATCH] x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed
-
-When -z separate-code, which is enabled by default for Linux/x86, is
-used to create executable, ld won't place any data in the code-only
-PT_LOAD segment. If there are no data sections placed before the
-code-only PT_LOAD segment, the program headers won't be mapped into
-any PT_LOAD segment. When the executable tries to access it (based
-on the program header address passed in AT_PHDR), it will lead to
-segfault. This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if
-there may be no data sections before the text section so that the
-first PT_LOAD segment won't be code-only and will contain the program
-header.
-
-Testcases are adjusted to either pass "-z noseparate-code" to ld or
-discard the .note.gnu.property section. A Linux/x86 run-time test is
-added.
-
-bfd/
-
- PR ld/23428
- * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the
- separate code program header is needed, make sure that the first
- read-only PT_LOAD segment has no code by adding a
- GNU_PROPERTY_X86_ISA_1_USED note.
-
-ld/
-
- PR ld/23428
- * testsuite/ld-elf/linux-x86.S: New file.
- * testsuite/ld-elf/linux-x86.exp: Likewise.
- * testsuite/ld-elf/pr23428.c: Likewise.
- * testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld
- for Linux/x86 targets.
- * testsuite/ld-i386/abs-iamcu.d: Likewise.
- * testsuite/ld-i386/abs.d: Likewise.
- * testsuite/ld-i386/pr12718.d: Likewise.
- * testsuite/ld-i386/pr12921.d: Likewise.
- * testsuite/ld-x86-64/abs-k1om.d: Likewise.
- * testsuite/ld-x86-64/abs-l1om.d: Likewise.
- * testsuite/ld-x86-64/abs.d: Likewise.
- * testsuite/ld-x86-64/pr12718.d: Likewise.
- * testsuite/ld-x86-64/pr12921.d: Likewise.
- * testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property
- section.
- * testsuite/ld-scripts/print-memory-usage.t: Likewise.
- * testsuite/ld-scripts/size-2.t: Likewise.
- * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld
- to create executable if language is "asm".
-
-(cherry picked from commit 241e64e3b42cd9eba514b8e0ad2ef39a337f10a5)
-Signed-off-by: Norbert Lange <nolange79@gmail.com>
----
- bfd/ChangeLog | 8 ++++
- bfd/elfxx-x86.c | 60 +++++++++++++++++++-------
- ld/ChangeLog | 24 +++++++++++
- ld/testsuite/ld-elf/linux-x86.S | 63 ++++++++++++++++++++++++++++
- ld/testsuite/ld-elf/linux-x86.exp | 46 ++++++++++++++++++++
- ld/testsuite/ld-elf/pr23428.c | 43 +++++++++++++++++++
- ld/testsuite/ld-elf/sec64k.exp | 2 +
- ld/testsuite/ld-i386/abs-iamcu.d | 2 +-
- ld/testsuite/ld-i386/abs.d | 2 +-
- ld/testsuite/ld-i386/pr12718.d | 2 +-
- ld/testsuite/ld-i386/pr12921.d | 2 +-
- ld/testsuite/ld-linkonce/zeroeh.ld | 1 +
- ld/testsuite/ld-scripts/print-memory-usage.t | 2 +
- ld/testsuite/ld-scripts/size-2.t | 1 +
- ld/testsuite/ld-x86-64/abs-k1om.d | 2 +-
- ld/testsuite/ld-x86-64/abs-l1om.d | 2 +-
- ld/testsuite/ld-x86-64/abs.d | 2 +-
- ld/testsuite/ld-x86-64/pr12718.d | 2 +-
- ld/testsuite/ld-x86-64/pr12921.d | 2 +-
- ld/testsuite/lib/ld-lib.exp | 5 ++-
- 20 files changed, 248 insertions(+), 25 deletions(-)
- create mode 100644 ld/testsuite/ld-elf/linux-x86.S
- create mode 100644 ld/testsuite/ld-elf/linux-x86.exp
- create mode 100644 ld/testsuite/ld-elf/pr23428.c
-
-diff --git a/bfd/ChangeLog b/bfd/ChangeLog
-index 1c1174a..d3831b7 100644
---- a/bfd/ChangeLog
-+++ b/bfd/ChangeLog
-@@ -1,3 +1,11 @@
-+2018-07-23 H.J. Lu <hongjiu.lu@intel.com>
-+
-+ PR ld/23428
-+ * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the
-+ separate code program header is needed, make sure that the first
-+ read-only PT_LOAD segment has no code by adding a
-+ GNU_PROPERTY_X86_ISA_1_USED note.
-+
- 2018-07-18 Nick Clifton <nickc@redhat.com>
-
- * development.sh: Set to true.
-diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
-index a2497aa..2e4ff88 100644
---- a/bfd/elfxx-x86.c
-+++ b/bfd/elfxx-x86.c
-@@ -2524,6 +2524,7 @@ _bfd_x86_elf_link_setup_gnu_properties
- const struct elf_backend_data *bed;
- unsigned int class_align = ABI_64_P (info->output_bfd) ? 3 : 2;
- unsigned int got_align;
-+ bfd_boolean has_text = FALSE;
-
- features = 0;
- if (info->ibt)
-@@ -2538,24 +2539,59 @@ _bfd_x86_elf_link_setup_gnu_properties
- if (bfd_get_flavour (pbfd) == bfd_target_elf_flavour
- && bfd_count_sections (pbfd) != 0)
- {
-+ if (!has_text)
-+ {
-+ /* Check if there is no non-empty text section. */
-+ sec = bfd_get_section_by_name (pbfd, ".text");
-+ if (sec != NULL && sec->size != 0)
-+ has_text = TRUE;
-+ }
-+
- ebfd = pbfd;
-
- if (elf_properties (pbfd) != NULL)
- break;
- }
-
-- if (ebfd != NULL && features)
-+ bed = get_elf_backend_data (info->output_bfd);
-+
-+ htab = elf_x86_hash_table (info, bed->target_id);
-+ if (htab == NULL)
-+ return pbfd;
-+
-+ if (ebfd != NULL)
- {
-- /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and
-- GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
-- prop = _bfd_elf_get_property (ebfd,
-- GNU_PROPERTY_X86_FEATURE_1_AND,
-- 4);
-- prop->u.number |= features;
-- prop->pr_kind = property_number;
-+ prop = NULL;
-+ if (features)
-+ {
-+ /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and
-+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
-+ prop = _bfd_elf_get_property (ebfd,
-+ GNU_PROPERTY_X86_FEATURE_1_AND,
-+ 4);
-+ prop->u.number |= features;
-+ prop->pr_kind = property_number;
-+ }
-+ else if (has_text
-+ && elf_properties (ebfd) == NULL
-+ && elf_tdata (info->output_bfd)->o->build_id.sec == NULL
-+ && !htab->elf.dynamic_sections_created
-+ && !info->traditional_format
-+ && (info->output_bfd->flags & D_PAGED) != 0
-+ && info->separate_code)
-+ {
-+ /* If the separate code program header is needed, make sure
-+ that the first read-only PT_LOAD segment has no code by
-+ adding a GNU_PROPERTY_X86_ISA_1_USED note. */
-+ prop = _bfd_elf_get_property (ebfd,
-+ GNU_PROPERTY_X86_ISA_1_USED,
-+ 4);
-+ prop->u.number = GNU_PROPERTY_X86_ISA_1_486;
-+ prop->pr_kind = property_number;
-+ }
-
- /* Create the GNU property note section if needed. */
-- if (pbfd == NULL)
-+ if (prop != NULL && pbfd == NULL)
- {
- sec = bfd_make_section_with_flags (ebfd,
- NOTE_GNU_PROPERTY_SECTION_NAME,
-@@ -2581,12 +2617,6 @@ error_alignment:
-
- pbfd = _bfd_elf_link_setup_gnu_properties (info);
-
-- bed = get_elf_backend_data (info->output_bfd);
--
-- htab = elf_x86_hash_table (info, bed->target_id);
-- if (htab == NULL)
-- return pbfd;
--
- htab->r_info = init_table->r_info;
- htab->r_sym = init_table->r_sym;
-
-diff --git a/ld/ChangeLog b/ld/ChangeLog
-index c07e442..cfadbd4 100644
---- a/ld/ChangeLog
-+++ b/ld/ChangeLog
-@@ -1,3 +1,27 @@
-+2018-07-23 H.J. Lu <hongjiu.lu@intel.com>
-+
-+ PR ld/23428
-+ * testsuite/ld-elf/linux-x86.S: New file.
-+ * testsuite/ld-elf/linux-x86.exp: Likewise.
-+ * testsuite/ld-elf/pr23428.c: Likewise.
-+ * testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld
-+ for Linux/x86 targets.
-+ * testsuite/ld-i386/abs-iamcu.d: Likewise.
-+ * testsuite/ld-i386/abs.d: Likewise.
-+ * testsuite/ld-i386/pr12718.d: Likewise.
-+ * testsuite/ld-i386/pr12921.d: Likewise.
-+ * testsuite/ld-x86-64/abs-k1om.d: Likewise.
-+ * testsuite/ld-x86-64/abs-l1om.d: Likewise.
-+ * testsuite/ld-x86-64/abs.d: Likewise.
-+ * testsuite/ld-x86-64/pr12718.d: Likewise.
-+ * testsuite/ld-x86-64/pr12921.d: Likewise.
-+ * testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property
-+ section.
-+ * testsuite/ld-scripts/print-memory-usage.t: Likewise.
-+ * testsuite/ld-scripts/size-2.t: Likewise.
-+ * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld to
-+ create executable if language is "asm".
-+
- 2018-07-18 Nick Clifton <nickc@redhat.com>
-
- 2.31.1 Release point.
-diff --git a/ld/testsuite/ld-elf/linux-x86.S b/ld/testsuite/ld-elf/linux-x86.S
-new file mode 100644
-index 0000000..bdf40c6
---- /dev/null
-+++ b/ld/testsuite/ld-elf/linux-x86.S
-@@ -0,0 +1,63 @@
-+ .text
-+ .globl _start
-+ .type _start,@function
-+ .p2align 4
-+_start:
-+ xorl %ebp, %ebp
-+#ifdef __LP64__
-+ popq %rdi
-+ movq %rsp, %rsi
-+ andq $~15, %rsp
-+#elif defined __x86_64__
-+ mov (%rsp),%edi
-+ addl $4,%esp
-+ movl %esp, %esi
-+ andl $~15, %esp
-+#else
-+ popl %esi
-+ movl %esp, %ecx
-+ andl $~15, %esp
-+
-+ subl $8,%esp
-+ pushl %ecx
-+ pushl %esi
-+#endif
-+
-+ call main
-+
-+ hlt
-+
-+ .type syscall, @function
-+ .globl syscall
-+ .p2align 4
-+syscall:
-+#ifdef __x86_64__
-+ movq %rdi, %rax /* Syscall number -> rax. */
-+ movq %rsi, %rdi /* shift arg1 - arg5. */
-+ movq %rdx, %rsi
-+ movq %rcx, %rdx
-+ movq %r8, %r10
-+ movq %r9, %r8
-+ movq 8(%rsp),%r9 /* arg6 is on the stack. */
-+ syscall /* Do the system call. */
-+#else
-+ push %ebp
-+ push %edi
-+ push %esi
-+ push %ebx
-+ mov 0x2c(%esp),%ebp
-+ mov 0x28(%esp),%edi
-+ mov 0x24(%esp),%esi
-+ mov 0x20(%esp),%edx
-+ mov 0x1c(%esp),%ecx
-+ mov 0x18(%esp),%ebx
-+ mov 0x14(%esp),%eax
-+ int $0x80
-+ pop %ebx
-+ pop %esi
-+ pop %edi
-+ pop %ebp
-+#endif
-+ ret /* Return to caller. */
-+ .size syscall, .-syscall
-+ .section .note.GNU-stack,"",@progbits
-diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
-new file mode 100644
-index 0000000..36217c6
---- /dev/null
-+++ b/ld/testsuite/ld-elf/linux-x86.exp
-@@ -0,0 +1,46 @@
-+# Expect script for simple native Linux/x86 tests.
-+# Copyright (C) 2018 Free Software Foundation, Inc.
-+#
-+# This file is part of the GNU Binutils.
-+#
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program; if not, write to the Free Software
-+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-+# MA 02110-1301, USA.
-+#
-+
-+# Test very simple native Linux/x86 programs with linux-x86.S.
-+if { ![isnative] || [which $CC] == 0 \
-+ || (![istarget "i?86-*-linux*"] \
-+ && ![istarget "x86_64-*-linux*"] \
-+ && ![istarget "amd64-*-linux*"]) } {
-+ return
-+}
-+
-+# Add $PLT_CFLAGS if PLT is expected.
-+global PLT_CFLAGS
-+# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-+global NOPIE_CFLAGS NOPIE_LDFLAGS
-+
-+run_ld_link_exec_tests [list \
-+ [list \
-+ "Run PR ld/23428 test" \
-+ "--no-dynamic-linker -z separate-code" \
-+ "" \
-+ { linux-x86.S pr23428.c } \
-+ "pr23428" \
-+ "pass.out" \
-+ "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \
-+ "asm" \
-+ ] \
-+]
-diff --git a/ld/testsuite/ld-elf/pr23428.c b/ld/testsuite/ld-elf/pr23428.c
-new file mode 100644
-index 0000000..3631ed7
---- /dev/null
-+++ b/ld/testsuite/ld-elf/pr23428.c
-@@ -0,0 +1,43 @@
-+#include <unistd.h>
-+#include <link.h>
-+#include <syscall.h>
-+
-+#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
-+
-+int
-+main (int argc, char **argv)
-+{
-+ char **ev = &argv[argc + 1];
-+ char **evp = ev;
-+ ElfW(auxv_t) *av;
-+ const ElfW(Phdr) *phdr = NULL;
-+ size_t phnum = 0;
-+ size_t loadnum = 0;
-+ int fd = STDOUT_FILENO;
-+ size_t i;
-+
-+ while (*evp++ != NULL)
-+ ;
-+
-+ av = (ElfW(auxv_t) *) evp;
-+
-+ for (; av->a_type != AT_NULL; ++av)
-+ switch (av->a_type)
-+ {
-+ case AT_PHDR:
-+ phdr = (const void *) av->a_un.a_val;
-+ break;
-+ case AT_PHNUM:
-+ phnum = av->a_un.a_val;
-+ break;
-+ }
-+
-+ for (i = 0; i < phnum; i++, phdr++)
-+ if (phdr->p_type == PT_LOAD)
-+ loadnum++;
-+
-+ syscall (SYS_write, fd, STRING_COMMA_LEN ("PASS\n"));
-+
-+ syscall (SYS_exit, !loadnum);
-+ return 0;
-+}
-diff --git a/ld/testsuite/ld-elf/sec64k.exp b/ld/testsuite/ld-elf/sec64k.exp
-index b58139e..3909c0e 100644
---- a/ld/testsuite/ld-elf/sec64k.exp
-+++ b/ld/testsuite/ld-elf/sec64k.exp
-@@ -177,6 +177,8 @@ if { ![istarget "d10v-*-*"]
- foreach sfile $sfiles { puts $ofd "#source: $sfile" }
- if { [istarget spu*-*-*] } {
- puts $ofd "#ld: --local-store 0:0"
-+ } elseif { [istarget "i?86-*-linux*"] || [istarget "x86_64-*-linux*"] } {
-+ puts $ofd "#ld: -z noseparate-code"
- } else {
- puts $ofd "#ld:"
- }
-diff --git a/ld/testsuite/ld-i386/abs-iamcu.d b/ld/testsuite/ld-i386/abs-iamcu.d
-index ac9beff..aba7d6b 100644
---- a/ld/testsuite/ld-i386/abs-iamcu.d
-+++ b/ld/testsuite/ld-i386/abs-iamcu.d
-@@ -2,7 +2,7 @@
- #source: abs.s
- #source: zero.s
- #as: --32 -march=iamcu
--#ld: -m elf_iamcu
-+#ld: -m elf_iamcu -z noseparate-code
- #objdump: -rs -j .text
-
- .*: file format .*
-diff --git a/ld/testsuite/ld-i386/abs.d b/ld/testsuite/ld-i386/abs.d
-index e660aca..191ee44 100644
---- a/ld/testsuite/ld-i386/abs.d
-+++ b/ld/testsuite/ld-i386/abs.d
-@@ -2,7 +2,7 @@
- #as: --32
- #source: abs.s
- #source: zero.s
--#ld: -melf_i386
-+#ld: -melf_i386 -z noseparate-code
- #objdump: -rs
-
- .*: file format .*
-diff --git a/ld/testsuite/ld-i386/pr12718.d b/ld/testsuite/ld-i386/pr12718.d
-index ec51540..7eba52d 100644
---- a/ld/testsuite/ld-i386/pr12718.d
-+++ b/ld/testsuite/ld-i386/pr12718.d
-@@ -1,6 +1,6 @@
- #name: PR ld/12718
- #as: --32
--#ld: -melf_i386
-+#ld: -melf_i386 -z noseparate-code
- #readelf: -S
-
- There are 5 section headers, starting at offset 0x[0-9a-f]+:
-diff --git a/ld/testsuite/ld-i386/pr12921.d b/ld/testsuite/ld-i386/pr12921.d
-index e49079b..ea2da3e 100644
---- a/ld/testsuite/ld-i386/pr12921.d
-+++ b/ld/testsuite/ld-i386/pr12921.d
-@@ -1,6 +1,6 @@
- #name: PR ld/12921
- #as: --32
--#ld: -melf_i386
-+#ld: -melf_i386 -z noseparate-code
- #readelf: -S --wide
-
- There are 7 section headers, starting at offset 0x[0-9a-f]+:
-diff --git a/ld/testsuite/ld-linkonce/zeroeh.ld b/ld/testsuite/ld-linkonce/zeroeh.ld
-index b22eaa1..f89855a 100644
---- a/ld/testsuite/ld-linkonce/zeroeh.ld
-+++ b/ld/testsuite/ld-linkonce/zeroeh.ld
-@@ -2,4 +2,5 @@ SECTIONS {
- .text 0xa00 : { *(.text); *(.gnu.linkonce.t.*) }
- .gcc_except_table 0x2000 : { *(.gcc_except_table) }
- .eh_frame 0x4000 : { *(.eh_frame) }
-+ /DISCARD/ : { *(.note.gnu.property) }
- }
-diff --git a/ld/testsuite/ld-scripts/print-memory-usage.t b/ld/testsuite/ld-scripts/print-memory-usage.t
-index 5ff057a..6eda1d2 100644
---- a/ld/testsuite/ld-scripts/print-memory-usage.t
-+++ b/ld/testsuite/ld-scripts/print-memory-usage.t
-@@ -11,4 +11,6 @@ SECTIONS
- *(.data)
- *(.rw)
- }
-+
-+ /DISCARD/ : { *(.note.gnu.property) }
- }
-diff --git a/ld/testsuite/ld-scripts/size-2.t b/ld/testsuite/ld-scripts/size-2.t
-index 7238639..c3c4edd 100644
---- a/ld/testsuite/ld-scripts/size-2.t
-+++ b/ld/testsuite/ld-scripts/size-2.t
-@@ -18,4 +18,5 @@ SECTIONS
- LONG (SIZEOF (.tdata))
- LONG (SIZEOF (.tbss))
- } :image
-+ /DISCARD/ : { *(.note.gnu.property) }
- }
-diff --git a/ld/testsuite/ld-x86-64/abs-k1om.d b/ld/testsuite/ld-x86-64/abs-k1om.d
-index 2c26639..6b0fde0 100644
---- a/ld/testsuite/ld-x86-64/abs-k1om.d
-+++ b/ld/testsuite/ld-x86-64/abs-k1om.d
-@@ -2,7 +2,7 @@
- #source: ../ld-i386/abs.s
- #source: ../ld-i386/zero.s
- #as: --64 -march=k1om
--#ld: -m elf_k1om
-+#ld: -m elf_k1om -z noseparate-code
- #objdump: -rs -j .text
-
- .*: file format .*
-diff --git a/ld/testsuite/ld-x86-64/abs-l1om.d b/ld/testsuite/ld-x86-64/abs-l1om.d
-index 1fb96d4..f87869f 100644
---- a/ld/testsuite/ld-x86-64/abs-l1om.d
-+++ b/ld/testsuite/ld-x86-64/abs-l1om.d
-@@ -2,7 +2,7 @@
- #source: ../ld-i386/abs.s
- #source: ../ld-i386/zero.s
- #as: --64 -march=l1om
--#ld: -m elf_l1om
-+#ld: -m elf_l1om -z noseparate-code
- #objdump: -rs -j .text
- #target: x86_64-*-linux*
-
-diff --git a/ld/testsuite/ld-x86-64/abs.d b/ld/testsuite/ld-x86-64/abs.d
-index b24b018..d99ab46 100644
---- a/ld/testsuite/ld-x86-64/abs.d
-+++ b/ld/testsuite/ld-x86-64/abs.d
-@@ -1,7 +1,7 @@
- #name: Absolute non-overflowing relocs
- #source: ../ld-i386/abs.s
- #source: ../ld-i386/zero.s
--#ld:
-+#ld: -z noseparate-code
- #objdump: -rs
-
- .*: file format .*
-diff --git a/ld/testsuite/ld-x86-64/pr12718.d b/ld/testsuite/ld-x86-64/pr12718.d
-index 07d1732..2c503ff 100644
---- a/ld/testsuite/ld-x86-64/pr12718.d
-+++ b/ld/testsuite/ld-x86-64/pr12718.d
-@@ -1,6 +1,6 @@
- #name: PR ld/12718
- #as: --64
--#ld: -melf_x86_64
-+#ld: -melf_x86_64 -z noseparate-code
- #readelf: -S --wide
-
- There are 5 section headers, starting at offset 0x[0-9a-f]+:
-diff --git a/ld/testsuite/ld-x86-64/pr12921.d b/ld/testsuite/ld-x86-64/pr12921.d
-index 6fe6abe..1162d55 100644
---- a/ld/testsuite/ld-x86-64/pr12921.d
-+++ b/ld/testsuite/ld-x86-64/pr12921.d
-@@ -1,6 +1,6 @@
- #name: PR ld/12921
- #as: --64
--#ld: -melf_x86_64
-+#ld: -melf_x86_64 -z noseparate-code
- #readelf: -S --wide
-
- There are 7 section headers, starting at offset 0x[0-9a-f]+:
-diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
-index cfbefe9..1095091 100644
---- a/ld/testsuite/lib/ld-lib.exp
-+++ b/ld/testsuite/lib/ld-lib.exp
-@@ -1482,7 +1482,10 @@ proc run_ld_link_exec_tests { ldtests args } {
- continue
- }
-
-- if { [ string match "c++" $lang ] } {
-+ if { [ string match "asm" $lang ] } {
-+ set link_proc ld_link
-+ set link_cmd $ld
-+ } elseif { [ string match "c++" $lang ] } {
- set link_proc ld_link
- set link_cmd $CXX
- } else {
---
-2.9.3
-
+++ /dev/null
-From d55c3e36094f06bb1fb02f5eac19fdccf1d91f7e Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Wed, 8 Aug 2018 06:09:15 -0700
-Subject: [PATCH] x86: Properly merge GNU_PROPERTY_X86_ISA_1_USED
-MIME-Version: 1.0
-Content-Type: text/plain; charset=utf8
-Content-Transfer-Encoding: 8bit
-
-Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used.
-If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the
-corresponding x86 instruction set isnâ\80\99t used. When merging properties
-from 2 input files and one input file doesn't have the
-GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have
-it neither. This patch removes the GNU_PROPERTY_X86_ISA_1_USED
-property if an input file doesn't have it.
-
-This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the
-GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA
-requirement.
-
-bfd/
-
- PR ld/23486
- * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove
- GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it.
- (_bfd_x86_elf_link_setup_gnu_properties): Adding the
- GNU_PROPERTY_X86_ISA_1_NEEDED, instead of
- GNU_PROPERTY_X86_ISA_1_USED, property.
-
-ld/
-
- PR ld/23486
- * testsuite/ld-i386/i386.exp: Run PR ld/23486 tests.
- * testsuite/ld-x86-64/x86-64.exp: Likewise.
- * testsuite/ld-i386/pr23486a.d: New file.
- * testsuite/ld-i386/pr23486b.d: Likewise.
- * testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
- * testsuite/ld-x86-64/pr23486a.d: Likewise.
- * testsuite/ld-x86-64/pr23486a.s: Likewise.
- * testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
- * testsuite/ld-x86-64/pr23486b.d: Likewise.
- * testsuite/ld-x86-64/pr23486b.s: Likewise.
- * testsuite/ld-i386/property-3.r: Remove "x86 ISA used".
- * testsuite/ld-i386/property-4.r: Likewise.
- * testsuite/ld-i386/property-5.r: Likewise.
- * testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
- * testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
- * testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
- * testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
- * testsuite/ld-x86-64/property-3.r: Likewise.
- * testsuite/ld-x86-64/property-4.r: Likewise.
- * testsuite/ld-x86-64/property-5.r: Likewise.
- * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
- * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
- * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
- * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
- * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
- * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
- * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
- * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
-
-(cherry picked from commit f7309df20c4e787041cedc4a6aced89c15259e54)
-Signed-off-by: Norbert Lange <nolange79@gmail.com>
----
- bfd/ChangeLog | 9 +++++++
- bfd/elfxx-x86.c | 25 ++++++++++++++----
- ld/ChangeLog | 32 +++++++++++++++++++++++
- ld/testsuite/ld-i386/i386.exp | 2 ++
- ld/testsuite/ld-i386/pr23486a.d | 10 +++++++
- ld/testsuite/ld-i386/pr23486b.d | 10 +++++++
- ld/testsuite/ld-i386/property-3.r | 1 -
- ld/testsuite/ld-i386/property-4.r | 1 -
- ld/testsuite/ld-i386/property-5.r | 1 -
- ld/testsuite/ld-i386/property-x86-ibt3a.d | 5 ++--
- ld/testsuite/ld-i386/property-x86-ibt3b.d | 5 ++--
- ld/testsuite/ld-i386/property-x86-shstk3a.d | 5 ++--
- ld/testsuite/ld-i386/property-x86-shstk3b.d | 5 ++--
- ld/testsuite/ld-x86-64/pr23486a-x32.d | 10 +++++++
- ld/testsuite/ld-x86-64/pr23486a.d | 10 +++++++
- ld/testsuite/ld-x86-64/pr23486a.s | 30 +++++++++++++++++++++
- ld/testsuite/ld-x86-64/pr23486b-x32.d | 10 +++++++
- ld/testsuite/ld-x86-64/pr23486b.d | 10 +++++++
- ld/testsuite/ld-x86-64/pr23486b.s | 30 +++++++++++++++++++++
- ld/testsuite/ld-x86-64/property-3.r | 1 -
- ld/testsuite/ld-x86-64/property-4.r | 1 -
- ld/testsuite/ld-x86-64/property-5.r | 1 -
- ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-ibt3a.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-ibt3b.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-shstk3a.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d | 5 ++--
- ld/testsuite/ld-x86-64/property-x86-shstk3b.d | 5 ++--
- ld/testsuite/ld-x86-64/x86-64.exp | 4 +++
- 31 files changed, 211 insertions(+), 47 deletions(-)
- create mode 100644 ld/testsuite/ld-i386/pr23486a.d
- create mode 100644 ld/testsuite/ld-i386/pr23486b.d
- create mode 100644 ld/testsuite/ld-x86-64/pr23486a-x32.d
- create mode 100644 ld/testsuite/ld-x86-64/pr23486a.d
- create mode 100644 ld/testsuite/ld-x86-64/pr23486a.s
- create mode 100644 ld/testsuite/ld-x86-64/pr23486b-x32.d
- create mode 100644 ld/testsuite/ld-x86-64/pr23486b.d
- create mode 100644 ld/testsuite/ld-x86-64/pr23486b.s
-
-diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
-index 2e4ff88..7ccfd25 100644
---- a/bfd/elfxx-x86.c
-+++ b/bfd/elfxx-x86.c
-@@ -2407,12 +2407,27 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
- switch (pr_type)
- {
- case GNU_PROPERTY_X86_ISA_1_USED:
-+ if (aprop == NULL || bprop == NULL)
-+ {
-+ /* Only one of APROP and BPROP can be NULL. */
-+ if (aprop != NULL)
-+ {
-+ /* Remove this property since the other input file doesn't
-+ have it. */
-+ aprop->pr_kind = property_remove;
-+ updated = TRUE;
-+ }
-+ break;
-+ }
-+ goto or_property;
-+
- case GNU_PROPERTY_X86_ISA_1_NEEDED:
- if (aprop != NULL && bprop != NULL)
- {
-+or_property:
- number = aprop->u.number;
- aprop->u.number = number | bprop->u.number;
-- /* Remove the property if ISA bits are empty. */
-+ /* Remove the property if all bits are empty. */
- if (aprop->u.number == 0)
- {
- aprop->pr_kind = property_remove;
-@@ -2428,14 +2443,14 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
- {
- if (aprop->u.number == 0)
- {
-- /* Remove APROP if ISA bits are empty. */
-+ /* Remove APROP if all bits are empty. */
- aprop->pr_kind = property_remove;
- updated = TRUE;
- }
- }
- else
- {
-- /* Return TRUE if APROP is NULL and ISA bits of BPROP
-+ /* Return TRUE if APROP is NULL and all bits of BPROP
- aren't empty to indicate that BPROP should be added
- to ABFD. */
- updated = bprop->u.number != 0;
-@@ -2582,9 +2597,9 @@ _bfd_x86_elf_link_setup_gnu_properties
- {
- /* If the separate code program header is needed, make sure
- that the first read-only PT_LOAD segment has no code by
-- adding a GNU_PROPERTY_X86_ISA_1_USED note. */
-+ adding a GNU_PROPERTY_X86_ISA_1_NEEDED note. */
- prop = _bfd_elf_get_property (ebfd,
-- GNU_PROPERTY_X86_ISA_1_USED,
-+ GNU_PROPERTY_X86_ISA_1_NEEDED,
- 4);
- prop->u.number = GNU_PROPERTY_X86_ISA_1_486;
- prop->pr_kind = property_number;
-diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
-index 6d794fe..78dad02 100644
---- a/ld/testsuite/ld-i386/i386.exp
-+++ b/ld/testsuite/ld-i386/i386.exp
-@@ -462,6 +462,8 @@ run_dump_test "pr23189"
- run_dump_test "pr23194"
- run_dump_test "pr23372a"
- run_dump_test "pr23372b"
-+run_dump_test "pr23486a"
-+run_dump_test "pr23486b"
-
- if { !([istarget "i?86-*-linux*"]
- || [istarget "i?86-*-gnu*"]
-diff --git a/ld/testsuite/ld-i386/pr23486a.d b/ld/testsuite/ld-i386/pr23486a.d
-new file mode 100644
-index 0000000..41a6dcf
---- /dev/null
-+++ b/ld/testsuite/ld-i386/pr23486a.d
-@@ -0,0 +1,10 @@
-+#source: ../ld-x86-64/pr23486a.s
-+#source: ../ld-x86-64/pr23486b.s
-+#as: --32
-+#ld: -r -m elf_i386
-+#readelf: -n
-+
-+Displaying notes found in: .note.gnu.property
-+ Owner Data size Description
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586
-diff --git a/ld/testsuite/ld-i386/pr23486b.d b/ld/testsuite/ld-i386/pr23486b.d
-new file mode 100644
-index 0000000..08019b7
---- /dev/null
-+++ b/ld/testsuite/ld-i386/pr23486b.d
-@@ -0,0 +1,10 @@
-+#source: ../ld-x86-64/pr23486b.s
-+#source: ../ld-x86-64/pr23486a.s
-+#as: --32
-+#ld: -r -m elf_i386
-+#readelf: -n
-+
-+Displaying notes found in: .note.gnu.property
-+ Owner Data size Description
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586
-diff --git a/ld/testsuite/ld-i386/property-3.r b/ld/testsuite/ld-i386/property-3.r
-index 0ed91f5..d03203c 100644
---- a/ld/testsuite/ld-i386/property-3.r
-+++ b/ld/testsuite/ld-i386/property-3.r
-@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
- Owner Data size Description
- GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
- Properties: stack size: 0x800000
-- x86 ISA used: 586, SSE
- x86 ISA needed: i486, 586
- #pass
-diff --git a/ld/testsuite/ld-i386/property-4.r b/ld/testsuite/ld-i386/property-4.r
-index cb2bc15..da295eb 100644
---- a/ld/testsuite/ld-i386/property-4.r
-+++ b/ld/testsuite/ld-i386/property-4.r
-@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
- Owner Data size Description
- GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
- Properties: stack size: 0x800000
-- x86 ISA used: i486, 586, SSE
- x86 ISA needed: i486, 586, SSE
- #pass
-diff --git a/ld/testsuite/ld-i386/property-5.r b/ld/testsuite/ld-i386/property-5.r
-index 5529650..e414159 100644
---- a/ld/testsuite/ld-i386/property-5.r
-+++ b/ld/testsuite/ld-i386/property-5.r
-@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
- Owner Data size Description
- GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
- Properties: stack size: 0x900000
-- x86 ISA used: i486, 586, SSE
- x86 ISA needed: i486, 586, SSE
- #pass
-diff --git a/ld/testsuite/ld-i386/property-x86-ibt3a.d b/ld/testsuite/ld-i386/property-x86-ibt3a.d
-index 4bb35b0..0aedea1 100644
---- a/ld/testsuite/ld-i386/property-x86-ibt3a.d
-+++ b/ld/testsuite/ld-i386/property-x86-ibt3a.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: i486, 586, SSE2, SSE3
-- x86 ISA needed: 586, SSE, SSE3, SSE4_1
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
-diff --git a/ld/testsuite/ld-i386/property-x86-ibt3b.d b/ld/testsuite/ld-i386/property-x86-ibt3b.d
-index 418d58a..bd69ac6 100644
---- a/ld/testsuite/ld-i386/property-x86-ibt3b.d
-+++ b/ld/testsuite/ld-i386/property-x86-ibt3b.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: i486, 586, SSE2, SSE3
-- x86 ISA needed: 586, SSE, SSE3, SSE4_1
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
-diff --git a/ld/testsuite/ld-i386/property-x86-shstk3a.d b/ld/testsuite/ld-i386/property-x86-shstk3a.d
-index e261038..76d2a39 100644
---- a/ld/testsuite/ld-i386/property-x86-shstk3a.d
-+++ b/ld/testsuite/ld-i386/property-x86-shstk3a.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: i486, 586, SSE2, SSE3
-- x86 ISA needed: 586, SSE, SSE3, SSE4_1
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
-diff --git a/ld/testsuite/ld-i386/property-x86-shstk3b.d b/ld/testsuite/ld-i386/property-x86-shstk3b.d
-index 25f3d23..e770ecf 100644
---- a/ld/testsuite/ld-i386/property-x86-shstk3b.d
-+++ b/ld/testsuite/ld-i386/property-x86-shstk3b.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: i486, 586, SSE2, SSE3
-- x86 ISA needed: 586, SSE, SSE3, SSE4_1
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
-diff --git a/ld/testsuite/ld-x86-64/pr23486a-x32.d b/ld/testsuite/ld-x86-64/pr23486a-x32.d
-new file mode 100644
-index 0000000..6d9fa68
---- /dev/null
-+++ b/ld/testsuite/ld-x86-64/pr23486a-x32.d
-@@ -0,0 +1,10 @@
-+#source: pr23486a.s
-+#source: pr23486b.s
-+#as: --x32
-+#ld: -r -m elf32_x86_64
-+#readelf: -n
-+
-+Displaying notes found in: .note.gnu.property
-+ Owner Data size Description
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586
-diff --git a/ld/testsuite/ld-x86-64/pr23486a.d b/ld/testsuite/ld-x86-64/pr23486a.d
-new file mode 100644
-index 0000000..dc2b7bf
---- /dev/null
-+++ b/ld/testsuite/ld-x86-64/pr23486a.d
-@@ -0,0 +1,10 @@
-+#source: pr23486a.s
-+#source: pr23486b.s
-+#as: --64 -defsym __64_bit__=1
-+#ld: -r -m elf_x86_64
-+#readelf: -n
-+
-+Displaying notes found in: .note.gnu.property
-+ Owner Data size Description
-+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586
-diff --git a/ld/testsuite/ld-x86-64/pr23486a.s b/ld/testsuite/ld-x86-64/pr23486a.s
-new file mode 100644
-index 0000000..a07d0c7
---- /dev/null
-+++ b/ld/testsuite/ld-x86-64/pr23486a.s
-@@ -0,0 +1,30 @@
-+ .section ".note.gnu.property", "a"
-+.ifdef __64_bit__
-+ .p2align 3
-+.else
-+ .p2align 2
-+.endif
-+ .long 1f - 0f /* name length. */
-+ .long 4f - 1f /* data length. */
-+ /* NT_GNU_PROPERTY_TYPE_0 */
-+ .long 5 /* note type. */
-+0:
-+ .asciz "GNU" /* vendor name. */
-+1:
-+.ifdef __64_bit__
-+ .p2align 3
-+.else
-+ .p2align 2
-+.endif
-+ /* GNU_PROPERTY_X86_ISA_1_USED */
-+ .long 0xc0000000 /* pr_type. */
-+ .long 3f - 2f /* pr_datasz. */
-+2:
-+ .long 0xa
-+3:
-+.ifdef __64_bit__
-+ .p2align 3
-+.else
-+ .p2align 2
-+.endif
-+4:
-diff --git a/ld/testsuite/ld-x86-64/pr23486b-x32.d b/ld/testsuite/ld-x86-64/pr23486b-x32.d
-new file mode 100644
-index 0000000..0445e69
---- /dev/null
-+++ b/ld/testsuite/ld-x86-64/pr23486b-x32.d
-@@ -0,0 +1,10 @@
-+#source: pr23486b.s
-+#source: pr23486a.s
-+#as: --x32
-+#ld: -r -m elf32_x86_64
-+#readelf: -n
-+
-+Displaying notes found in: .note.gnu.property
-+ Owner Data size Description
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586
-diff --git a/ld/testsuite/ld-x86-64/pr23486b.d b/ld/testsuite/ld-x86-64/pr23486b.d
-new file mode 100644
-index 0000000..dc2b7bf
---- /dev/null
-+++ b/ld/testsuite/ld-x86-64/pr23486b.d
-@@ -0,0 +1,10 @@
-+#source: pr23486a.s
-+#source: pr23486b.s
-+#as: --64 -defsym __64_bit__=1
-+#ld: -r -m elf_x86_64
-+#readelf: -n
-+
-+Displaying notes found in: .note.gnu.property
-+ Owner Data size Description
-+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586
-diff --git a/ld/testsuite/ld-x86-64/pr23486b.s b/ld/testsuite/ld-x86-64/pr23486b.s
-new file mode 100644
-index 0000000..c5167ee
---- /dev/null
-+++ b/ld/testsuite/ld-x86-64/pr23486b.s
-@@ -0,0 +1,30 @@
-+ .section ".note.gnu.property", "a"
-+.ifdef __64_bit__
-+ .p2align 3
-+.else
-+ .p2align 2
-+.endif
-+ .long 1f - 0f /* name length. */
-+ .long 4f - 1f /* data length. */
-+ /* NT_GNU_PROPERTY_TYPE_0 */
-+ .long 5 /* note type. */
-+0:
-+ .asciz "GNU" /* vendor name. */
-+1:
-+.ifdef __64_bit__
-+ .p2align 3
-+.else
-+ .p2align 2
-+.endif
-+ /* GNU_PROPERTY_X86_ISA_1_NEEDED */
-+ .long 0xc0000001 /* pr_type. */
-+ .long 3f - 2f /* pr_datasz. */
-+2:
-+ .long 0x3
-+3:
-+.ifdef __64_bit__
-+ .p2align 3
-+.else
-+ .p2align 2
-+.endif
-+4:
-diff --git a/ld/testsuite/ld-x86-64/property-3.r b/ld/testsuite/ld-x86-64/property-3.r
-index 0ed91f5..d03203c 100644
---- a/ld/testsuite/ld-x86-64/property-3.r
-+++ b/ld/testsuite/ld-x86-64/property-3.r
-@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
- Owner Data size Description
- GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
- Properties: stack size: 0x800000
-- x86 ISA used: 586, SSE
- x86 ISA needed: i486, 586
- #pass
-diff --git a/ld/testsuite/ld-x86-64/property-4.r b/ld/testsuite/ld-x86-64/property-4.r
-index cb2bc15..da295eb 100644
---- a/ld/testsuite/ld-x86-64/property-4.r
-+++ b/ld/testsuite/ld-x86-64/property-4.r
-@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
- Owner Data size Description
- GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
- Properties: stack size: 0x800000
-- x86 ISA used: i486, 586, SSE
- x86 ISA needed: i486, 586, SSE
- #pass
-diff --git a/ld/testsuite/ld-x86-64/property-5.r b/ld/testsuite/ld-x86-64/property-5.r
-index 5529650..e414159 100644
---- a/ld/testsuite/ld-x86-64/property-5.r
-+++ b/ld/testsuite/ld-x86-64/property-5.r
-@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
- Owner Data size Description
- GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
- Properties: stack size: 0x900000
-- x86 ISA used: i486, 586, SSE
- x86 ISA needed: i486, 586, SSE
- #pass
-diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
-index 011426f..4cec728 100644
---- a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
-index 1b4229a..a8df49a 100644
---- a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
-index 290ed6a..c112626 100644
---- a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
-index 1142e03..f10dffd 100644
---- a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d
-index 819542d..0147a3c 100644
---- a/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3a.d b/ld/testsuite/ld-x86-64/property-x86-shstk3a.d
-index 4c5d0e0..1f8c2dc 100644
---- a/ld/testsuite/ld-x86-64/property-x86-shstk3a.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3a.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d
-index ba181e0..7ca2539 100644
---- a/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3b.d b/ld/testsuite/ld-x86-64/property-x86-shstk3b.d
-index 5216f38..f66a40e 100644
---- a/ld/testsuite/ld-x86-64/property-x86-shstk3b.d
-+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3b.d
-@@ -6,6 +6,5 @@
-
- Displaying notes found in: .note.gnu.property
- Owner Data size Description
-- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
-- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-- x86 ISA needed: i486, 586, SSE2, SSE3
-+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
-+ Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
-index 6edb9e8..ae21e55 100644
---- a/ld/testsuite/ld-x86-64/x86-64.exp
-+++ b/ld/testsuite/ld-x86-64/x86-64.exp
-@@ -403,6 +403,10 @@ run_dump_test "pr23372a"
- run_dump_test "pr23372a-x32"
- run_dump_test "pr23372b"
- run_dump_test "pr23372b-x32"
-+run_dump_test "pr23486a"
-+run_dump_test "pr23486a-x32"
-+run_dump_test "pr23486b"
-+run_dump_test "pr23486b-x32"
-
- if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
- return
---
-2.9.3
-
+++ /dev/null
-From 28a27bdbb9500797e6767f80c8128b09112aeed5 Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Sat, 11 Aug 2018 06:41:33 -0700
-Subject: [PATCH] x86: Properly add X86_ISA_1_NEEDED property
-
-Existing properties may be removed during property merging. We avoid
-adding X86_ISA_1_NEEDED property only if existing properties won't be
-removed.
-
-bfd/
-
- PR ld/23428
- * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't
- add X86_ISA_1_NEEDED property only if existing properties won't
- be removed.
-
-ld/
-
- PR ld/23428
- * testsuite/ld-elf/dummy.s: New file.
- * testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property.
- * testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428.
-
-(cherry picked from commit ab9e342807d132182892de1be1a92d6e91a5c1da)
-Signed-off-by: Norbert Lange <nolange79@gmail.com>
----
- bfd/ChangeLog | 7 +++++++
- bfd/elfxx-x86.c | 28 ++++++++++++++++++++++------
- ld/ChangeLog | 7 +++++++
- ld/testsuite/ld-elf/dummy.s | 1 +
- ld/testsuite/ld-elf/linux-x86.S | 28 ++++++++++++++++++++++++++++
- ld/testsuite/ld-elf/linux-x86.exp | 2 +-
- 6 files changed, 66 insertions(+), 7 deletions(-)
- create mode 100644 ld/testsuite/ld-elf/dummy.s
-
-diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
-index 7ccfd25..2d8f7b6 100644
---- a/bfd/elfxx-x86.c
-+++ b/bfd/elfxx-x86.c
-@@ -2588,7 +2588,6 @@ _bfd_x86_elf_link_setup_gnu_properties
- prop->pr_kind = property_number;
- }
- else if (has_text
-- && elf_properties (ebfd) == NULL
- && elf_tdata (info->output_bfd)->o->build_id.sec == NULL
- && !htab->elf.dynamic_sections_created
- && !info->traditional_format
-@@ -2598,11 +2597,28 @@ _bfd_x86_elf_link_setup_gnu_properties
- /* If the separate code program header is needed, make sure
- that the first read-only PT_LOAD segment has no code by
- adding a GNU_PROPERTY_X86_ISA_1_NEEDED note. */
-- prop = _bfd_elf_get_property (ebfd,
-- GNU_PROPERTY_X86_ISA_1_NEEDED,
-- 4);
-- prop->u.number = GNU_PROPERTY_X86_ISA_1_486;
-- prop->pr_kind = property_number;
-+ elf_property_list *list;
-+ bfd_boolean need_property = TRUE;
-+
-+ for (list = elf_properties (ebfd); list; list = list->next)
-+ switch (list->property.pr_type)
-+ {
-+ case GNU_PROPERTY_STACK_SIZE:
-+ case GNU_PROPERTY_NO_COPY_ON_PROTECTED:
-+ case GNU_PROPERTY_X86_ISA_1_NEEDED:
-+ /* These properties won't be removed during merging. */
-+ need_property = FALSE;
-+ break;
-+ }
-+
-+ if (need_property)
-+ {
-+ prop = _bfd_elf_get_property (ebfd,
-+ GNU_PROPERTY_X86_ISA_1_NEEDED,
-+ 4);
-+ prop->u.number = GNU_PROPERTY_X86_ISA_1_486;
-+ prop->pr_kind = property_number;
-+ }
- }
-
- /* Create the GNU property note section if needed. */
-diff --git a/ld/testsuite/ld-elf/dummy.s b/ld/testsuite/ld-elf/dummy.s
-new file mode 100644
-index 0000000..403f980
---- /dev/null
-+++ b/ld/testsuite/ld-elf/dummy.s
-@@ -0,0 +1 @@
-+# Dummy
-diff --git a/ld/testsuite/ld-elf/linux-x86.S b/ld/testsuite/ld-elf/linux-x86.S
-index bdf40c6..d94abc1 100644
---- a/ld/testsuite/ld-elf/linux-x86.S
-+++ b/ld/testsuite/ld-elf/linux-x86.S
-@@ -61,3 +61,31 @@ syscall:
- ret /* Return to caller. */
- .size syscall, .-syscall
- .section .note.GNU-stack,"",@progbits
-+
-+ .section ".note.gnu.property", "a"
-+#ifdef __LP64__
-+ .p2align 3
-+#else
-+ .p2align 2
-+#endif
-+ .long 1f - 0f /* name length */
-+ .long 5f - 2f /* data length */
-+ .long 5 /* note type */
-+0: .asciz "GNU" /* vendor name */
-+1:
-+#ifdef __LP64__
-+ .p2align 3
-+#else
-+ .p2align 2
-+#endif
-+2: .long 0xc0000002 /* pr_type. */
-+ .long 4f - 3f /* pr_datasz. */
-+3:
-+ .long 0x2
-+4:
-+#ifdef __LP64__
-+ .p2align 3
-+#else
-+ .p2align 2
-+#endif
-+5:
-diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
-index 36217c6..f6f5a80 100644
---- a/ld/testsuite/ld-elf/linux-x86.exp
-+++ b/ld/testsuite/ld-elf/linux-x86.exp
-@@ -37,7 +37,7 @@ run_ld_link_exec_tests [list \
- "Run PR ld/23428 test" \
- "--no-dynamic-linker -z separate-code" \
- "" \
-- { linux-x86.S pr23428.c } \
-+ { linux-x86.S pr23428.c dummy.s } \
- "pr23428" \
- "pass.out" \
- "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \
---
-2.9.3
-
+++ /dev/null
-From 278989f23735aa501be1052e085540c75c126dbb Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Thu, 28 Mar 2019 17:03:57 -0700
-Subject: [PATCH] bfd: xtensa: fix shrink_dynamic_reloc_sections for
- export-dynamic
-
-shrink_dynamic_reloc_sections must remove PLT entry that was created for
-an undefined weak symbol in the presence of --export-dynamic option when
-relaxation coalesces literals pointing to that symbol. This fixes the
-following assertion:
-
- ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at
- elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections
-
-2019-03-28 Max Filippov <jcmvbkbc@gmail.com>
-bfd/
- * elf32-xtensa.c (shrink_dynamic_reloc_sections): Add
- info->export_dynamic to the conditional.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
----
- bfd/elf32-xtensa.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
-index c3df3d6db756..37ea200eea74 100644
---- a/bfd/elf32-xtensa.c
-+++ b/bfd/elf32-xtensa.c
-@@ -10083,7 +10083,8 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
- && (input_section->flags & SEC_ALLOC) != 0
- && (dynamic_symbol || bfd_link_pic (info))
- && (!h || h->root.type != bfd_link_hash_undefweak
-- || (dynamic_symbol && bfd_link_dll (info))))
-+ || (dynamic_symbol
-+ && (bfd_link_dll (info) || info->export_dynamic))))
- {
- asection *srel;
- bfd_boolean is_plt = FALSE;
---
-2.11.0
-
+++ /dev/null
-From 0dbdfb7918d0b0cfcb8883b24c1291574bf5bb7c Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Tue, 2 Apr 2019 14:32:42 -0700
-Subject: [PATCH] gas: use literals/const16 for xtensa loop relaxation
-
-Loop opcode relaxation that uses addi/addmi doesn't work well with other
-relaxations that may cause code movement. Instead of encoding fixed loop
-end offset in the relaxed sequence use l32r or a pair of const16 to load
-loop end address. This way the address of the loop end gets a relocation
-record and it gets updated appropriately.
-
-gas/
-2019-04-02 Max Filippov <jcmvbkbc@gmail.com>
-
- * config/tc-xtensa.c (convert_frag_immed): Drop
- convert_frag_immed_finish_loop invocation.
- (convert_frag_immed_finish_loop): Drop declaration and
- definition.
- * config/xtensa-relax.c (widen_spec_list): Replace loop
- widening that uses addi/addmi with widening that uses l32r
- and const16.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
----
- gas/config/tc-xtensa.c | 120 ----------------------------------------------
- gas/config/xtensa-relax.c | 77 ++++++++++++++++++++---------
- 2 files changed, 55 insertions(+), 142 deletions(-)
-
-diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
-index 3bdbbc931cfc..0cc06361cf6f 100644
---- a/gas/config/tc-xtensa.c
-+++ b/gas/config/tc-xtensa.c
-@@ -10668,7 +10668,6 @@ convert_frag_fill_nop (fragS *fragP)
- static fixS *fix_new_exp_in_seg
- (segT, subsegT, fragS *, int, int, expressionS *, int,
- bfd_reloc_code_real_type);
--static void convert_frag_immed_finish_loop (segT, fragS *, TInsn *);
-
- static void
- convert_frag_immed (segT segP,
-@@ -10910,9 +10909,6 @@ convert_frag_immed (segT segP,
- }
- }
-
-- if (expanded && xtensa_opcode_is_loop (isa, orig_tinsn.opcode) == 1)
-- convert_frag_immed_finish_loop (segP, fragP, &orig_tinsn);
--
- if (expanded && is_direct_call_opcode (orig_tinsn.opcode))
- {
- /* Add an expansion note on the expanded instruction. */
-@@ -10949,122 +10945,6 @@ fix_new_exp_in_seg (segT new_seg,
- }
-
-
--/* Relax a loop instruction so that it can span loop >256 bytes.
--
-- loop as, .L1
-- .L0:
-- rsr as, LEND
-- wsr as, LBEG
-- addi as, as, lo8 (label-.L1)
-- addmi as, as, mid8 (label-.L1)
-- wsr as, LEND
-- isync
-- rsr as, LCOUNT
-- addi as, as, 1
-- .L1:
-- <<body>>
-- label:
--*/
--
--static void
--convert_frag_immed_finish_loop (segT segP, fragS *fragP, TInsn *tinsn)
--{
-- TInsn loop_insn;
-- TInsn addi_insn;
-- TInsn addmi_insn;
-- unsigned long target;
-- static xtensa_insnbuf insnbuf = NULL;
-- unsigned int loop_length, loop_length_hi, loop_length_lo;
-- xtensa_isa isa = xtensa_default_isa;
-- addressT loop_offset;
-- addressT addi_offset = 9;
-- addressT addmi_offset = 12;
-- fragS *next_fragP;
-- int target_count;
--
-- if (!insnbuf)
-- insnbuf = xtensa_insnbuf_alloc (isa);
--
-- /* Get the loop offset. */
-- loop_offset = get_expanded_loop_offset (tinsn->opcode);
--
-- /* Validate that there really is a LOOP at the loop_offset. Because
-- loops are not bundleable, we can assume that the instruction will be
-- in slot 0. */
-- tinsn_from_chars (&loop_insn, fragP->fr_opcode + loop_offset, 0);
-- tinsn_immed_from_frag (&loop_insn, fragP, 0);
--
-- gas_assert (xtensa_opcode_is_loop (isa, loop_insn.opcode) == 1);
-- addi_offset += loop_offset;
-- addmi_offset += loop_offset;
--
-- gas_assert (tinsn->ntok == 2);
-- if (tinsn->tok[1].X_op == O_constant)
-- target = tinsn->tok[1].X_add_number;
-- else if (tinsn->tok[1].X_op == O_symbol)
-- {
-- /* Find the fragment. */
-- symbolS *sym = tinsn->tok[1].X_add_symbol;
-- gas_assert (S_GET_SEGMENT (sym) == segP
-- || S_GET_SEGMENT (sym) == absolute_section);
-- target = (S_GET_VALUE (sym) + tinsn->tok[1].X_add_number);
-- }
-- else
-- {
-- as_bad (_("invalid expression evaluation type %d"), tinsn->tok[1].X_op);
-- target = 0;
-- }
--
-- loop_length = target - (fragP->fr_address + fragP->fr_fix);
-- loop_length_hi = loop_length & ~0x0ff;
-- loop_length_lo = loop_length & 0x0ff;
-- if (loop_length_lo >= 128)
-- {
-- loop_length_lo -= 256;
-- loop_length_hi += 256;
-- }
--
-- /* Because addmi sign-extends the immediate, 'loop_length_hi' can be at most
-- 32512. If the loop is larger than that, then we just fail. */
-- if (loop_length_hi > 32512)
-- as_bad_where (fragP->fr_file, fragP->fr_line,
-- _("loop too long for LOOP instruction"));
--
-- tinsn_from_chars (&addi_insn, fragP->fr_opcode + addi_offset, 0);
-- gas_assert (addi_insn.opcode == xtensa_addi_opcode);
--
-- tinsn_from_chars (&addmi_insn, fragP->fr_opcode + addmi_offset, 0);
-- gas_assert (addmi_insn.opcode == xtensa_addmi_opcode);
--
-- set_expr_const (&addi_insn.tok[2], loop_length_lo);
-- tinsn_to_insnbuf (&addi_insn, insnbuf);
--
-- fragP->tc_frag_data.is_insn = TRUE;
-- xtensa_insnbuf_to_chars
-- (isa, insnbuf, (unsigned char *) fragP->fr_opcode + addi_offset, 0);
--
-- set_expr_const (&addmi_insn.tok[2], loop_length_hi);
-- tinsn_to_insnbuf (&addmi_insn, insnbuf);
-- xtensa_insnbuf_to_chars
-- (isa, insnbuf, (unsigned char *) fragP->fr_opcode + addmi_offset, 0);
--
-- /* Walk through all of the frags from here to the loop end
-- and mark them as no_transform to keep them from being modified
-- by the linker. If we ever have a relocation for the
-- addi/addmi of the difference of two symbols we can remove this. */
--
-- target_count = 0;
-- for (next_fragP = fragP; next_fragP != NULL;
-- next_fragP = next_fragP->fr_next)
-- {
-- next_fragP->tc_frag_data.is_no_transform = TRUE;
-- if (next_fragP->tc_frag_data.is_loop_target)
-- target_count++;
-- if (target_count == 2)
-- break;
-- }
--}
--
- \f
- /* A map that keeps information on a per-subsegment basis. This is
- maintained during initial assembly, but is invalid once the
-diff --git a/gas/config/xtensa-relax.c b/gas/config/xtensa-relax.c
-index cb296ed85ed2..daf15d52c259 100644
---- a/gas/config/xtensa-relax.c
-+++ b/gas/config/xtensa-relax.c
-@@ -87,13 +87,7 @@
- when the first and second operands are not the same as specified
- by the "| %at!=%as" precondition clause.
- {"l32i %at,%as,%imm | %at!=%as",
-- "LITERAL %imm; l32r %at,%LITERAL; add %at,%at,%as; l32i %at,%at,0"}
--
-- There is special case for loop instructions here, but because we do
-- not currently have the ability to represent the difference of two
-- symbols, the conversion requires special code in the assembler to
-- write the operands of the addi/addmi pair representing the
-- difference of the old and new loop end label. */
-+ "LITERAL %imm; l32r %at,%LITERAL; add %at,%at,%as; l32i %at,%at,0"} */
-
- #include "as.h"
- #include "xtensa-isa.h"
-@@ -306,44 +300,83 @@ static string_pattern_pair widen_spec_list[] =
- {"l32i %at,%as,%imm | %at!=%as ? IsaUseConst16",
- "const16 %at,HI16U(%imm); const16 %at,LOW16U(%imm); add %at,%at,%as; l32i %at,%at,0"},
-
-- /* This is only PART of the loop instruction. In addition,
-- hardcoded into its use is a modification of the final operand in
-- the instruction in bytes 9 and 12. */
-- {"loop %as,%label | %as!=1 ? IsaUseLoops",
-+ /* Widening loops with literals. */
-+ {"loop %as,%label | %as!=1 ? IsaUseLoops ? IsaUseL32R",
-+ "loop %as,%LABEL;"
-+ "rsr.lend %as;" /* LEND */
-+ "wsr.lbeg %as;" /* LBEG */
-+ "LITERAL %label;"
-+ "l32r %as, %LITERAL;"
-+ "nop;"
-+ "wsr.lend %as;"
-+ "isync;"
-+ "rsr.lcount %as;" /* LCOUNT */
-+ "addi %as, %as, 1;"
-+ "LABEL"},
-+ {"loopgtz %as,%label | %as!=1 ? IsaUseLoops ? IsaUseL32R",
-+ "beqz %as,%label;"
-+ "bltz %as,%label;"
-+ "loopgtz %as,%LABEL;"
-+ "rsr.lend %as;" /* LEND */
-+ "wsr.lbeg %as;" /* LBEG */
-+ "LITERAL %label;"
-+ "l32r %as, %LITERAL;"
-+ "nop;"
-+ "wsr.lend %as;"
-+ "isync;"
-+ "rsr.lcount %as;" /* LCOUNT */
-+ "addi %as, %as, 1;"
-+ "LABEL"},
-+ {"loopnez %as,%label | %as!=1 ? IsaUseLoops ? IsaUseL32R",
-+ "beqz %as,%label;"
-+ "loopnez %as,%LABEL;"
-+ "rsr.lend %as;" /* LEND */
-+ "wsr.lbeg %as;" /* LBEG */
-+ "LITERAL %label;"
-+ "l32r %as, %LITERAL;"
-+ "nop;"
-+ "wsr.lend %as;"
-+ "isync;"
-+ "rsr.lcount %as;" /* LCOUNT */
-+ "addi %as, %as, 1;"
-+ "LABEL"},
-+
-+ /* Widening loops with const16. */
-+ {"loop %as,%label | %as!=1 ? IsaUseLoops ? IsaUseConst16",
- "loop %as,%LABEL;"
- "rsr.lend %as;" /* LEND */
- "wsr.lbeg %as;" /* LBEG */
-- "addi %as, %as, 0;" /* lo8(%label-%LABEL1) */
-- "addmi %as, %as, 0;" /* mid8(%label-%LABEL1) */
-+ "const16 %as,HI16U(%label);"
-+ "const16 %as,LOW16U(%label);"
- "wsr.lend %as;"
- "isync;"
- "rsr.lcount %as;" /* LCOUNT */
-- "addi %as, %as, 1;" /* density -> addi.n %as, %as, 1 */
-+ "addi %as, %as, 1;"
- "LABEL"},
-- {"loopgtz %as,%label | %as!=1 ? IsaUseLoops",
-+ {"loopgtz %as,%label | %as!=1 ? IsaUseLoops ? IsaUseConst16",
- "beqz %as,%label;"
- "bltz %as,%label;"
- "loopgtz %as,%LABEL;"
- "rsr.lend %as;" /* LEND */
- "wsr.lbeg %as;" /* LBEG */
-- "addi %as, %as, 0;" /* lo8(%label-%LABEL1) */
-- "addmi %as, %as, 0;" /* mid8(%label-%LABEL1) */
-+ "const16 %as,HI16U(%label);"
-+ "const16 %as,LOW16U(%label);"
- "wsr.lend %as;"
- "isync;"
- "rsr.lcount %as;" /* LCOUNT */
-- "addi %as, %as, 1;" /* density -> addi.n %as, %as, 1 */
-+ "addi %as, %as, 1;"
- "LABEL"},
-- {"loopnez %as,%label | %as!=1 ? IsaUseLoops",
-+ {"loopnez %as,%label | %as!=1 ? IsaUseLoops ? IsaUseConst16",
- "beqz %as,%label;"
- "loopnez %as,%LABEL;"
- "rsr.lend %as;" /* LEND */
- "wsr.lbeg %as;" /* LBEG */
-- "addi %as, %as, 0;" /* lo8(%label-%LABEL1) */
-- "addmi %as, %as, 0;" /* mid8(%label-%LABEL1) */
-+ "const16 %as,HI16U(%label);"
-+ "const16 %as,LOW16U(%label);"
- "wsr.lend %as;"
- "isync;"
- "rsr.lcount %as;" /* LCOUNT */
-- "addi %as, %as, 1;" /* density -> addi.n %as, %as, 1 */
-+ "addi %as, %as, 1;"
- "LABEL"},
-
- /* Relaxing to wide branches. Order is important here. With wide
---
-2.11.0
-
+++ /dev/null
-From 471702ac4a57878a06e8167f063274cf413e548d Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Mon, 8 Apr 2019 13:47:18 -0700
-Subject: [PATCH] xtensa: gas: put .literal_position at section start
-
-Provide literal position at the beginning of each section for literal
-space reserved by relaxations when text-section-literals or
-auto-litpools options are used. Remove code that adds fill frag to the
-literal section for every .literal_position directive to avoid creation
-of empty literal sections.
-
-Fix auto-litpools tests that got literal pool address changes.
-
-gas/
-2019-04-11 Max Filippov <jcmvbkbc@gmail.com>
-
- * config/tc-xtensa.c (xtensa_is_init_fini): Add declaration.
- (xtensa_mark_literal_pool_location): Don't add fill frag to literal
- section that records literal pool location.
- (md_begin): Call xtensa_mark_literal_pool_location when text
- section literals or auto litpools are used.
- (xtensa_elf_section_change_hook): Call
- xtensa_mark_literal_pool_location when text section literals or
- auto litpools are used, there's no literal pool location defined
- for the current section and it's not .init or .fini.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
----
- gas/config/tc-xtensa.c | 22 +++++++++-------------
- 1 file changed, 9 insertions(+), 13 deletions(-)
-
-diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
-index 0cc06361cf6f..6a80e76fed8c 100644
---- a/gas/config/tc-xtensa.c
-+++ b/gas/config/tc-xtensa.c
-@@ -497,6 +497,7 @@ static fixS *xg_append_jump (fragS *fragP, symbolS *sym, offsetT offset);
- static void xtensa_maybe_create_literal_pool_frag (bfd_boolean, bfd_boolean);
- static bfd_boolean auto_litpools = FALSE;
- static int auto_litpool_limit = 0;
-+static bfd_boolean xtensa_is_init_fini (segT seg);
-
- /* Alignment Functions. */
-
-@@ -4797,7 +4798,6 @@ xtensa_mark_literal_pool_location (void)
- {
- /* Any labels pointing to the current location need
- to be adjusted to after the literal pool. */
-- emit_state s;
- fragS *pool_location;
-
- if (use_literal_section)
-@@ -4818,19 +4818,7 @@ xtensa_mark_literal_pool_location (void)
- RELAX_LITERAL_POOL_END, NULL, 0, NULL);
- xtensa_set_frag_assembly_state (frag_now);
-
-- /* Now put a frag into the literal pool that points to this location. */
- set_literal_pool_location (now_seg, pool_location);
-- xtensa_switch_to_non_abs_literal_fragment (&s);
-- frag_align (2, 0, 0);
-- record_alignment (now_seg, 2);
--
-- /* Close whatever frag is there. */
-- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
-- xtensa_set_frag_assembly_state (frag_now);
-- frag_now->tc_frag_data.literal_frag = pool_location;
-- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
-- xtensa_restore_emit_state (&s);
-- xtensa_set_frag_assembly_state (frag_now);
- }
-
-
-@@ -5334,6 +5322,9 @@ md_begin (void)
- /* Set up the assembly state. */
- if (!frag_now->tc_frag_data.is_assembly_state_set)
- xtensa_set_frag_assembly_state (frag_now);
-+
-+ if (!use_literal_section)
-+ xtensa_mark_literal_pool_location ();
- }
-
-
-@@ -5933,6 +5924,11 @@ xtensa_elf_section_change_hook (void)
- /* Set up the assembly state. */
- if (!frag_now->tc_frag_data.is_assembly_state_set)
- xtensa_set_frag_assembly_state (frag_now);
-+
-+ if (!use_literal_section
-+ && seg_info (now_seg)->tc_segment_info_data.literal_pool_loc == NULL
-+ && !xtensa_is_init_fini (now_seg))
-+ xtensa_mark_literal_pool_location ();
- }
-
-
---
-2.11.0
-
+++ /dev/null
-From 85dcca5997cf3822d6456a5c9c59c46b56adfbb8 Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Wed, 4 Mar 2020 14:54:27 -0800
-Subject: [PATCH] bfd: xtensa: fix PR ld/25630
-
-bfd/
-2020-03-05 Max Filippov <jcmvbkbc@gmail.com>
-
- * elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic
- relocation sections for any removed reference to a dynamic symbol.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
----
- bfd/elf32-xtensa.c | 7 +++----
- 1 file changed, 3 insertions(+), 4 deletions(-)
-
-diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
-index 12ff9f772aaf..65e14d87940c 100644
---- a/bfd/elf32-xtensa.c
-+++ b/bfd/elf32-xtensa.c
-@@ -10148,10 +10148,9 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
-
- if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
- && (input_section->flags & SEC_ALLOC) != 0
-- && (dynamic_symbol || bfd_link_pic (info))
-- && (!h || h->root.type != bfd_link_hash_undefweak
-- || (dynamic_symbol
-- && (bfd_link_dll (info) || info->export_dynamic))))
-+ && (dynamic_symbol
-+ || (bfd_link_pic (info)
-+ && (!h || h->root.type != bfd_link_hash_undefweak))))
- {
- asection *srel;
- bfd_boolean is_plt = FALSE;
---
-2.20.1
-
+++ /dev/null
-From c7a1d1f656c717394937a92cb970f0f4cecce128 Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Sun, 19 Apr 2020 19:04:41 -0700
-Subject: [PATCH] xtensa: fix PR ld/25861
-
-Introduce new relaxations XTENSA_PDIFF{8,16,32} for positive differences
-(subtracted symbol precedes diminished symbol) and XTENSA_NDIFF{8,16,32}
-for negative differences (subtracted symbol follows diminished symbol).
-Don't generate XTENSA_DIFF relocations in the assembler, generate
-XTENSA_PDIFF or XTENSA_NDIFF based on relative symbol position.
-
-Handle XTENSA_DIFF in BFD for compatibility with old object files.
-Handle XTENSA_PDIFF and XTENSA_NDIFF in BFD, treating difference value
-as unsigned.
-
-2020-04-22 Max Filippov <jcmvbkbc@gmail.com>
-bfd/
- * bfd-in2.h: Regenerated.
- * elf32-xtensa.c (elf_howto_table): New entries for
- R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.
- (elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc)
- (relax_section): Add cases for R_XTENSA_PDIFF{8,16,32} and
- R_XTENSA_NDIFF{8,16,32}.
- * libbfd.h (bfd_reloc_code_real_names): Add names for
- BFD_RELOC_XTENSA_PDIFF{8,16,32} and
- BFD_RELOC_XTENSA_NDIFF{8,16,32}.
- * reloc.c: Add documentation for BFD_RELOC_XTENSA_PDIFF{8,16,32}
- and BFD_RELOC_XTENSA_NDIFF{8,16,32}.
-
-binutils/
- * readelf.c (is_none_reloc): Recognize
- BFD_RELOC_XTENSA_PDIFF{8,16,32} and
- BFD_RELOC_XTENSA_NDIFF{8,16,32}.
-
-gas/
- * config/tc-xtensa.c (md_apply_fix): Replace
- BFD_RELOC_XTENSA_DIFF{8,16,32} generation with
- BFD_RELOC_XTENSA_PDIFF{8,16,32} and
- BFD_RELOC_XTENSA_NDIFF{8,16,32} generation.
- * testsuite/gas/xtensa/loc.d: Replace BFD_RELOC_XTENSA_DIFF16
- with BFD_RELOC_XTENSA_PDIFF16 in the expected output.
-
-include/
- * elf/xtensa.h (elf_xtensa_reloc_type): New entries for
- R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
----
-Backported from: 30ce8e47fad9b057b6d7af9e1d43061126d34d20
-
- bfd/bfd-in2.h | 20 ++++++-
- bfd/elf32-xtensa.c | 89 +++++++++++++++++++++++++++++-
- bfd/libbfd.h | 6 ++
- bfd/reloc.c | 24 ++++++++
- binutils/readelf.c | 8 ++-
- gas/config/tc-xtensa.c | 12 +++-
- gas/testsuite/gas/xtensa/loc.d | 2 +-
- include/elf/xtensa.h | 6 ++
- 11 files changed, 160 insertions(+), 7 deletions(-)
-
-diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
-index 37114607b515..be6a30f57955 100644
---- a/bfd/bfd-in2.h
-+++ b/bfd/bfd-in2.h
-@@ -5217,7 +5217,9 @@ to one of its own internal functions or data structures. */
- PLT entries. Otherwise, this is just a generic 32-bit relocation. */
- BFD_RELOC_XTENSA_PLT,
-
--/* Xtensa relocations to mark the difference of two local symbols.
-+/* Xtensa relocations for backward compatibility. These have been replaced
-+by BFD_RELOC_XTENSA_PDIFF and BFD_RELOC_XTENSA_NDIFF.
-+Xtensa relocations to mark the difference of two local symbols.
- These are only needed to support linker relaxation and can be ignored
- when not relaxing. The field is set to the value of the difference
- assuming no relaxation. The relocation encodes the position of the
-@@ -5291,6 +5293,22 @@ BFD_RELOC_XTENSA_ASM_EXPAND. */
- BFD_RELOC_XTENSA_TLS_ARG,
- BFD_RELOC_XTENSA_TLS_CALL,
-
-+/* Xtensa relocations to mark the difference of two local symbols.
-+These are only needed to support linker relaxation and can be ignored
-+when not relaxing. The field is set to the value of the difference
-+assuming no relaxation. The relocation encodes the position of the
-+subtracted symbol so the linker can determine whether to adjust the field
-+value. PDIFF relocations are used for positive differences, NDIFF
-+relocations are used for negative differences. The difference value
-+is treated as unsigned with these relocation types, giving full
-+8/16 value ranges. */
-+ BFD_RELOC_XTENSA_PDIFF8,
-+ BFD_RELOC_XTENSA_PDIFF16,
-+ BFD_RELOC_XTENSA_PDIFF32,
-+ BFD_RELOC_XTENSA_NDIFF8,
-+ BFD_RELOC_XTENSA_NDIFF16,
-+ BFD_RELOC_XTENSA_NDIFF32,
-+
- /* 8 bit signed offset in (ix+d) or (iy+d). */
- BFD_RELOC_Z80_DISP8,
-
-diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
-index 473a9d76f289..fded42d52a9a 100644
---- a/bfd/elf32-xtensa.c
-+++ b/bfd/elf32-xtensa.c
-@@ -325,6 +325,20 @@ static reloc_howto_type elf_howto_table[] =
- HOWTO (R_XTENSA_TLS_CALL, 0, 0, 0, FALSE, 0, complain_overflow_dont,
- bfd_elf_xtensa_reloc, "R_XTENSA_TLS_CALL",
- FALSE, 0, 0, FALSE),
-+
-+ HOWTO (R_XTENSA_PDIFF8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,
-+ bfd_elf_xtensa_reloc, "R_XTENSA_PDIFF8", FALSE, 0, 0xff, FALSE),
-+ HOWTO (R_XTENSA_PDIFF16, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,
-+ bfd_elf_xtensa_reloc, "R_XTENSA_PDIFF16", FALSE, 0, 0xffff, FALSE),
-+ HOWTO (R_XTENSA_PDIFF32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
-+ bfd_elf_xtensa_reloc, "R_XTENSA_PDIFF32", FALSE, 0, 0xffffffff, FALSE),
-+
-+ HOWTO (R_XTENSA_NDIFF8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,
-+ bfd_elf_xtensa_reloc, "R_XTENSA_NDIFF8", FALSE, 0, 0xff, FALSE),
-+ HOWTO (R_XTENSA_NDIFF16, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,
-+ bfd_elf_xtensa_reloc, "R_XTENSA_NDIFF16", FALSE, 0, 0xffff, FALSE),
-+ HOWTO (R_XTENSA_NDIFF32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
-+ bfd_elf_xtensa_reloc, "R_XTENSA_NDIFF32", FALSE, 0, 0xffffffff, FALSE),
- };
-
- #if DEBUG_GEN_RELOC
-@@ -364,6 +378,30 @@ elf_xtensa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
- TRACE ("BFD_RELOC_XTENSA_DIFF32");
- return &elf_howto_table[(unsigned) R_XTENSA_DIFF32 ];
-
-+ case BFD_RELOC_XTENSA_PDIFF8:
-+ TRACE ("BFD_RELOC_XTENSA_PDIFF8");
-+ return &elf_howto_table[(unsigned) R_XTENSA_PDIFF8 ];
-+
-+ case BFD_RELOC_XTENSA_PDIFF16:
-+ TRACE ("BFD_RELOC_XTENSA_PDIFF16");
-+ return &elf_howto_table[(unsigned) R_XTENSA_PDIFF16 ];
-+
-+ case BFD_RELOC_XTENSA_PDIFF32:
-+ TRACE ("BFD_RELOC_XTENSA_PDIFF32");
-+ return &elf_howto_table[(unsigned) R_XTENSA_PDIFF32 ];
-+
-+ case BFD_RELOC_XTENSA_NDIFF8:
-+ TRACE ("BFD_RELOC_XTENSA_NDIFF8");
-+ return &elf_howto_table[(unsigned) R_XTENSA_NDIFF8 ];
-+
-+ case BFD_RELOC_XTENSA_NDIFF16:
-+ TRACE ("BFD_RELOC_XTENSA_NDIFF16");
-+ return &elf_howto_table[(unsigned) R_XTENSA_NDIFF16 ];
-+
-+ case BFD_RELOC_XTENSA_NDIFF32:
-+ TRACE ("BFD_RELOC_XTENSA_NDIFF32");
-+ return &elf_howto_table[(unsigned) R_XTENSA_NDIFF32 ];
-+
- case BFD_RELOC_XTENSA_RTLD:
- TRACE ("BFD_RELOC_XTENSA_RTLD");
- return &elf_howto_table[(unsigned) R_XTENSA_RTLD ];
-@@ -1851,6 +1889,12 @@ elf_xtensa_do_reloc (reloc_howto_type *howto,
- case R_XTENSA_DIFF8:
- case R_XTENSA_DIFF16:
- case R_XTENSA_DIFF32:
-+ case R_XTENSA_PDIFF8:
-+ case R_XTENSA_PDIFF16:
-+ case R_XTENSA_PDIFF32:
-+ case R_XTENSA_NDIFF8:
-+ case R_XTENSA_NDIFF16:
-+ case R_XTENSA_NDIFF32:
- case R_XTENSA_TLS_FUNC:
- case R_XTENSA_TLS_ARG:
- case R_XTENSA_TLS_CALL:
-@@ -9604,7 +9648,13 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info)
-
- if (r_type == R_XTENSA_DIFF8
- || r_type == R_XTENSA_DIFF16
-- || r_type == R_XTENSA_DIFF32)
-+ || r_type == R_XTENSA_DIFF32
-+ || r_type == R_XTENSA_PDIFF8
-+ || r_type == R_XTENSA_PDIFF16
-+ || r_type == R_XTENSA_PDIFF32
-+ || r_type == R_XTENSA_NDIFF8
-+ || r_type == R_XTENSA_NDIFF16
-+ || r_type == R_XTENSA_NDIFF32)
- {
- bfd_signed_vma diff_value = 0;
- bfd_vma new_end_offset, diff_mask = 0;
-@@ -9631,8 +9681,27 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info)
- diff_value =
- bfd_get_signed_32 (abfd, &contents[old_source_offset]);
- break;
-+ case R_XTENSA_PDIFF8:
-+ case R_XTENSA_NDIFF8:
-+ diff_value =
-+ bfd_get_8 (abfd, &contents[old_source_offset]);
-+ break;
-+ case R_XTENSA_PDIFF16:
-+ case R_XTENSA_NDIFF16:
-+ diff_value =
-+ bfd_get_16 (abfd, &contents[old_source_offset]);
-+ break;
-+ case R_XTENSA_PDIFF32:
-+ case R_XTENSA_NDIFF32:
-+ diff_value =
-+ bfd_get_32 (abfd, &contents[old_source_offset]);
-+ break;
- }
-
-+ if (r_type >= R_XTENSA_NDIFF8
-+ && r_type <= R_XTENSA_NDIFF32)
-+ diff_value = -diff_value;
-+
- new_end_offset = offset_with_removed_text_map
- (&target_relax_info->action_list,
- r_rel.target_offset + diff_value);
-@@ -9655,6 +9724,24 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info)
- bfd_put_signed_32 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
-+ case R_XTENSA_PDIFF8:
-+ case R_XTENSA_NDIFF8:
-+ diff_mask = 0xff;
-+ bfd_put_8 (abfd, diff_value,
-+ &contents[old_source_offset]);
-+ break;
-+ case R_XTENSA_PDIFF16:
-+ case R_XTENSA_NDIFF16:
-+ diff_mask = 0xffff;
-+ bfd_put_16 (abfd, diff_value,
-+ &contents[old_source_offset]);
-+ break;
-+ case R_XTENSA_PDIFF32:
-+ case R_XTENSA_NDIFF32:
-+ diff_mask = 0xffffffff;
-+ bfd_put_32 (abfd, diff_value,
-+ &contents[old_source_offset]);
-+ break;
- }
-
- /* Check for overflow. Sign bits must be all zeroes or all ones */
-diff --git a/bfd/libbfd.h b/bfd/libbfd.h
-index 3c184fcadadf..989f4bc0b595 100644
---- a/bfd/libbfd.h
-+++ b/bfd/libbfd.h
-@@ -2919,6 +2919,12 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
- "BFD_RELOC_XTENSA_TLS_FUNC",
- "BFD_RELOC_XTENSA_TLS_ARG",
- "BFD_RELOC_XTENSA_TLS_CALL",
-+ "BFD_RELOC_XTENSA_PDIFF8",
-+ "BFD_RELOC_XTENSA_PDIFF16",
-+ "BFD_RELOC_XTENSA_PDIFF32",
-+ "BFD_RELOC_XTENSA_NDIFF8",
-+ "BFD_RELOC_XTENSA_NDIFF16",
-+ "BFD_RELOC_XTENSA_NDIFF32",
- "BFD_RELOC_Z80_DISP8",
- "BFD_RELOC_Z80_BYTE0",
- "BFD_RELOC_Z80_BYTE1",
-diff --git a/bfd/reloc.c b/bfd/reloc.c
-index c4dec86d1d46..f5df8e2ab3eb 100644
---- a/bfd/reloc.c
-+++ b/bfd/reloc.c
-@@ -6556,6 +6556,8 @@ ENUMX
- ENUMX
- BFD_RELOC_XTENSA_DIFF32
- ENUMDOC
-+ Xtensa relocations for backward compatibility. These have been replaced
-+ by BFD_RELOC_XTENSA_PDIFF and BFD_RELOC_XTENSA_NDIFF.
- Xtensa relocations to mark the difference of two local symbols.
- These are only needed to support linker relaxation and can be ignored
- when not relaxing. The field is set to the value of the difference
-@@ -6668,6 +6670,28 @@ ENUMX
- BFD_RELOC_XTENSA_TLS_CALL
- ENUMDOC
- Xtensa TLS relocations.
-+ENUM
-+ BFD_RELOC_XTENSA_PDIFF8
-+ENUMX
-+ BFD_RELOC_XTENSA_PDIFF16
-+ENUMX
-+ BFD_RELOC_XTENSA_PDIFF32
-+ENUMX
-+ BFD_RELOC_XTENSA_NDIFF8
-+ENUMX
-+ BFD_RELOC_XTENSA_NDIFF16
-+ENUMX
-+ BFD_RELOC_XTENSA_NDIFF32
-+ENUMDOC
-+ Xtensa relocations to mark the difference of two local symbols.
-+ These are only needed to support linker relaxation and can be ignored
-+ when not relaxing. The field is set to the value of the difference
-+ assuming no relaxation. The relocation encodes the position of the
-+ subtracted symbol so the linker can determine whether to adjust the field
-+ value. PDIFF relocations are used for positive differences, NDIFF
-+ relocations are used for negative differences. The difference value
-+ is treated as unsigned with these relocation types, giving full
-+ 8/16 value ranges.
-
- ENUM
- BFD_RELOC_Z80_DISP8
-diff --git a/binutils/readelf.c b/binutils/readelf.c
-index d4756c93b345..800918f901c8 100644
---- a/binutils/readelf.c
-+++ b/binutils/readelf.c
-@@ -13262,7 +13262,13 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
- return (reloc_type == 0 /* R_XTENSA_NONE. */
- || reloc_type == 17 /* R_XTENSA_DIFF8. */
- || reloc_type == 18 /* R_XTENSA_DIFF16. */
-- || reloc_type == 19 /* R_XTENSA_DIFF32. */);
-+ || reloc_type == 19 /* R_XTENSA_DIFF32. */
-+ || reloc_type == 57 /* R_XTENSA_PDIFF8. */
-+ || reloc_type == 58 /* R_XTENSA_PDIFF16. */
-+ || reloc_type == 59 /* R_XTENSA_PDIFF32. */
-+ || reloc_type == 60 /* R_XTENSA_NDIFF8. */
-+ || reloc_type == 61 /* R_XTENSA_NDIFF16. */
-+ || reloc_type == 62 /* R_XTENSA_NDIFF32. */);
- }
- return FALSE;
- }
-diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
-index 71d4d94a8d7d..ee75c13548ff 100644
---- a/gas/config/tc-xtensa.c
-+++ b/gas/config/tc-xtensa.c
-@@ -5974,18 +5974,24 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
- case BFD_RELOC_8:
- if (fixP->fx_subsy)
- {
-+ bfd_boolean neg = S_GET_VALUE (fixP->fx_addsy) + fixP->fx_offset
-+ < S_GET_VALUE (fixP->fx_subsy);
-+
- switch (fixP->fx_r_type)
- {
- case BFD_RELOC_8:
-- fixP->fx_r_type = BFD_RELOC_XTENSA_DIFF8;
-+ fixP->fx_r_type = neg
-+ ? BFD_RELOC_XTENSA_NDIFF8 : BFD_RELOC_XTENSA_PDIFF8;
- fixP->fx_signed = 0;
- break;
- case BFD_RELOC_16:
-- fixP->fx_r_type = BFD_RELOC_XTENSA_DIFF16;
-+ fixP->fx_r_type = neg
-+ ? BFD_RELOC_XTENSA_NDIFF16 : BFD_RELOC_XTENSA_PDIFF16;
- fixP->fx_signed = 0;
- break;
- case BFD_RELOC_32:
-- fixP->fx_r_type = BFD_RELOC_XTENSA_DIFF32;
-+ fixP->fx_r_type = neg
-+ ? BFD_RELOC_XTENSA_NDIFF32 : BFD_RELOC_XTENSA_PDIFF32;
- fixP->fx_signed = 0;
- break;
- default:
-diff --git a/gas/testsuite/gas/xtensa/loc.d b/gas/testsuite/gas/xtensa/loc.d
-index 71983cc90055..8fb3425999d5 100644
---- a/gas/testsuite/gas/xtensa/loc.d
-+++ b/gas/testsuite/gas/xtensa/loc.d
-@@ -6,5 +6,5 @@
-
- RELOCATION RECORDS FOR \[\.debug_line\]:
- #...
--.*R_XTENSA_DIFF16.*\.text\+0x00009c42
-+.*R_XTENSA_PDIFF16.*\.text\+0x00009c42
- #...
-diff --git a/include/elf/xtensa.h b/include/elf/xtensa.h
-index 2eb5e4e52941..bd5c80d13777 100644
---- a/include/elf/xtensa.h
-+++ b/include/elf/xtensa.h
-@@ -87,6 +87,12 @@ START_RELOC_NUMBERS (elf_xtensa_reloc_type)
- RELOC_NUMBER (R_XTENSA_TLS_FUNC, 54)
- RELOC_NUMBER (R_XTENSA_TLS_ARG, 55)
- RELOC_NUMBER (R_XTENSA_TLS_CALL, 56)
-+ RELOC_NUMBER (R_XTENSA_PDIFF8, 57)
-+ RELOC_NUMBER (R_XTENSA_PDIFF16, 58)
-+ RELOC_NUMBER (R_XTENSA_PDIFF32, 59)
-+ RELOC_NUMBER (R_XTENSA_NDIFF8, 60)
-+ RELOC_NUMBER (R_XTENSA_NDIFF16, 61)
-+ RELOC_NUMBER (R_XTENSA_NDIFF32, 62)
- END_RELOC_NUMBERS (R_XTENSA_max)
-
- /* Processor-specific flags for the ELF header e_flags field. */
---
-2.20.1
-
+++ /dev/null
-From 735321812435ae278d3766a3371f55937dc776d6 Mon Sep 17 00:00:00 2001
-From: Max Filippov <jcmvbkbc@gmail.com>
-Date: Sat, 25 Apr 2020 00:40:25 -0700
-Subject: [PATCH] xtensa: fix XTENSA_NDIFF handling for PR ld/25861
-
-Fields marked with XTENSA_NDIFF relocations are not negated, they only
-have sign bits removed. Don't negate their values when relaxation is
-performed. Don't add sign bits when the value is zero. Report overflow
-when the result has negative sign but all significant bits are zero.
-
-2020-04-29 Max Filippov <jcmvbkbc@gmail.com>
-bfd/
- * elf32-xtensa.c (relax_section): Don't negate diff_value for
- XTENSA_NDIFF relocations. Don't add sign bits whe diff_value
- equals 0. Report overflow when the result has negative sign but
- all significant bits are zero.
-
-Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-Backported from: d548f47df4d2e3d117d504a4c9977982c78a0556
----
-
- bfd/elf32-xtensa.c | 26 +++++++++++++++-----------
- 1 file changed, 15 insertions(+), 11 deletions(-)
-
-diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
-index fded42d52a9a..4327b027911f 100644
---- a/bfd/elf32-xtensa.c
-+++ b/bfd/elf32-xtensa.c
-@@ -9670,37 +9670,44 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info)
- switch (r_type)
- {
- case R_XTENSA_DIFF8:
-+ diff_mask = 0x7f;
- diff_value =
- bfd_get_signed_8 (abfd, &contents[old_source_offset]);
- break;
- case R_XTENSA_DIFF16:
-+ diff_mask = 0x7fff;
- diff_value =
- bfd_get_signed_16 (abfd, &contents[old_source_offset]);
- break;
- case R_XTENSA_DIFF32:
-+ diff_mask = 0x7fffffff;
- diff_value =
- bfd_get_signed_32 (abfd, &contents[old_source_offset]);
- break;
- case R_XTENSA_PDIFF8:
- case R_XTENSA_NDIFF8:
-+ diff_mask = 0xff;
- diff_value =
- bfd_get_8 (abfd, &contents[old_source_offset]);
- break;
- case R_XTENSA_PDIFF16:
- case R_XTENSA_NDIFF16:
-+ diff_mask = 0xffff;
- diff_value =
- bfd_get_16 (abfd, &contents[old_source_offset]);
- break;
- case R_XTENSA_PDIFF32:
- case R_XTENSA_NDIFF32:
-+ diff_mask = 0xffffffff;
- diff_value =
- bfd_get_32 (abfd, &contents[old_source_offset]);
- break;
- }
-
- if (r_type >= R_XTENSA_NDIFF8
-- && r_type <= R_XTENSA_NDIFF32)
-- diff_value = -diff_value;
-+ && r_type <= R_XTENSA_NDIFF32
-+ && diff_value)
-+ diff_value |= ~diff_mask;
-
- new_end_offset = offset_with_removed_text_map
- (&target_relax_info->action_list,
-@@ -9710,43 +9717,40 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info)
- switch (r_type)
- {
- case R_XTENSA_DIFF8:
-- diff_mask = 0x7f;
- bfd_put_signed_8 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
- case R_XTENSA_DIFF16:
-- diff_mask = 0x7fff;
- bfd_put_signed_16 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
- case R_XTENSA_DIFF32:
-- diff_mask = 0x7fffffff;
- bfd_put_signed_32 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
- case R_XTENSA_PDIFF8:
- case R_XTENSA_NDIFF8:
-- diff_mask = 0xff;
- bfd_put_8 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
- case R_XTENSA_PDIFF16:
- case R_XTENSA_NDIFF16:
-- diff_mask = 0xffff;
- bfd_put_16 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
- case R_XTENSA_PDIFF32:
- case R_XTENSA_NDIFF32:
-- diff_mask = 0xffffffff;
- bfd_put_32 (abfd, diff_value,
- &contents[old_source_offset]);
- break;
- }
-
-- /* Check for overflow. Sign bits must be all zeroes or all ones */
-- if ((diff_value & ~diff_mask) != 0 &&
-- (diff_value & ~diff_mask) != (-1 & ~diff_mask))
-+ /* Check for overflow. Sign bits must be all zeroes or
-+ all ones. When sign bits are all ones diff_value
-+ may not be zero. */
-+ if (((diff_value & ~diff_mask) != 0
-+ && (diff_value & ~diff_mask) != ~diff_mask)
-+ || (diff_value && (bfd_vma) diff_value == ~diff_mask))
- {
- (*link_info->callbacks->reloc_dangerous)
- (link_info, _("overflow after relaxation"),
---
-2.20.1
-
help
Select the version of binutils you wish to use.
-config BR2_BINUTILS_VERSION_2_31_X
- bool "binutils 2.31.1"
- depends on !BR2_csky
-
config BR2_BINUTILS_VERSION_2_32_X
bool "binutils 2.32"
depends on !BR2_csky
string
default "arc-2020.03-release" if BR2_BINUTILS_VERSION_ARC
default "c66d8bbcebfddf713b2b436e1b135e6b125a55a5" if BR2_BINUTILS_VERSION_CSKY
- default "2.31.1" if BR2_BINUTILS_VERSION_2_31_X
default "2.32" if BR2_BINUTILS_VERSION_2_32_X
default "2.33.1" if BR2_BINUTILS_VERSION_2_33_X
default "2.34" if BR2_BINUTILS_VERSION_2_34_X
# From ftp://gcc.gnu.org/pub/binutils/releases/sha512.sum
-sha512 0fca326feb1d5f5fe505a827b20237fe3ec9c13eaf7ec7e35847fd71184f605ba1cefe1314b1b8f8a29c0aa9d88162849ee1c1a3e70c2f7407d88339b17edb30 binutils-2.31.1.tar.xz
sha512 d326408f12a03d9a61a9de56584c2af12f81c2e50d2d7e835d51565df8314df01575724afa1e43bd0db45cfc9916b41519b67dfce03232aa4978704492a6994a binutils-2.32.tar.xz
sha512 b7a6767c6c7ca6b5cafa7080e6820b7bb3a53b7148348c438d99905defbdf0d30c9744a484ee01c9441a8153901808513366b15ba9533e20c9673c262ade36ac binutils-2.33.1.tar.xz
sha512 2c7976939dcf5e8c5b7374cccd39bfe803b1bec73c6abfa0eb17c24e1942574c6bdb874c66a092a82adc443182eacd8a5a8001c19a76101f0c7ba40c27de0bbd binutils-2.34.tar.xz
config BR2_GCC_VERSION_9_X
bool "gcc 9.x"
depends on !BR2_ARCH_NEEDS_GCC_AT_LEAST_10
- # or1k needs binutils >= 2.32
- depends on !(BR2_or1k && BR2_BINUTILS_VERSION_2_31_X)
# powerpc spe support has been deprecated since gcc 8.x.
# https://gcc.gnu.org/ml/gcc/2018-04/msg00102.html
depends on !BR2_powerpc_SPE
config BR2_GCC_VERSION_10_X
bool "gcc 10.x"
- # or1k needs binutils >= 2.32
- depends on !(BR2_or1k && BR2_BINUTILS_VERSION_2_31_X)
# powerpc spe support has been deprecated since gcc 8.x.
# https://gcc.gnu.org/ml/gcc/2018-04/msg00102.html
depends on !BR2_powerpc_SPE