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