Blame SOURCES/binutils-aarch64-condbranch-relocs.patch

d1152b
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.35/bfd/elfnn-aarch64.c
d1152b
--- binutils.orig/bfd/elfnn-aarch64.c	2020-09-10 17:03:31.738458044 +0100
d1152b
+++ binutils-2.35/bfd/elfnn-aarch64.c	2020-09-10 17:04:03.643344898 +0100
d1152b
@@ -5445,7 +5445,6 @@ elfNN_aarch64_final_link_relocate (reloc
d1152b
   bfd_vma orig_value = value;
d1152b
   bfd_boolean resolved_to_zero;
d1152b
   bfd_boolean abs_symbol_p;
d1152b
-  bfd_boolean via_plt_p;
d1152b
 
d1152b
   globals = elf_aarch64_hash_table (info);
d1152b
 
d1152b
@@ -5467,8 +5466,6 @@ elfNN_aarch64_final_link_relocate (reloc
d1152b
 		  : bfd_is_und_section (sym_sec));
d1152b
   abs_symbol_p = h != NULL && bfd_is_abs_symbol (&h->root);
d1152b
 
d1152b
-  via_plt_p = (globals->root.splt != NULL && h != NULL
d1152b
-	       && h->plt.offset != (bfd_vma) - 1);
d1152b
 
d1152b
   /* Since STT_GNU_IFUNC symbol must go through PLT, we handle
d1152b
      it here if it is defined in a non-shared object.  */
d1152b
@@ -5805,23 +5802,12 @@ elfNN_aarch64_final_link_relocate (reloc
d1152b
 	value += signed_addend;
d1152b
       break;
d1152b
 
d1152b
-    case BFD_RELOC_AARCH64_BRANCH19:
d1152b
-    case BFD_RELOC_AARCH64_TSTBR14:
d1152b
-      /* A conditional branch to an undefined weak symbol is converted to a
d1152b
-	 branch to itself.  */
d1152b
-      if (weak_undef_p && !via_plt_p)
d1152b
-	{
d1152b
-	  value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type,
d1152b
-						       place, value,
d1152b
-						       signed_addend,
d1152b
-						       weak_undef_p);
d1152b
-	  break;
d1152b
-	}
d1152b
-      /* Fall through.  */
d1152b
     case BFD_RELOC_AARCH64_CALL26:
d1152b
     case BFD_RELOC_AARCH64_JUMP26:
d1152b
       {
d1152b
 	asection *splt = globals->root.splt;
d1152b
+	bfd_boolean via_plt_p =
d1152b
+	  splt != NULL && h != NULL && h->plt.offset != (bfd_vma) - 1;
d1152b
 
d1152b
 	/* A call to an undefined weak symbol is converted to a jump to
d1152b
 	   the next instruction unless a PLT entry will be created.
d1152b
@@ -5902,6 +5888,23 @@ elfNN_aarch64_final_link_relocate (reloc
d1152b
 	  bfd_set_error (bfd_error_bad_value);
d1152b
 	  return bfd_reloc_notsupported;
d1152b
 	}
d1152b
+      value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type,
d1152b
+						   place, value,
d1152b
+						   signed_addend,
d1152b
+						   weak_undef_p);
d1152b
+      break;
d1152b
+
d1152b
+    case BFD_RELOC_AARCH64_BRANCH19:
d1152b
+    case BFD_RELOC_AARCH64_TSTBR14:
d1152b
+      if (h && h->root.type == bfd_link_hash_undefined)
d1152b
+	{
d1152b
+	  _bfd_error_handler
d1152b
+	    /* xgettext:c-format */
d1152b
+	    (_("%pB: conditional branch to undefined symbol `%s' "
d1152b
+	       "not allowed"), input_bfd, h->root.root.string);
d1152b
+	  bfd_set_error (bfd_error_bad_value);
d1152b
+	  return bfd_reloc_notsupported;
d1152b
+	}
d1152b
       /* Fall through.  */
d1152b
 
d1152b
     case BFD_RELOC_AARCH64_16:
d1152b
@@ -7967,8 +7970,6 @@ elfNN_aarch64_check_relocs (bfd *abfd, s
d1152b
 	    break;
d1152b
 	  }
d1152b
 
d1152b
-	case BFD_RELOC_AARCH64_BRANCH19:
d1152b
-	case BFD_RELOC_AARCH64_TSTBR14:
d1152b
 	case BFD_RELOC_AARCH64_CALL26:
d1152b
 	case BFD_RELOC_AARCH64_JUMP26:
d1152b
 	  /* If this is a local symbol then we resolve it
d1152b
Only in binutils-2.35/bfd: elfnn-aarch64.c.orig
d1152b
diff -rup binutils.orig/ld/testsuite/ld-aarch64/emit-relocs-560.d binutils-2.35/ld/testsuite/ld-aarch64/emit-relocs-560.d
d1152b
--- binutils.orig/ld/testsuite/ld-aarch64/emit-relocs-560.d	2020-09-10 17:03:31.067460424 +0100
d1152b
+++ binutils-2.35/ld/testsuite/ld-aarch64/emit-relocs-560.d	2020-09-10 17:04:03.644344895 +0100
d1152b
@@ -1,8 +1,3 @@
d1152b
 #source: emit-relocs-560.s
d1152b
 #ld: -shared
d1152b
-#readelf: -r
d1152b
-
d1152b
-Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 2 entries:
d1152b
-  Offset          Info           Type           Sym. Value    Sym. Name \+ Addend
d1152b
-[0-9a-f]+  000100000402 R_AARCH64_JUMP_SL 0000000000000000 baz \+ 0
d1152b
-[0-9a-f]+  000200000402 R_AARCH64_JUMP_SL 0000000000000000 bar \+ 0
d1152b
+#error: .*: conditional branch to undefined symbol `bar' not allowed