branch-updates
authorMatthias Klose <doko@debian.org>
Sun, 22 Oct 2017 20:41:34 +0000 (21:41 +0100)
committerMatthias Klose <doko@debian.org>
Sun, 22 Oct 2017 20:41:34 +0000 (21:41 +0100)
# DP: updates from the binutils-2.29 branch

# git diff d1a6e7195b9bb0255fa77588985b969ad8aaacf5 52d10fb25c9ded29497c88088b13c60a37122076

Gbp-Pq: Name branch-updates.diff

21 files changed:
bfd/ChangeLog
bfd/bfd-in2.h
bfd/bfd.c
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/version.h
binutils/ChangeLog
binutils/readelf.c
gas/ChangeLog
gas/testsuite/gas/mips/elf_mach_5900.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp
gold/ChangeLog
gold/options.h
gold/powerpc.cc
ld/ChangeLog
ld/testsuite/ld-plugin/lto.exp
ld/testsuite/ld-plugin/pr22220.h [new file with mode: 0644]
ld/testsuite/ld-plugin/pr22220lib.cc [new file with mode: 0644]
ld/testsuite/ld-plugin/pr22220lib.ver [new file with mode: 0644]
ld/testsuite/ld-plugin/pr22220main.cc [new file with mode: 0644]

index 417ed273ab8e72a5879920502b85a9358b5e508a..cd0a8f24d1118fed8c64a3e405659545c3d5e6c1 100644 (file)
@@ -1,3 +1,49 @@
+2017-10-05  Alan Modra  <amodra@gmail.com>
+
+       * elflink.c (elf_link_input_bfd): Correct ctor/dtor in init_array/
+       fini_array error value.
+
+2017-10-04  Pavel I. Kryukov <kryukov@frtk.ru>
+
+       PR 22245
+       * bfd.c (bfd_set_error): Avoid UB on passing arg to va_start that
+       undergoes default promotion.
+       * bfd-in2.h: Regenerate.
+
+2017-09-28  Alan Modra  <amodra@gmail.com>
+
+       PR 22220
+       * elflink.c (_bfd_elf_merge_symbol): Set non_ir_ref_dynamic in
+       a case where plugin_notice isn't called.
+
+2017-09-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/22199
+       * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Don't pass
+       output_bfd to info->callbacks->minfo.
+
+2017-09-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/22170
+       * elf32-i386.c (elf_i386_get_synthetic_symtab): Guard against
+       corrupted PLT.
+       * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
+
+2017-09-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/22163
+       * elf32-i386.c (elf_i386_get_synthetic_symtab): Also return -1
+       if bfd_canonicalize_dynamic_reloc returns 0.
+       * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
+
+2017-09-21  Nick Clifton  <nickc@redhat.com>
+
+       * development.sh (development): Revert previous delta.
+
+2017-09-20  Nick Clifton  <nickc@redhat.com>
+
+       * development.sh (development): Set to false.
+
 2017-09-19  Nick Clifton  <nickc@redhat.com>
 
        2.29.1 Release
index 1343780c8ceb57e16df15a728df2056b5bb127f3..0dba68b1e66297ec4dfd013ccd7c1fb83be9b3b8 100644 (file)
@@ -7053,7 +7053,7 @@ bfd_error_type;
 
 bfd_error_type bfd_get_error (void);
 
-void bfd_set_error (bfd_error_type error_tag, ...);
+void bfd_set_error (int error_tag, ...);
 
 const char *bfd_errmsg (bfd_error_type error_tag);
 
index 665f182559b37b4b9f61fdac19eb117badb9d0d8..5da1a6fd53a7024bd037913d77e5ab603e4ef8fd 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -497,7 +497,7 @@ FUNCTION
        bfd_set_error
 
 SYNOPSIS
-       void bfd_set_error (bfd_error_type error_tag, ...);
+       void bfd_set_error (int error_tag, ...);
 
 DESCRIPTION
        Set the BFD error condition to be @var{error_tag}.
@@ -507,7 +507,7 @@ DESCRIPTION
 */
 
 void
-bfd_set_error (bfd_error_type error_tag, ...)
+bfd_set_error (int error_tag, ...)
 {
   bfd_error = error_tag;
   if (error_tag == bfd_error_on_input)
index 5c1c3ff7907e7ae79deacdbef76dd2540377538d..ba50c93f33e451638354eefb81f8f038bdcc6fd6 100644 (file)
@@ -6342,7 +6342,7 @@ elf_i386_get_synthetic_symtab (bfd *abfd,
 
   dynrelcount = bfd_canonicalize_dynamic_reloc (abfd, dynrelbuf,
                                                dynsyms);
-  if (dynrelcount < 0)
+  if (dynrelcount <= 0)
     return -1;
 
   /* Sort the relocs by address.  */
@@ -6616,6 +6616,10 @@ bad_return:
                  size += sizeof ("+0x") - 1 + 8;
                n++;
                s++;
+               /* There should be only one entry in PLT for a given
+                  symbol.  Set howto to NULL after processing a PLT
+                  entry to guard against corrupted PLT.  */
+               p->howto = NULL;
              }
            offset += plt_entry_size;
          }
index 80dd791d25ca9f9e8d86cbdfc6ef62021b843f23..1f6dfb89bfe0379749a969fd088b4268ac1f1b73 100644 (file)
@@ -6133,7 +6133,6 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
              if (SYMBOL_REFERENCES_LOCAL (info, h))
                {
                  info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
-                                         output_bfd,
                                          h->root.root.string,
                                          h->root.u.def.section->owner);
 
@@ -6717,7 +6716,7 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd,
 
   dynrelcount = bfd_canonicalize_dynamic_reloc (abfd, dynrelbuf,
                                                dynsyms);
-  if (dynrelcount < 0)
+  if (dynrelcount <= 0)
     return -1;
 
   /* Sort the relocs by address.  */
@@ -6970,6 +6969,10 @@ bad_return:
                  size += sizeof ("+0x") - 1 + 8 + 8 * ABI_64_P (abfd);
                n++;
                s++;
+               /* There should be only one entry in PLT for a given
+                  symbol.  Set howto to NULL after processing a PLT
+                  entry to guard against corrupted PLT.  */
+               p->howto = NULL;
              }
            offset += plt_entry_size;
          }
index 02713a595641077f4efd1ad1f7164dd974fe293d..39d878c8146036e1f57218215d54089876dd3a04 100644 (file)
@@ -1234,6 +1234,16 @@ _bfd_elf_merge_symbol (bfd *abfd,
       olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0;
     }
 
+  /* Handle a case where plugin_notice won't be called and thus won't
+     set the non_ir_ref flags on the first pass over symbols.  */
+  if (oldbfd != NULL
+      && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN)
+      && newdyn != olddyn)
+    {
+      h->root.non_ir_ref_dynamic = TRUE;
+      hi->root.non_ir_ref_dynamic = TRUE;
+    }
+
   /* NEWDEF and OLDDEF indicate whether the new or old symbol,
      respectively, appear to be a definition rather than reference.  */
 
@@ -10429,7 +10439,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
                    (_("error: %B: size of section %A is not "
                       "multiple of address size"),
                     input_bfd, o);
-                 bfd_set_error (bfd_error_on_input);
+                 bfd_set_error (bfd_error_bad_value);
                  return FALSE;
                }
              o->flags |= SEC_ELF_REVERSE_COPY;
index 3405e424f40811f79744f86af16480ccac1d94bc..7470f451520510d6875bf8f5b8068fed8a53dabb 100644 (file)
@@ -1,4 +1,4 @@
-#define BFD_VERSION_DATE 20170919
+#define BFD_VERSION_DATE 20171022
 #define BFD_VERSION @bfd_version@
 #define BFD_VERSION_STRING  @bfd_version_package@ @bfd_version_string@
 #define REPORT_BUGS_TO @report_bugs_to@
index 84d3d7c1c4fb8bf436bd31f17e7264d135cb0fcd..ffb34fbb78e3ee8408d0571f815b833857d16ab3 100644 (file)
@@ -1,3 +1,7 @@
+2017-09-21  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * readelf.c (get_machine_flags) <E_MIPS_MACH_5900>: New case.
+
 2017-09-15  Nick Clifton  <nickc@redhat.com>
 
        2.29.1 Release
index fb16df8e2a9bf609f52f8a0f1cc73f51dacbb51e..41f128ed2343146cfaa2fd33662ead57f15c5dd0 100644 (file)
@@ -3325,6 +3325,7 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
            case E_MIPS_MACH_4650: strcat (buf, ", 4650"); break;
            case E_MIPS_MACH_5400: strcat (buf, ", 5400"); break;
            case E_MIPS_MACH_5500: strcat (buf, ", 5500"); break;
+           case E_MIPS_MACH_5900: strcat (buf, ", 5900"); break;
            case E_MIPS_MACH_SB1:  strcat (buf, ", sb1");  break;
            case E_MIPS_MACH_9000: strcat (buf, ", 9000"); break;
            case E_MIPS_MACH_LS2E: strcat (buf, ", loongson-2e"); break;
index 42a676f59827ee1c6ec53dc1b5e2b33aaca2714f..9aa3dbca3abd7b1668b77d34291ebfccc17f5feb 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-21  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * testsuite/gas/mips/elf_mach_5900.d: New test.
+       * testsuite/gas/mips/mips.exp: Run it.
+
 2017-09-15  Nick Clifton  <nickc@redhat.com>
 
        2.29.1 Release
diff --git a/gas/testsuite/gas/mips/elf_mach_5900.d b/gas/testsuite/gas/mips/elf_mach_5900.d
new file mode 100644 (file)
index 0000000..1df668e
--- /dev/null
@@ -0,0 +1,22 @@
+#readelf: -Ah
+#name: ELF R5900 markings
+#as: -32 -march=r5900
+#source: empty.s
+
+ELF Header:
+#...
+  Flags: +0x..92...., .*5900.*
+#...
+
+MIPS ABI Flags Version: 0
+
+ISA: MIPS3
+GPR size: 32
+CPR1 size: 32
+CPR2 size: 0
+FP ABI: .*
+ISA Extension: Toshiba R5900
+ASEs:
+       None
+FLAGS 1: .*
+FLAGS 2: .*
index c71dca4351d75b7abd746d3a252dd955fbd0836c..25221ae2af2096c1b2898995418b71ccde597130 100644 (file)
@@ -1149,6 +1149,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "elf_ase_micromips-2"
 
     # Verify that machine markings are handled properly.
+    run_dump_test "elf_mach_5900"
     run_dump_test "elf_mach_interaptiv-mr2"
 
     run_dump_test "mips-gp32-fp32-pic"
index 6071f8977a88c640b3e9c474b3cfa705a20f9e72..622a63a21428800f8cd77cc6ee08d44bb1303665 100644 (file)
@@ -1,3 +1,26 @@
+2017-10-18  Kyle Butt  <iteratee@google.com>
+           Alan Modra  <amodra@gmail.com>
+
+       * powerpc.cc (Target_powerpc::Scan::local): Correct dst_off
+       calculation for TOC16 relocs.
+       (Target_powerpc::Scan::global): Likewise.
+
+2017-09-28  Alan Modra  <amodra@gmail.com>
+
+       * powerpc.cc (Target_powerpc<64,*>::powerpc_info): Set
+       is_default_stack_executable false.
+
+2017-08-03  James Clarke  <jrtc27@jrtc27.com>
+
+       * options.h (General_options): Set a non-NULL second help string
+       argument for relax to allow --no-relax.
+
+2017-09-20  Alan Modra  <amodra@gmail.com>
+
+       * powerpc.cc (Target_powerpc::Branch_info::make_stub): Put
+       stubs for ppc32 non-branch relocs in first stub table.
+       (Target_powerpc::Relocate::relocate): Resolve similarly.
+
 2017-09-19  Alan Modra  <amodra@gmail.com>
 
        * options.h (stub-group-multi): Default to true.  Add
index 576b2a3c536ea17d7594d1253cfd07bb01b1cd99..4a802cf41fef376bcd7a047bd93f274a85ce1ca6 100644 (file)
@@ -1164,7 +1164,8 @@ class General_options
              N_("Generate relocatable output"), NULL);
 
   DEFINE_bool(relax, options::TWO_DASHES, '\0', false,
-             N_("Relax branches on certain targets"), NULL);
+             N_("Relax branches on certain targets"),
+             N_("Do not relax branches"));
 
   DEFINE_string(retain_symbols_file, options::TWO_DASHES, '\0', NULL,
                N_("keep only symbols listed in this file"), N_("FILE"));
index 629da4f8a12c905b4212211b3cac31d0c51a8088..b5db66549efa5910ecbcc3c47b51edf05bfa425e 100644 (file)
@@ -1618,7 +1618,7 @@ Target::Target_info Target_powerpc<64, true>::powerpc_info =
   false,               // has_make_symbol
   true,                        // has_resolve
   false,               // has_code_fill
-  true,                        // is_default_stack_executable
+  false,               // is_default_stack_executable
   false,               // can_icf_inline_merge_sections
   '\0',                        // wrap_char
   "/usr/lib/ld.so.1",  // dynamic_linker
@@ -1646,7 +1646,7 @@ Target::Target_info Target_powerpc<64, false>::powerpc_info =
   false,               // has_make_symbol
   true,                        // has_resolve
   false,               // has_code_fill
-  true,                        // is_default_stack_executable
+  false,               // is_default_stack_executable
   false,               // can_icf_inline_merge_sections
   '\0',                        // wrap_char
   "/usr/lib/ld.so.1",  // dynamic_linker
@@ -3065,11 +3065,17 @@ Target_powerpc<size, big_endian>::Branch_info::make_stub(
        target->glink_section()->add_global_entry(gsym);
       else
        {
-         if (stub_table == NULL)
+         if (stub_table == NULL
+             && !(size == 32
+                  && gsym != NULL
+                  && !parameters->options().output_is_position_independent()
+                  && !is_branch_reloc(this->r_type_)))
            stub_table = this->object_->stub_table(this->shndx_);
          if (stub_table == NULL)
            {
-             // This is a ref from a data section to an ifunc symbol.
+             // This is a ref from a data section to an ifunc symbol,
+             // or a non-branch reloc for which we always want to use
+             // one set of stubs for resolving function addresses.
              stub_table = ifunc_stub_table;
            }
          gold_assert(stub_table != NULL);
@@ -6643,7 +6649,7 @@ Target_powerpc<size, big_endian>::Scan::local(
          shndx = ppc_object->adjust_sym_shndx(r_sym, shndx, &is_ordinary);
          if (is_ordinary && shndx == ppc_object->toc_shndx())
            {
-             Address dst_off = lsym.get_st_value() + reloc.get_r_offset();
+             Address dst_off = lsym.get_st_value() + reloc.get_r_addend();
              if (dst_off < ppc_object->section_size(shndx))
                {
                  bool ok = false;
@@ -7311,7 +7317,7 @@ Target_powerpc<size, big_endian>::Scan::global(
              if (shndx == sym_object->toc_shndx())
                {
                  Sized_symbol<size>* sym = symtab->get_sized_symbol<size>(gsym);
-                 Address dst_off = sym->value() + reloc.get_r_offset();
+                 Address dst_off = sym->value() + reloc.get_r_addend();
                  if (dst_off < sym_object->section_size(shndx))
                    {
                      bool ok = false;
@@ -8052,11 +8058,20 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
        }
       else
        {
-         Stub_table<size, big_endian>* stub_table
-           = object->stub_table(relinfo->data_shndx);
+         Stub_table<size, big_endian>* stub_table = NULL;
+         if (target->stub_tables().size() == 1)
+           stub_table = target->stub_tables()[0];
+         if (stub_table == NULL
+             && !(size == 32
+                  && gsym != NULL
+                  && !parameters->options().output_is_position_independent()
+                  && !is_branch_reloc(r_type)))
+           stub_table = object->stub_table(relinfo->data_shndx);
          if (stub_table == NULL)
            {
-             // This is a ref from a data section to an ifunc symbol.
+             // This is a ref from a data section to an ifunc symbol,
+             // or a non-branch reloc for which we always want to use
+             // one set of stubs for resolving function addresses.
              if (target->stub_tables().size() != 0)
                stub_table = target->stub_tables()[0];
            }
index 73e05b618e496bf77eb4083cb11ac7ce5f95d314..ba67e20bf90d8b4de96ff39f0b7d69e51402b9a9 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-28  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/ld-plugin/pr22220.h,
+       * testsuite/ld-plugin/pr22220lib.cc,
+       * testsuite/ld-plugin/pr22220lib.ver,
+       * testsuite/ld-plugin/pr22220main.cc: New test.
+       * testsuite/ld-plugin/lto.exp: Run it.
+
 2017-09-19  Nick Clifton  <nickc@redhat.com>
 
        2.29.1 Release
index f0bc345f2c76b3fb1ed44b4354089932e1a45253..6b7ad536fbc6652386469813f5f067f688534ac9 100644 (file)
@@ -295,6 +295,12 @@ set lto_link_elf_tests [list \
   [list "Build pr21382.so" \
    "-shared" "-O2 -fpic" \
    {pr21382b.c} {} "pr21382.so" "c"] \
+  [list {Build pr22220lib.so} \
+   {-shared -Wl,--version-script=pr22220lib.ver} {-fPIC} \
+   {pr22220lib.cc} {} {pr22220lib.so} {c++}] \
+  [list {Build pr22220main.o} \
+   {} {-flto} \
+   {pr22220main.cc} {} {} {c++}] \
 ]
 
 # Check final symbols in executables.
@@ -396,6 +402,12 @@ set lto_run_elf_shared_tests [list \
   [list "Run pr21382" \
    "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr21382a.o tmpdir/pr21382.so" "" \
    {dummy.c} "pr21382.exe" "pass.out" "" "c"] \
+  [list {pr22220a} \
+   {-flto -fuse-linker-plugin tmpdir/pr22220main.o tmpdir/pr22220lib.so} {} \
+   {dummy.c} {pr22220a.exe} {pass.out} {} {c++}] \
+  [list {pr22220b} \
+   {-flto -fuse-linker-plugin -Wl,--no-as-needed tmpdir/pr22220lib.so tmpdir/pr22220main.o} {} \
+   {dummy.c} {pr22220b.exe} {pass.out} {} {c++}] \
 ]
 
 # LTO run-time tests for ELF
diff --git a/ld/testsuite/ld-plugin/pr22220.h b/ld/testsuite/ld-plugin/pr22220.h
new file mode 100644 (file)
index 0000000..b15b45c
--- /dev/null
@@ -0,0 +1,8 @@
+extern int doo();
+
+inline int *goo() {
+       static int xyz;
+       return &xyz;
+}
+
+int *boo();
diff --git a/ld/testsuite/ld-plugin/pr22220lib.cc b/ld/testsuite/ld-plugin/pr22220lib.cc
new file mode 100644 (file)
index 0000000..771f44f
--- /dev/null
@@ -0,0 +1,6 @@
+#include "pr22220.h"
+
+int* boo()
+{
+  return goo ();
+}
diff --git a/ld/testsuite/ld-plugin/pr22220lib.ver b/ld/testsuite/ld-plugin/pr22220lib.ver
new file mode 100644 (file)
index 0000000..6da7e1a
--- /dev/null
@@ -0,0 +1 @@
+BAR { global: *; };
diff --git a/ld/testsuite/ld-plugin/pr22220main.cc b/ld/testsuite/ld-plugin/pr22220main.cc
new file mode 100644 (file)
index 0000000..38c206f
--- /dev/null
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "pr22220.h"
+
+int main()
+{
+  if (boo() == goo())
+    {
+      printf ("PASS\n");
+      return 0;
+    }
+  return 1;
+}