]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR22300, Abort in elf32_hppa_relocate_section building polyml
authorAlan Modra <amodra@gmail.com>
Sat, 28 Oct 2017 03:40:55 +0000 (14:10 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 1 Nov 2017 00:54:53 +0000 (11:24 +1030)
polyml produces object files with the wrong OS/ABI for hppa-linux.
This, along with the fact that elf32-hppa.c is using the strictest
backend relocs_compatible, results in wrong merging of ELF symbols.

So, remove the relocs_compatible check in _bfd_elf_merge_symbol.
_bfd_elf_merge_symbol is only called nowadays from within blocks
protected by is_elf_hash_table, so "we are doing an ELF link" as the
removed comment says, is true.

Also relax relocs_compatible for hppa and powerpc.  relocs_compatible
is used for more than just merging symbols, as the name suggests.
This allows objects that are in fact reasonably compatible to be
linked.

PR 22300
* elflink.c (_bfd_elf_merge_symbol): Remove relocs_compatible check.
* elf32-hppa.c (elf_backend_relocs_compatible): Define.
* elf32-ppc.c (elf_backend_relocs_compatible): Define.
* elf64-ppc.c (elf_backend_relocs_compatible): Define.

(cherry picked from commit c0e331c794d6bd75d9be9bea6145513074c33f39)

bfd/ChangeLog
bfd/elf32-hppa.c
bfd/elf32-ppc.c
bfd/elf64-ppc.c
bfd/elflink.c

index 320e3f5ff75ad0c00928f73596b31398a60996aa..ea035e76ff4d2dc282439a208a70c64782af819a 100644 (file)
@@ -1,6 +1,13 @@
 2017-11-01  Alan Modra  <amodra@gmail.com>
 
        Apply from master
+       2017-10-28  Alan Modra  <amodra@gmail.com>
+       PR 22300
+       * elflink.c (_bfd_elf_merge_symbol): Remove relocs_compatible check.
+       * elf32-hppa.c (elf_backend_relocs_compatible): Define.
+       * elf32-ppc.c (elf_backend_relocs_compatible): Define.
+       * elf64-ppc.c (elf_backend_relocs_compatible): Define.
+
        2017-10-25  Alan Modra  <amodra@gmail.com>
        * archive.c (_bfd_compute_and_write_armap): Match "__gnu_lto_slim"
        optionally prefixed with "_".
index 548d656776a0f6f257480984b96aeee0a8a85eb8..62a689ae5e5f451fd942b9639727a95ce820c5ea 100644 (file)
@@ -4615,6 +4615,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
 #define elf_backend_adjust_dynamic_symbol    elf32_hppa_adjust_dynamic_symbol
 #define elf_backend_copy_indirect_symbol     elf32_hppa_copy_indirect_symbol
 #define elf_backend_check_relocs            elf32_hppa_check_relocs
+#define elf_backend_relocs_compatible       _bfd_elf_relocs_compatible
 #define elf_backend_create_dynamic_sections  elf32_hppa_create_dynamic_sections
 #define elf_backend_fake_sections           elf_hppa_fake_sections
 #define elf_backend_relocate_section        elf32_hppa_relocate_section
index f9a32c2e87411b77969264a05323a59c4267242c..3f42f2a4d8e7050d5e53fbba7f0e1b326b4bdae8 100644 (file)
@@ -10931,6 +10931,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
 #define elf_backend_relocate_section           ppc_elf_relocate_section
 #define elf_backend_create_dynamic_sections    ppc_elf_create_dynamic_sections
 #define elf_backend_check_relocs               ppc_elf_check_relocs
+#define elf_backend_relocs_compatible          _bfd_elf_relocs_compatible
 #define elf_backend_copy_indirect_symbol       ppc_elf_copy_indirect_symbol
 #define elf_backend_adjust_dynamic_symbol      ppc_elf_adjust_dynamic_symbol
 #define elf_backend_add_symbol_hook            ppc_elf_add_symbol_hook
index 277bb0ef5d24f7fe32e064f4ba626657e35f65b1..3c8e2865d79de3cefa822a9cf9dc4fda0798d39d 100644 (file)
@@ -101,6 +101,7 @@ static bfd_vma opd_entry_value
 #define elf_backend_notice_as_needed         ppc64_elf_notice_as_needed
 #define elf_backend_archive_symbol_lookup     ppc64_elf_archive_symbol_lookup
 #define elf_backend_check_relocs             ppc64_elf_check_relocs
+#define elf_backend_relocs_compatible        _bfd_elf_relocs_compatible
 #define elf_backend_gc_keep                  ppc64_elf_gc_keep
 #define elf_backend_gc_mark_dynamic_ref       ppc64_elf_gc_mark_dynamic_ref
 #define elf_backend_gc_mark_hook             ppc64_elf_gc_mark_hook
index 39d878c8146036e1f57218215d54089876dd3a04..245d89c6f4fb917d0a674090569f4b79a314ee81 100644 (file)
@@ -1161,11 +1161,6 @@ _bfd_elf_merge_symbol (bfd *abfd,
   if (pold_weak)
     *pold_weak = oldweak;
 
-  /* This code is for coping with dynamic objects, and is only useful
-     if we are doing an ELF link.  */
-  if (!(*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
-    return TRUE;
-
   /* We have to check it for every instance since the first few may be
      references and not all compilers emit symbol type for undefined
      symbols.  */