]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf64-ppc.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / bfd / elf64-ppc.c
index 4194802d48b3667f7fff7ceca49376a80a080579..a118c32c7978464e6369880fef3ce6433a4f991e 100644 (file)
@@ -1,5 +1,5 @@
 /* PowerPC64-specific support for 64-bit ELF.
-   Copyright (C) 1999-2020 Free Software Foundation, Inc.
+   Copyright (C) 1999-2021 Free Software Foundation, Inc.
    Written by Linus Nordberg, Swox AB <info@swox.com>,
    based on elf32-ppc.c by Ian Lance Taylor.
    Largely rewritten by Alan Modra.
@@ -1715,10 +1715,12 @@ ppc64_elf_unhandled_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 
   if (error_message != NULL)
     {
-      static char buf[60];
-      sprintf (buf, "generic linker can't handle %s",
-              reloc_entry->howto->name);
-      *error_message = buf;
+      static char *message;
+      free (message);
+      if (asprintf (&message, _("generic linker can't handle %s"),
+                   reloc_entry->howto->name) < 0)
+       message = NULL;
+      *error_message = message;
     }
   return bfd_reloc_dangerous;
 }
@@ -2056,7 +2058,7 @@ get_opd_info (asection * sec)
 \f
 /* Parameters for the qsort hook.  */
 static bfd_boolean synthetic_relocatable;
-static asection *synthetic_opd;
+static const asection *synthetic_opd;
 
 /* qsort comparison function for ppc64_elf_get_synthetic_symtab.  */
 
@@ -4152,12 +4154,12 @@ ppc64_elf_add_symbol_hook (bfd *ibfd,
 
 static void
 ppc64_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
-                                 const Elf_Internal_Sym *isym,
+                                 unsigned int st_other,
                                  bfd_boolean definition,
                                  bfd_boolean dynamic)
 {
   if (definition && (!dynamic || !h->def_regular))
-    h->other = ((isym->st_other & ~ELF_ST_VISIBILITY (-1))
+    h->other = ((st_other & ~ELF_ST_VISIBILITY (-1))
                | ELF_ST_VISIBILITY (h->other));
 }
 
@@ -11678,6 +11680,7 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
       obfd = htab->params->stub_bfd;
       is_tga = ((stub_entry->stub_type == ppc_stub_plt_call_notoc
                 || stub_entry->stub_type == ppc_stub_plt_call_both)
+               && stub_entry->h != NULL
                && is_tls_get_addr (&stub_entry->h->elf, htab)
                && htab->params->tls_get_addr_opt);
       if (is_tga)
@@ -12188,7 +12191,8 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
     case ppc_stub_plt_call_notoc:
     case ppc_stub_plt_call_both:
       lr_used = 0;
-      if (is_tls_get_addr (&stub_entry->h->elf, htab)
+      if (stub_entry->h != NULL
+         && is_tls_get_addr (&stub_entry->h->elf, htab)
          && htab->params->tls_get_addr_opt)
        {
          lr_used += 7 * 4;
@@ -12258,6 +12262,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
        }
       if ((stub_entry->stub_type == ppc_stub_plt_call_notoc
           || stub_entry->stub_type == ppc_stub_plt_call_both)
+         && stub_entry->h != NULL
          && is_tls_get_addr (&stub_entry->h->elf, htab)
          && htab->params->tls_get_addr_opt)
        {
@@ -14256,8 +14261,6 @@ write_plt_relocs_for_local_syms (struct bfd_link_info *info)
                }
 
              val = sym->st_value + ent->addend;
-             if (ELF_ST_TYPE (sym->st_info) != STT_GNU_IFUNC)
-               val += PPC64_LOCAL_ENTRY_OFFSET (sym->st_other);
              if (sym_sec != NULL && sym_sec->output_section != NULL)
                val += sym_sec->output_offset + sym_sec->output_section->vma;
 
@@ -16090,14 +16093,16 @@ ppc64_elf_relocate_section (bfd *output_bfd,
              && (h == NULL || SYMBOL_REFERENCES_LOCAL (info, &h->elf)))
            {
              insn = bfd_get_32 (input_bfd, contents + (rel->r_offset & ~3));
-             if ((insn & (0x3fu << 26 | 0x3)) == 58u << 26 /* ld */)
+             if (r_type == R_PPC64_GOT16_LO_DS
+                 && (insn & (0x3fu << 26 | 0x3)) == 58u << 26 /* ld */)
                {
                  insn += (14u << 26) - (58u << 26);
                  bfd_put_32 (input_bfd, insn, contents + (rel->r_offset & ~3));
                  r_type = R_PPC64_TOC16_LO;
                  rel->r_info = ELF64_R_INFO (r_symndx, r_type);
                }
-             else if ((insn & (0x3fu << 26)) == 15u << 26 /* addis */)
+             else if (r_type == R_PPC64_GOT16_HA
+                      && (insn & (0x3fu << 26)) == 15u << 26 /* addis */)
                {
                  r_type = R_PPC64_TOC16_HA;
                  rel->r_info = ELF64_R_INFO (r_symndx, r_type);
@@ -17714,7 +17719,9 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
 /* FreeBSD support */
 
 #undef  TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM powerpc_elf64_fbsd_le_vec
 #undef  TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME "elf64-powerpcle-freebsd"
 
 #undef  TARGET_BIG_SYM
 #define TARGET_BIG_SYM powerpc_elf64_fbsd_vec