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

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