]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf64-ppc.c
PR 21412, get_reloc_section assumes .rel/.rela name for SHT_REL/RELA.
[thirdparty/binutils-gdb.git] / bfd / elf64-ppc.c
index 386db9a0dfea73f4bc5922bc54272648fa22e665..2e8f338748b0dd551c2d2e505d9ec6708219bf9d 100644 (file)
@@ -121,6 +121,7 @@ static bfd_vma opd_entry_value
 #define elf_backend_special_sections         ppc64_elf_special_sections
 #define elf_backend_merge_symbol_attribute    ppc64_elf_merge_symbol_attribute
 #define elf_backend_merge_symbol             ppc64_elf_merge_symbol
+#define elf_backend_get_reloc_section        bfd_get_section_by_name
 
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
@@ -7651,7 +7652,7 @@ tocsave_find (struct ppc_link_hash_table *htab,
   if (ent.sec == NULL || ent.sec->output_section == NULL)
     {
       _bfd_error_handler
-       (_("%B: undefined symbol on R_PPC64_TOCSAVE relocation"));
+       (_("%B: undefined symbol on R_PPC64_TOCSAVE relocation"), ibfd);
       return NULL;
     }
 
@@ -9695,6 +9696,7 @@ ensure_undefweak_dynamic (struct bfd_link_info *info,
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   if (htab->dynamic_sections_created
+      && info->dynamic_undefined_weak != 0
       && h->root.type == bfd_link_hash_undefweak
       && h->dynindx == -1
       && !h->forced_local
@@ -9785,10 +9787,19 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
        allocate_got (h, info, gent);
       }
 
+  /* If no dynamic sections we can't have dynamic relocs, except for
+     IFUNCs which are handled even in static executables.  */
   if (!htab->elf.dynamic_sections_created
       && h->type != STT_GNU_IFUNC)
     eh->dyn_relocs = NULL;
 
+  /* Also discard relocs on undefined weak syms with non-default
+     visibility, or when dynamic_undefined_weak says so.  */
+  else if (h->root.type == bfd_link_hash_undefweak
+          && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+              || info->dynamic_undefined_weak == 0))
+    eh->dyn_relocs = NULL;
+
   if (eh->dyn_relocs != NULL)
     {
       struct elf_dyn_relocs *p, **pp;
@@ -9821,17 +9832,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
                }
            }
 
-         /* Also discard relocs on undefined weak syms with
-            non-default visibility.  */
-         if (eh->dyn_relocs != NULL
-             && h->root.type == bfd_link_hash_undefweak)
+         if (eh->dyn_relocs != NULL)
            {
-             if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
-               eh->dyn_relocs = NULL;
-
              /* Make sure this symbol is output as a dynamic symbol.
                 Undefined weak syms won't yet be marked as dynamic.  */
-             else if (!ensure_undefweak_dynamic (info, h))
+             if (!ensure_undefweak_dynamic (info, h))
                return FALSE;
            }
        }
@@ -14320,7 +14325,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
              addend = 0;
              reloc_dest = DEST_STUB;
 
-             if ((stub_entry->stub_type == ppc_stub_plt_call
+             if ((stub_entry->stub_type == ppc_stub_plt_call
                   || stub_entry->stub_type == ppc_stub_plt_call_r2save)
                  && (ALWAYS_EMIT_R2SAVE
                      || stub_entry->stub_type == ppc_stub_plt_call_r2save)