gdb/
[binutils-gdb.git] / bfd / elf64-aarch64.c
index feb1a006ff198cc6e8bb21b6071eceff85c31c90..aef472f2e8bc017e376756e1a7626c8371b249c0 100644 (file)
@@ -4306,6 +4306,14 @@ elf64_aarch64_relocate_section (bfd *output_bfd,
       bfd_reloc.howto = elf64_aarch64_howto_from_type (r_type);
       howto = bfd_reloc.howto;
 
+      if (howto == NULL)
+       {
+         (*_bfd_error_handler)
+           (_("%B: unrecognized relocation (0x%x) in section `%A'"),
+            input_bfd, input_section, r_type);
+         return FALSE;
+       }
+
       h = NULL;
       sym = NULL;
       sec = NULL;
@@ -4330,12 +4338,6 @@ elf64_aarch64_relocate_section (bfd *output_bfd,
                return FALSE;
            }
 
-         if (r_type >= R_AARCH64_dyn_max)
-           {
-             bfd_set_error (bfd_error_bad_value);
-             return FALSE;
-           }
-
          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
@@ -4869,16 +4871,15 @@ elf64_aarch64_print_private_bfd_data (bfd *abfd, void *ptr)
 /* Update the got entry reference counts for the section being removed.  */
 
 static bfd_boolean
-elf64_aarch64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-                            struct bfd_link_info *info ATTRIBUTE_UNUSED,
-                            asection *sec ATTRIBUTE_UNUSED,
-                            const Elf_Internal_Rela *
-                            relocs ATTRIBUTE_UNUSED)
+elf64_aarch64_gc_sweep_hook (bfd *abfd,
+                            struct bfd_link_info *info,
+                            asection *sec,
+                            const Elf_Internal_Rela * relocs)
 {
   struct elf64_aarch64_link_hash_table *htab;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
-  bfd_signed_vma *local_got_refcounts;
+  struct elf_aarch64_local_symbol *locals;
   const Elf_Internal_Rela *rel, *relend;
 
   if (info->relocatable)
@@ -4894,7 +4895,7 @@ elf64_aarch64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
   symtab_hdr = &elf_symtab_hdr (abfd);
   sym_hashes = elf_sym_hashes (abfd);
 
-  local_got_refcounts = elf_local_got_refcounts (abfd);
+  locals = elf64_aarch64_locals (abfd);
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
@@ -4965,10 +4966,10 @@ elf64_aarch64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
              if (h->got.refcount > 0)
                h->got.refcount -= 1;
            }
-         else if (local_got_refcounts != NULL)
+         else if (locals != NULL)
            {
-             if (local_got_refcounts[r_symndx] > 0)
-               local_got_refcounts[r_symndx] -= 1;
+             if (locals[r_symndx].got_refcount > 0)
+               locals[r_symndx].got_refcount -= 1;
            }
          break;
 
@@ -5142,8 +5143,6 @@ elf64_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
   struct elf64_aarch64_link_hash_table *htab;
 
-  unsigned long nsyms;
-
   if (info->relocatable)
     return TRUE;
 
@@ -5154,7 +5153,6 @@ elf64_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
   symtab_hdr = &elf_symtab_hdr (abfd);
   sym_hashes = elf_sym_hashes (abfd);
-  nsyms = NUM_SHDR_ENTRIES (symtab_hdr);
 
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
@@ -5173,18 +5171,7 @@ elf64_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          return FALSE;
        }
 
-      if (r_symndx >= nsyms
-         /* PR 9934: It is possible to have relocations that do not
-            refer to symbols, thus it is also possible to have an
-            object file containing relocations but no symbol table.  */
-         && (r_symndx > 0 || nsyms > 0))
-       {
-         (*_bfd_error_handler) (_("%B: bad symbol index: %d"), abfd,
-                                r_symndx);
-         return FALSE;
-       }
-
-      if (nsyms == 0 || r_symndx < symtab_hdr->sh_info)
+      if (r_symndx < symtab_hdr->sh_info)
        h = NULL;
       else
        {
@@ -5192,6 +5179,10 @@ elf64_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *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;
+
+         /* PR15323, ref flags aren't set for references in the same
+            object.  */
+         h->root.non_ir_ref = 1;
        }
 
       /* Could be done earlier, if h were already available.  */
@@ -7190,6 +7181,7 @@ const struct elf_size_info elf64_aarch64_size_info =
 #define elf_backend_may_use_rela_p     1
 #define elf_backend_default_use_rela_p 1
 #define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3)
+#define elf_backend_default_execstack  0
 
 #undef  elf_backend_obj_attrs_section
 #define elf_backend_obj_attrs_section          ".ARM.attributes"