Blame SOURCES/binutils-rh1194164.patch

d570a8
diff -Nrup a/bfd/bfd-in2.h b/bfd/bfd-in2.h
d570a8
--- a/bfd/bfd-in2.h	2015-03-31 11:11:36.351939753 -0600
d570a8
+++ b/bfd/bfd-in2.h	2015-03-31 11:12:07.733201604 -0600
d570a8
@@ -3191,6 +3191,7 @@ instruction.  */
d570a8
   BFD_RELOC_PPC64_PLTGOT16_LO_DS,
d570a8
   BFD_RELOC_PPC64_ADDR16_HIGH,
d570a8
   BFD_RELOC_PPC64_ADDR16_HIGHA,
d570a8
+  BFD_RELOC_PPC64_ADDR64_LOCAL,
d570a8
 
d570a8
 /* PowerPC and PowerPC64 thread-local storage relocations.  */
d570a8
   BFD_RELOC_PPC_TLS,
d570a8
diff -Nrup a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
d570a8
--- a/bfd/elf64-ppc.c	2015-03-31 11:11:36.348939823 -0600
d570a8
+++ b/bfd/elf64-ppc.c	2015-03-31 11:12:07.735201557 -0600
d570a8
@@ -2097,6 +2097,21 @@ static reloc_howto_type ppc64_elf_howto_
d570a8
 	 0xffff,		/* dst_mask */
d570a8
 	 FALSE),		/* pcrel_offset */
d570a8
 
d570a8
+  /* Like ADDR64, but use local entry point of function.  */
d570a8
+  HOWTO (R_PPC64_ADDR64_LOCAL,	/* type */
d570a8
+	 0,			/* rightshift */
d570a8
+	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
d570a8
+	 64,			/* bitsize */
d570a8
+	 FALSE,			/* pc_relative */
d570a8
+	 0,			/* bitpos */
d570a8
+	 complain_overflow_dont, /* complain_on_overflow */
d570a8
+	 bfd_elf_generic_reloc,	/* special_function */
d570a8
+	 "R_PPC64_ADDR64_LOCAL", /* name */
d570a8
+	 FALSE,			/* partial_inplace */
d570a8
+	 0,			/* src_mask */
d570a8
+	 ONES (64),		/* dst_mask */
d570a8
+	 FALSE),		/* pcrel_offset */
d570a8
+
d570a8
   /* GNU extension to record C++ vtable hierarchy.  */
d570a8
   HOWTO (R_PPC64_GNU_VTINHERIT,	/* type */
d570a8
 	 0,			/* rightshift */
d570a8
@@ -2385,6 +2400,8 @@ ppc64_elf_reloc_type_lookup (bfd *abfd A
d570a8
       break;
d570a8
     case BFD_RELOC_HI16_S_PCREL:		r = R_PPC64_REL16_HA;
d570a8
       break;
d570a8
+    case BFD_RELOC_PPC64_ADDR64_LOCAL:		r = R_PPC64_ADDR64_LOCAL;
d570a8
+      break;
d570a8
     case BFD_RELOC_VTABLE_INHERIT:		r = R_PPC64_GNU_VTINHERIT;
d570a8
       break;
d570a8
     case BFD_RELOC_VTABLE_ENTRY:		r = R_PPC64_GNU_VTENTRY;
d570a8
@@ -5431,6 +5448,21 @@ ppc64_elf_check_relocs (bfd *abfd, struc
d570a8
 	case R_PPC64_REL16_HA:
d570a8
 	  break;
d570a8
 
d570a8
+	  /* Not supported as a dynamic relocation.  */
d570a8
+	case R_PPC64_ADDR64_LOCAL:
d570a8
+	  if (info->shared)
d570a8
+	    {
d570a8
+	      if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
d570a8
+		ppc_howto_init ();
d570a8
+	      info->callbacks->einfo (_("%P: %H: %s reloc unsupported "
d570a8
+					"in shared libraries and PIEs.\n"),
d570a8
+				      abfd, sec, rel->r_offset,
d570a8
+				      ppc64_elf_howto_table[r_type]->name);
d570a8
+	      bfd_set_error (bfd_error_bad_value);
d570a8
+	      return FALSE;
d570a8
+	    }
d570a8
+	  break;
d570a8
+
d570a8
 	case R_PPC64_TOC16:
d570a8
 	case R_PPC64_TOC16_DS:
d570a8
 	  htab->do_multi_toc = 1;
d570a8
@@ -14162,6 +14194,12 @@ ppc64_elf_relocate_section (bfd *output_
d570a8
 	  addend -= htab->elf.tls_sec->vma + DTP_OFFSET;
d570a8
 	  break;
d570a8
 
d570a8
+	case R_PPC64_ADDR64_LOCAL:
d570a8
+	  addend += PPC64_LOCAL_ENTRY_OFFSET (h != NULL
d570a8
+					      ? h->elf.other
d570a8
+					      : sym->st_other);
d570a8
+	  break;
d570a8
+
d570a8
 	case R_PPC64_DTPMOD64:
d570a8
 	  relocation = 1;
d570a8
 	  addend = 0;
d570a8
diff -Nrup a/bfd/libbfd.h b/bfd/libbfd.h
d570a8
--- a/bfd/libbfd.h	2015-03-31 11:11:36.300940952 -0600
d570a8
+++ b/bfd/libbfd.h	2015-03-31 11:12:07.735201557 -0600
d570a8
@@ -1398,6 +1398,7 @@ static const char *const bfd_reloc_code_
d570a8
   "BFD_RELOC_PPC64_PLTGOT16_LO_DS",
d570a8
   "BFD_RELOC_PPC64_ADDR16_HIGH",
d570a8
   "BFD_RELOC_PPC64_ADDR16_HIGHA",
d570a8
+  "BFD_RELOC_PPC64_ADDR64_LOCAL",
d570a8
   "BFD_RELOC_PPC_TLS",
d570a8
   "BFD_RELOC_PPC_TLSGD",
d570a8
   "BFD_RELOC_PPC_TLSLD",
d570a8
diff -Nrup a/bfd/reloc.c b/bfd/reloc.c
d570a8
--- a/bfd/reloc.c	2015-03-31 11:11:36.300940952 -0600
d570a8
+++ b/bfd/reloc.c	2015-03-31 11:12:07.736201534 -0600
d570a8
@@ -2896,6 +2896,8 @@ ENUMX
d570a8
   BFD_RELOC_PPC64_ADDR16_HIGH
d570a8
 ENUMX
d570a8
   BFD_RELOC_PPC64_ADDR16_HIGHA
d570a8
+ENUMX
d570a8
+  BFD_RELOC_PPC64_ADDR64_LOCAL
d570a8
 ENUMDOC
d570a8
   Power(rs6000) and PowerPC relocations.
d570a8
 
d570a8
diff -Nrup a/elfcpp/powerpc.h b/elfcpp/powerpc.h
d570a8
--- a/elfcpp/powerpc.h	2015-03-31 11:11:36.301940929 -0600
d570a8
+++ b/elfcpp/powerpc.h	2015-03-31 11:12:07.736201534 -0600
d570a8
@@ -176,6 +176,8 @@ enum
d570a8
   R_PPC_EMB_BIT_FLD = 115,
d570a8
   R_PPC64_DTPREL16_HIGHA = 115,
d570a8
   R_PPC_EMB_RELSDA = 116,
d570a8
+  R_PPC64_REL24_NOTOC = 116,
d570a8
+  R_PPC64_ADDR64_LOCAL = 117,
d570a8
 
d570a8
   R_PPC_VLE_REL8 = 216,
d570a8
   R_PPC_VLE_REL15 = 217,
d570a8
diff -Nrup a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
d570a8
--- a/gas/config/tc-ppc.c	2015-03-31 11:11:36.321940458 -0600
d570a8
+++ b/gas/config/tc-ppc.c	2015-03-31 11:12:07.737201510 -0600
d570a8
@@ -1952,6 +1952,7 @@ ppc_elf_suffix (char **str_p, expression
d570a8
     MAP64 ("dtprel@highera",	BFD_RELOC_PPC64_DTPREL16_HIGHERA),
d570a8
     MAP64 ("dtprel@highest",	BFD_RELOC_PPC64_DTPREL16_HIGHEST),
d570a8
     MAP64 ("dtprel@highesta",	BFD_RELOC_PPC64_DTPREL16_HIGHESTA),
d570a8
+    MAP64 ("localentry",	BFD_RELOC_PPC64_ADDR64_LOCAL),
d570a8
     MAP64 ("tprel@high",	BFD_RELOC_PPC64_TPREL16_HIGH),
d570a8
     MAP64 ("tprel@higha",	BFD_RELOC_PPC64_TPREL16_HIGHA),
d570a8
     MAP64 ("tprel@higher",	BFD_RELOC_PPC64_TPREL16_HIGHER),
d570a8
@@ -6868,6 +6869,7 @@ md_apply_fix (fixS *fixP, valueT *valP,
d570a8
 	case BFD_RELOC_PPC64_HIGHEST_S:
d570a8
 	case BFD_RELOC_PPC64_ADDR16_HIGH:
d570a8
 	case BFD_RELOC_PPC64_ADDR16_HIGHA:
d570a8
+	case BFD_RELOC_PPC64_ADDR64_LOCAL:
d570a8
 	  break;
d570a8
 
d570a8
 	case BFD_RELOC_PPC_DTPMOD:
d570a8
diff -Nrup a/include/elf/ppc64.h b/include/elf/ppc64.h
d570a8
--- a/include/elf/ppc64.h	2015-03-31 11:11:36.303940882 -0600
d570a8
+++ b/include/elf/ppc64.h	2015-03-31 11:12:07.740201440 -0600
d570a8
@@ -149,6 +149,10 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_typ
d570a8
   RELOC_NUMBER (R_PPC64_DTPREL16_HIGH,	   114)
d570a8
   RELOC_NUMBER (R_PPC64_DTPREL16_HIGHA,	   115)
d570a8
 
d570a8
+/* Added for ELFv2.  */
d570a8
+  RELOC_NUMBER (R_PPC64_REL24_NOTOC,	   116)
d570a8
+  RELOC_NUMBER (R_PPC64_ADDR64_LOCAL,	   117)
d570a8
+
d570a8
 #ifndef RELOC_MACROS_GEN_FUNC
d570a8
 /* Fake relocation only used internally by ld.  */
d570a8
   RELOC_NUMBER (R_PPC64_LO_DS_OPT,	   128)
d570a8
diff -Nrup a/ld/testsuite/ld-powerpc/elfv2-2a.s b/ld/testsuite/ld-powerpc/elfv2-2a.s
d570a8
--- a/ld/testsuite/ld-powerpc/elfv2-2a.s	1969-12-31 17:00:00.000000000 -0700
d570a8
+++ b/ld/testsuite/ld-powerpc/elfv2-2a.s	2015-03-31 11:12:07.740201440 -0600
d570a8
@@ -0,0 +1,27 @@
d570a8
+ .globl f1
d570a8
+ .type f1,@function
d570a8
+ .text
d570a8
+f1:
d570a8
+ addis 2,12,.TOC.-f1@ha
d570a8
+ addi 2,2,.TOC.-f1@l
d570a8
+ .localentry f1,.-f1
d570a8
+ blr
d570a8
+ .size f1,.-f1
d570a8
+
d570a8
+ .globl f2
d570a8
+ .type f2,@function
d570a8
+ .text
d570a8
+f2:
d570a8
+ addi 2,12,.TOC.-f2
d570a8
+ .localentry f2,.-f2
d570a8
+ blr
d570a8
+ .size f2,.-f2
d570a8
+
d570a8
+ .quad f1
d570a8
+ .quad f1@localentry
d570a8
+ .quad f2
d570a8
+ .quad f2@localentry
d570a8
+ .quad f3
d570a8
+ .quad f3@localentry
d570a8
+ .quad f4
d570a8
+ .quad f4@localentry
d570a8
diff -Nrup a/ld/testsuite/ld-powerpc/elfv2-2b.s b/ld/testsuite/ld-powerpc/elfv2-2b.s
d570a8
--- a/ld/testsuite/ld-powerpc/elfv2-2b.s	1969-12-31 17:00:00.000000000 -0700
d570a8
+++ b/ld/testsuite/ld-powerpc/elfv2-2b.s	2015-03-31 11:12:07.740201440 -0600
d570a8
@@ -0,0 +1,17 @@
d570a8
+ .globl f3
d570a8
+ .type f3,@function
d570a8
+ .text
d570a8
+f3:
d570a8
+ addis 2,12,.TOC.-f3@ha
d570a8
+ addi 2,2,.TOC.-f3@l
d570a8
+ .localentry f3,.-f3
d570a8
+ blr
d570a8
+ .size f3,.-f3
d570a8
+
d570a8
+ .globl f4
d570a8
+ .type f4,@function
d570a8
+ .text
d570a8
+f4:
d570a8
+ .localentry f4,0
d570a8
+ blr
d570a8
+ .size f4,.-f4
d570a8
diff -Nrup a/ld/testsuite/ld-powerpc/elfv2-2exe.d b/ld/testsuite/ld-powerpc/elfv2-2exe.d
d570a8
--- a/ld/testsuite/ld-powerpc/elfv2-2exe.d	1969-12-31 17:00:00.000000000 -0700
d570a8
+++ b/ld/testsuite/ld-powerpc/elfv2-2exe.d	2015-03-31 11:12:07.740201440 -0600
d570a8
@@ -0,0 +1,41 @@
d570a8
+#source: elfv2-2a.s
d570a8
+#source: elfv2-2b.s
d570a8
+#as: -a64
d570a8
+#ld: -melf64ppc -e f1
d570a8
+#objdump: -dr
d570a8
+
d570a8
+.*
d570a8
+
d570a8
+Disassembly of section \.text:
d570a8
+
d570a8
+0+10000078 <f1>:
d570a8
+.*:	(3c 40 10 01|01 10 40 3c) 	lis     r2,4097
d570a8
+.*:	(38 42 80 78|78 80 42 38) 	addi    r2,r2,-32648
d570a8
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
d570a8
+0+10000084 <f2>:
d570a8
+.*:	(38 4c 7f f4|f4 7f 4c 38) 	addi    r2,r12,32756
d570a8
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
d570a8
+.*:	(00 00 00 00|78 00 00 10) .*
d570a8
+.*:	(10 00 00 78|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|80 00 00 10) .*
d570a8
+.*:	(10 00 00 80|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|84 00 00 10) .*
d570a8
+.*:	(10 00 00 84|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|88 00 00 10) .*
d570a8
+.*:	(10 00 00 88|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|cc 00 00 10) .*
d570a8
+.*:	(10 00 00 cc|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|d4 00 00 10) .*
d570a8
+.*:	(10 00 00 d4|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|d8 00 00 10) .*
d570a8
+.*:	(10 00 00 d8|00 00 00 00) .*
d570a8
+.*:	(00 00 00 00|d8 00 00 10) .*
d570a8
+.*:	(10 00 00 d8|00 00 00 00) .*
d570a8
+
d570a8
+0+100000cc <f3>:
d570a8
+.*:	(3c 40 10 01|01 10 40 3c) 	lis     r2,4097
d570a8
+.*:	(38 42 80 78|78 80 42 38) 	addi    r2,r2,-32648
d570a8
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
d570a8
+
d570a8
+0+100000d8 <f4>:
d570a8
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
d570a8
diff -Nrup a/ld/testsuite/ld-powerpc/elfv2-2so.d b/ld/testsuite/ld-powerpc/elfv2-2so.d
d570a8
--- a/ld/testsuite/ld-powerpc/elfv2-2so.d	1969-12-31 17:00:00.000000000 -0700
d570a8
+++ b/ld/testsuite/ld-powerpc/elfv2-2so.d	2015-03-31 11:12:07.740201440 -0600
d570a8
@@ -0,0 +1,5 @@
d570a8
+#source: elfv2-2a.s
d570a8
+#source: elfv2-2b.s
d570a8
+#as: -a64
d570a8
+#ld: -melf64ppc -shared -e f1
d570a8
+#error: .* R_PPC64_ADDR64_LOCAL reloc unsupported in shared libraries and PIEs.*
d570a8
diff -Nrup a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
d570a8
--- a/ld/testsuite/ld-powerpc/powerpc.exp	2015-03-31 11:11:36.355939659 -0600
d570a8
+++ b/ld/testsuite/ld-powerpc/powerpc.exp	2015-03-31 11:13:19.569511875 -0600
d570a8
@@ -276,6 +276,9 @@ if [ supports_ppc64 ] then {
d570a8
     run_dump_test "ambiguousv1"
d570a8
     run_dump_test "ambiguousv2"
d570a8
     run_dump_test "defsym"
d570a8
+    run_dump_test "elfv2-2so"
d570a8
+    run_dump_test "elfv2-2exe"
d570a8
+
d570a8
 }
d570a8
 
d570a8
 if { [istarget "powerpc*-eabi*"] } {