Implement a workaround for GNU mak jobserver
[deliverable/binutils-gdb.git] / bfd / elfnn-aarch64.c
index 2c88f288c3ac3b4f857fb4c8e07dde68b23e042b..1ec405ef1e00456371f6b301b6e1c63306cc753b 100644 (file)
@@ -1,5 +1,5 @@
 /* AArch64-specific support for NN-bit ELF.
-   Copyright (C) 2009-2020 Free Software Foundation, Inc.
+   Copyright (C) 2009-2021 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -2854,11 +2854,11 @@ elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info,
 
 static void
 elfNN_aarch64_merge_symbol_attribute (struct elf_link_hash_entry *h,
-                                     const Elf_Internal_Sym *isym,
+                                     unsigned int st_other,
                                      bfd_boolean definition ATTRIBUTE_UNUSED,
                                      bfd_boolean dynamic ATTRIBUTE_UNUSED)
 {
-  unsigned int isym_sto = isym->st_other & ~ELF_ST_VISIBILITY (-1);
+  unsigned int isym_sto = st_other & ~ELF_ST_VISIBILITY (-1);
   unsigned int h_sto = h->other & ~ELF_ST_VISIBILITY (-1);
 
   if (isym_sto == h_sto)
@@ -3925,8 +3925,9 @@ _bfd_aarch64_erratum_835769_scan (bfd *input_bfd,
 
       sec_data = elf_aarch64_section_data (section);
 
-      qsort (sec_data->map, sec_data->mapcount,
-            sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping);
+      if (sec_data->mapcount)
+       qsort (sec_data->map, sec_data->mapcount,
+              sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping);
 
       for (span = 0; span < sec_data->mapcount; span++)
        {
@@ -4209,8 +4210,9 @@ _bfd_aarch64_erratum_843419_scan (bfd *input_bfd, asection *section,
 
       sec_data = elf_aarch64_section_data (section);
 
-      qsort (sec_data->map, sec_data->mapcount,
-            sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping);
+      if (sec_data->mapcount)
+       qsort (sec_data->map, sec_data->mapcount,
+              sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping);
 
       for (span = 0; span < sec_data->mapcount; span++)
        {
@@ -5445,7 +5447,6 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
   bfd_vma orig_value = value;
   bfd_boolean resolved_to_zero;
   bfd_boolean abs_symbol_p;
-  bfd_boolean via_plt_p;
 
   globals = elf_aarch64_hash_table (info);
 
@@ -5467,8 +5468,6 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
                  : bfd_is_und_section (sym_sec));
   abs_symbol_p = h != NULL && bfd_is_abs_symbol (&h->root);
 
-  via_plt_p = (globals->root.splt != NULL && h != NULL
-              && h->plt.offset != (bfd_vma) - 1);
 
   /* Since STT_GNU_IFUNC symbol must go through PLT, we handle
      it here if it is defined in a non-shared object.  */
@@ -5804,23 +5803,12 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
        value += signed_addend;
       break;
 
-    case BFD_RELOC_AARCH64_BRANCH19:
-    case BFD_RELOC_AARCH64_TSTBR14:
-      /* A conditional branch to an undefined weak symbol is converted to a
-        branch to itself.  */
-      if (weak_undef_p && !via_plt_p)
-       {
-         value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type,
-                                                      place, value,
-                                                      signed_addend,
-                                                      weak_undef_p);
-         break;
-       }
-      /* Fall through.  */
     case BFD_RELOC_AARCH64_CALL26:
     case BFD_RELOC_AARCH64_JUMP26:
       {
        asection *splt = globals->root.splt;
+       bfd_boolean via_plt_p =
+         splt != NULL && h != NULL && h->plt.offset != (bfd_vma) - 1;
 
        /* A call to an undefined weak symbol is converted to a jump to
           the next instruction unless a PLT entry will be created.
@@ -5901,6 +5889,23 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
          bfd_set_error (bfd_error_bad_value);
          return bfd_reloc_notsupported;
        }
+      value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type,
+                                                  place, value,
+                                                  signed_addend,
+                                                  weak_undef_p);
+      break;
+
+    case BFD_RELOC_AARCH64_BRANCH19:
+    case BFD_RELOC_AARCH64_TSTBR14:
+      if (h && h->root.type == bfd_link_hash_undefined)
+       {
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%pB: conditional branch to undefined symbol `%s' "
+              "not allowed"), input_bfd, h->root.root.string);
+         bfd_set_error (bfd_error_bad_value);
+         return bfd_reloc_notsupported;
+       }
       /* Fall through.  */
 
     case BFD_RELOC_AARCH64_16:
@@ -7137,7 +7142,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
 
                 Try to catch this situation here and provide a more helpful
                 error message to the user.  */
-             if (addend & ((1 << howto->rightshift) - 1)
+             if (addend & (((bfd_vma) 1 << howto->rightshift) - 1)
                  /* FIXME: Are we testing all of the appropriate reloc
                     types here ?  */
                  && (real_r_type == BFD_RELOC_AARCH64_LD_LO19_PCREL
@@ -7326,10 +7331,10 @@ elfNN_aarch64_print_private_bfd_data (bfd *abfd, void *ptr)
      containing valid data.  */
 
   /* xgettext:c-format */
-  fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+  fprintf (file, _("private flags = 0x%lx:"), elf_elfheader (abfd)->e_flags);
 
   if (flags)
-    fprintf (file, _("<Unrecognised flag bits set>"));
+    fprintf (file, _(" <Unrecognised flag bits set>"));
 
   fputc ('\n', file);
 
@@ -7966,8 +7971,6 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
            break;
          }
 
-       case BFD_RELOC_AARCH64_BRANCH19:
-       case BFD_RELOC_AARCH64_TSTBR14:
        case BFD_RELOC_AARCH64_CALL26:
        case BFD_RELOC_AARCH64_JUMP26:
          /* If this is a local symbol then we resolve it
@@ -9509,8 +9512,11 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   memcpy (htab->root.splt->contents, htab->plt0_entry,
          htab->plt_header_size);
-  elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize =
-    htab->plt_header_size;
+
+  /* PR 26312: Explicitly set the sh_entsize to 0 so that
+     consumers do not think that the section contains fixed
+     sized objects.  */
+  elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize = 0;
 
   plt_got_2nd_ent = (htab->root.sgotplt->output_section->vma
                  + htab->root.sgotplt->output_offset
@@ -9612,10 +9618,6 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
     {
       elfNN_aarch64_init_small_plt0_entry (output_bfd, htab);
 
-      elf_section_data (htab->root.splt->output_section)->
-       this_hdr.sh_entsize = htab->plt_entry_size;
-
-
       if (htab->root.tlsdesc_plt && !(info->flags & DF_BIND_NOW))
        {
          BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1);
This page took 0.02507 seconds and 4 git commands to generate.