3c3e148
--- binutils-2.25.orig/bfd/elfnn-aarch64.c	2015-07-02 14:38:44.178894336 +0100
3c3e148
+++ binutils-2.25/bfd/elfnn-aarch64.c	2015-07-02 14:40:39.341603064 +0100
3c3e148
@@ -4426,16 +4426,36 @@ elfNN_aarch64_final_link_relocate (reloc
3c3e148
 						   signed_addend, weak_undef_p);
3c3e148
       break;
3c3e148
 
3c3e148
+    case BFD_RELOC_AARCH64_16_PCREL:
3c3e148
+    case BFD_RELOC_AARCH64_32_PCREL:
3c3e148
+    case BFD_RELOC_AARCH64_64_PCREL:
3c3e148
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
3c3e148
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
3c3e148
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
3c3e148
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
3c3e148
+      if (info->shared
3c3e148
+	  && (input_section->flags & SEC_ALLOC) != 0
3c3e148
+	  && (input_section->flags & SEC_READONLY) != 0
3c3e148
+	  && h != NULL
3c3e148
+	  && !h->def_regular)
3c3e148
+	{
3c3e148
+	  int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
3c3e148
+
3c3e148
+	  (*_bfd_error_handler)
3c3e148
+	    (_("%B: relocation %s against external symbol `%s' can not be used"
3c3e148
+	       " when making a shared object; recompile with -fPIC"),
3c3e148
+	     input_bfd, elfNN_aarch64_howto_table[howto_index].name,
3c3e148
+	     h->root.root.string);
3c3e148
+	  bfd_set_error (bfd_error_bad_value);
3c3e148
+	  return FALSE;
3c3e148
+	}
3c3e148
+      /* Fall through.  */
3c3e148
     case BFD_RELOC_AARCH64_16:
3c3e148
 #if ARCH_SIZE == 64
3c3e148
     case BFD_RELOC_AARCH64_32:
3c3e148
 #endif
3c3e148
     case BFD_RELOC_AARCH64_ADD_LO12:
3c3e148
-    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
3c3e148
-    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
3c3e148
-    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
3c3e148
     case BFD_RELOC_AARCH64_BRANCH19:
3c3e148
-    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
3c3e148
     case BFD_RELOC_AARCH64_LDST8_LO12:
3c3e148
     case BFD_RELOC_AARCH64_LDST16_LO12:
3c3e148
     case BFD_RELOC_AARCH64_LDST32_LO12:
3c3e148
@@ -4451,9 +4471,6 @@ elfNN_aarch64_final_link_relocate (reloc
3c3e148
     case BFD_RELOC_AARCH64_MOVW_G2:
3c3e148
     case BFD_RELOC_AARCH64_MOVW_G2_NC:
3c3e148
     case BFD_RELOC_AARCH64_MOVW_G3:
3c3e148
-    case BFD_RELOC_AARCH64_16_PCREL:
3c3e148
-    case BFD_RELOC_AARCH64_32_PCREL:
3c3e148
-    case BFD_RELOC_AARCH64_64_PCREL:
3c3e148
     case BFD_RELOC_AARCH64_TSTBR14:
3c3e148
       value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
3c3e148
 						   signed_addend, weak_undef_p);