Blame SOURCES/gdb-rhbz1320945-power9pre-3of3.patch

a094f6
commit f9c6b9078c54ea0f018b673e2ff128e61a0aa666
a094f6
Author: Alan Modra <amodra@gmail.com>
a094f6
Date:   Tue Oct 29 16:53:25 2013 +1030
a094f6
a094f6
    Report overflow on PowerPC64 @h and @ha relocations.
a094f6
    
a094f6
    This changes the behaviour of @h and @ha on PowerPC64 to report errors
a094f6
    on 32-bit overflow.  The motivation for this change is that on
a094f6
    PowerPC64, most uses of @h and @ha modifiers and their corresponding
a094f6
    relocations are to build up 32-bit offsets.  We'd like to know when
a094f6
    such offsets overflow.  Only rarely do people use @h or @ha with the
a094f6
    high 32-bit modifiers to build a 64-bit constant.  Those uses will now
a094f6
    need to use two new modifiers, @high and @higha, if the constant isn't
a094f6
    known at assembly time.  For now, we won't report overflow at assembly
a094f6
    time..
a094f6
    
a094f6
    This also fixes an error when applying some of the HIGHER and HIGHEST
a094f6
    relocations.
a094f6
    
a094f6
    include/elf/
a094f6
            * ppc64.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
a094f6
            R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
a094f6
            R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): New.
a094f6
            (IS_PPC64_TLS_RELOC): Match new tls relocs.
a094f6
    bfd/
a094f6
            * reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
a094f6
            BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
a094f6
            BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
a094f6
            * elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
a094f6
            Make all _HA and _HI relocs report signed overflow.
a094f6
            (ppc64_elf_reloc_type_lookup): Handle new relocs.
a094f6
            (must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
a094f6
            (dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
a094f6
            (ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
a094f6
            R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
a094f6
            R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
a094f6
            * libbfd.h: Regenerate.
a094f6
            * bfd-in2.h: Regenerate.
a094f6
    gas/
a094f6
            * config/tc-ppc.c (SEX16): Don't mask.
a094f6
            (REPORT_OVERFLOW_HI): Define as zero.
a094f6
            (ppc_elf_suffix): Support @high, @higha, @dtprel@high, @dtprel@higha,
a094f6
            @tprel@high, and @tprel@higha modifiers.
a094f6
            (md_assemble): Ignore X_unsigned when applying 16-bit insn fields.
a094f6
            Add (disabled) code to check @h and @ha reloc overflow for powerpc64.
a094f6
            Handle new relocs.
a094f6
            (md_apply_fix): Similarly.
a094f6
    elfcpp/
a094f6
            * powerpc.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
a094f6
            R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
a094f6
            R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): Define.
a094f6
    gold/
a094f6
            * powerpc.cc (Target_powerpc::Scan::check_non_pic): Handle new relocs.
a094f6
            (Target_powerpc::Scan::global, local): Likewise.
a094f6
            (Target_powerpc::Relocate::relocate): Likewise.  Check for overflow
a094f6
            on all ppc64 @h and @ha relocs.
a094f6
a094f6
### a/bfd/ChangeLog
a094f6
### b/bfd/ChangeLog
a094f6
## -1,3 +1,19 @@
a094f6
+2013-10-30  Alan Modra  <amodra@gmail.com>
a094f6
+
a094f6
+	* reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
a094f6
+	BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
a094f6
+	BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
a094f6
+	* elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
a094f6
+	Make all _HA and _HI relocs report signed overflow.
a094f6
+	(ppc64_elf_reloc_type_lookup): Handle new relocs.
a094f6
+	(must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
a094f6
+	(dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
a094f6
+	(ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
a094f6
+	R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
a094f6
+	R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
a094f6
+	* libbfd.h: Regenerate.
a094f6
+	* bfd-in2.h: Regenerate.
a094f6
+
a094f6
 2013-10-29  Roland McGrath  <mcgrathr@google.com>
a094f6
 
a094f6
 	* elf64-x86-64.c (elf_x86_64_nacl_plt0_entry): Correct 9-byte nop
a094f6
--- a/bfd/bfd-in2.h
a094f6
+++ b/bfd/bfd-in2.h
a094f6
@@ -3223,6 +3223,8 @@ instruction.  */
a094f6
   BFD_RELOC_PPC64_TOC16_LO_DS,
a094f6
   BFD_RELOC_PPC64_PLTGOT16_DS,
a094f6
   BFD_RELOC_PPC64_PLTGOT16_LO_DS,
a094f6
+  BFD_RELOC_PPC64_ADDR16_HIGH,
a094f6
+  BFD_RELOC_PPC64_ADDR16_HIGHA,
a094f6
 
a094f6
 /* PowerPC and PowerPC64 thread-local storage relocations.  */
a094f6
   BFD_RELOC_PPC_TLS,
a094f6
@@ -3267,6 +3269,10 @@ instruction.  */
a094f6
   BFD_RELOC_PPC64_DTPREL16_HIGHERA,
a094f6
   BFD_RELOC_PPC64_DTPREL16_HIGHEST,
a094f6
   BFD_RELOC_PPC64_DTPREL16_HIGHESTA,
a094f6
+  BFD_RELOC_PPC64_TPREL16_HIGH,
a094f6
+  BFD_RELOC_PPC64_TPREL16_HIGHA,
a094f6
+  BFD_RELOC_PPC64_DTPREL16_HIGH,
a094f6
+  BFD_RELOC_PPC64_DTPREL16_HIGHA,
a094f6
 
a094f6
 /* IBM 370/390 relocations  */
a094f6
   BFD_RELOC_I370_D12,
a094f6
--- a/bfd/elf64-ppc.c
a094f6
+++ b/bfd/elf64-ppc.c
a094f6
@@ -309,7 +309,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 bfd_elf_generic_reloc,	/* special_function */
a094f6
 	 "R_PPC64_ADDR16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -325,7 +325,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_ha_reloc,	/* special_function */
a094f6
 	 "R_PPC64_ADDR16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -487,7 +487,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont,/* complain_on_overflow */
a094f6
+	 complain_overflow_signed,/* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -503,7 +503,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont,/* complain_on_overflow */
a094f6
+	 complain_overflow_signed,/* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -680,7 +680,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_PLT16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -696,7 +696,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_PLT16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -741,7 +741,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_sectoff_reloc, /* special_function */
a094f6
 	 "R_PPC64_SECTOFF_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -756,7 +756,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_sectoff_ha_reloc, /* special_function */
a094f6
 	 "R_PPC64_SECTOFF_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -963,7 +963,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_toc_reloc,	/* special_function */
a094f6
 	 "R_PPC64_TOC16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -982,7 +982,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_toc_ha_reloc, /* special_function */
a094f6
 	 "R_PPC64_TOC16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1054,7 +1054,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_PLTGOT16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1072,7 +1072,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont,/* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_PLTGOT16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1374,7 +1374,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_DTPREL16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1389,7 +1389,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_DTPREL16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1540,7 +1540,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_TPREL16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1555,7 +1555,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_TPREL16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1692,7 +1692,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_TLSGD16_HI", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1707,7 +1707,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_TLSGD16_HA", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1754,7 +1754,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_TLSLD16_HI", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1769,7 +1769,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_TLSLD16_HA", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1815,7 +1815,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_DTPREL16_HI", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1830,7 +1830,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_DTPREL16_HA", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1876,7 +1876,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_TPREL16_HI", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1891,7 +1891,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 FALSE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
 	 "R_PPC64_GOT_TPREL16_HA", /* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1964,7 +1964,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 TRUE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 bfd_elf_generic_reloc,	/* special_function */
a094f6
 	 "R_PPC64_REL16_HI",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1980,7 +1980,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 16,			/* bitsize */
a094f6
 	 TRUE,			/* pc_relative */
a094f6
 	 0,			/* bitpos */
a094f6
-	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 complain_overflow_signed, /* complain_on_overflow */
a094f6
 	 ppc64_elf_ha_reloc,	/* special_function */
a094f6
 	 "R_PPC64_REL16_HA",	/* name */
a094f6
 	 FALSE,			/* partial_inplace */
a094f6
@@ -1988,6 +1988,96 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
a094f6
 	 0xffff,		/* dst_mask */
a094f6
 	 TRUE),			/* pcrel_offset */
a094f6
 
a094f6
+  /* Like R_PPC64_ADDR16_HI, but no overflow.  */
a094f6
+  HOWTO (R_PPC64_ADDR16_HIGH,	/* type */
a094f6
+	 16,			/* rightshift */
a094f6
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
a094f6
+	 16,			/* bitsize */
a094f6
+	 FALSE,			/* pc_relative */
a094f6
+	 0,			/* bitpos */
a094f6
+	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 bfd_elf_generic_reloc,	/* special_function */
a094f6
+	 "R_PPC64_ADDR16_HIGH",	/* name */
a094f6
+	 FALSE,			/* partial_inplace */
a094f6
+	 0,			/* src_mask */
a094f6
+	 0xffff,		/* dst_mask */
a094f6
+	 FALSE),		/* pcrel_offset */
a094f6
+
a094f6
+  /* Like R_PPC64_ADDR16_HA, but no overflow.  */
a094f6
+  HOWTO (R_PPC64_ADDR16_HIGHA,	/* type */
a094f6
+	 16,			/* rightshift */
a094f6
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
a094f6
+	 16,			/* bitsize */
a094f6
+	 FALSE,			/* pc_relative */
a094f6
+	 0,			/* bitpos */
a094f6
+	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 ppc64_elf_ha_reloc,	/* special_function */
a094f6
+	 "R_PPC64_ADDR16_HIGHA",	/* name */
a094f6
+	 FALSE,			/* partial_inplace */
a094f6
+	 0,			/* src_mask */
a094f6
+	 0xffff,		/* dst_mask */
a094f6
+	 FALSE),		/* pcrel_offset */
a094f6
+
a094f6
+  /* Like R_PPC64_DTPREL16_HI, but no overflow.  */
a094f6
+  HOWTO (R_PPC64_DTPREL16_HIGH,
a094f6
+	 16,			/* rightshift */
a094f6
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
a094f6
+	 16,			/* bitsize */
a094f6
+	 FALSE,			/* pc_relative */
a094f6
+	 0,			/* bitpos */
a094f6
+	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
+	 "R_PPC64_DTPREL16_HIGH", /* name */
a094f6
+	 FALSE,			/* partial_inplace */
a094f6
+	 0,			/* src_mask */
a094f6
+	 0xffff,		/* dst_mask */
a094f6
+	 FALSE),		/* pcrel_offset */
a094f6
+
a094f6
+  /* Like R_PPC64_DTPREL16_HA, but no overflow.  */
a094f6
+  HOWTO (R_PPC64_DTPREL16_HIGHA,
a094f6
+	 16,			/* rightshift */
a094f6
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
a094f6
+	 16,			/* bitsize */
a094f6
+	 FALSE,			/* pc_relative */
a094f6
+	 0,			/* bitpos */
a094f6
+	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
+	 "R_PPC64_DTPREL16_HIGHA", /* name */
a094f6
+	 FALSE,			/* partial_inplace */
a094f6
+	 0,			/* src_mask */
a094f6
+	 0xffff,		/* dst_mask */
a094f6
+	 FALSE),		/* pcrel_offset */
a094f6
+
a094f6
+  /* Like R_PPC64_TPREL16_HI, but no overflow.  */
a094f6
+  HOWTO (R_PPC64_TPREL16_HIGH,
a094f6
+	 16,			/* rightshift */
a094f6
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
a094f6
+	 16,			/* bitsize */
a094f6
+	 FALSE,			/* pc_relative */
a094f6
+	 0,			/* bitpos */
a094f6
+	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
+	 "R_PPC64_TPREL16_HIGH",	/* name */
a094f6
+	 FALSE,			/* partial_inplace */
a094f6
+	 0,			/* src_mask */
a094f6
+	 0xffff,		/* dst_mask */
a094f6
+	 FALSE),		/* pcrel_offset */
a094f6
+
a094f6
+  /* Like R_PPC64_TPREL16_HA, but no overflow.  */
a094f6
+  HOWTO (R_PPC64_TPREL16_HIGHA,
a094f6
+	 16,			/* rightshift */
a094f6
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
a094f6
+	 16,			/* bitsize */
a094f6
+	 FALSE,			/* pc_relative */
a094f6
+	 0,			/* bitpos */
a094f6
+	 complain_overflow_dont, /* complain_on_overflow */
a094f6
+	 ppc64_elf_unhandled_reloc, /* special_function */
a094f6
+	 "R_PPC64_TPREL16_HIGHA",	/* name */
a094f6
+	 FALSE,			/* partial_inplace */
a094f6
+	 0,			/* src_mask */
a094f6
+	 0xffff,		/* dst_mask */
a094f6
+	 FALSE),		/* pcrel_offset */
a094f6
+
a094f6
   /* GNU extension to record C++ vtable hierarchy.  */
a094f6
   HOWTO (R_PPC64_GNU_VTINHERIT,	/* type */
a094f6
 	 0,			/* rightshift */
a094f6
@@ -2066,8 +2156,12 @@ ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
a094f6
       break;
a094f6
     case BFD_RELOC_HI16:			r = R_PPC64_ADDR16_HI;
a094f6
       break;
a094f6
+    case BFD_RELOC_PPC64_ADDR16_HIGH:		r = R_PPC64_ADDR16_HIGH;
a094f6
+      break;
a094f6
     case BFD_RELOC_HI16_S:			r = R_PPC64_ADDR16_HA;
a094f6
       break;
a094f6
+    case BFD_RELOC_PPC64_ADDR16_HIGHA:		r = R_PPC64_ADDR16_HIGHA;
a094f6
+      break;
a094f6
     case BFD_RELOC_PPC_BA16:			r = R_PPC64_ADDR14;
a094f6
       break;
a094f6
     case BFD_RELOC_PPC_BA16_BRTAKEN:		r = R_PPC64_ADDR14_BRTAKEN;
a094f6
@@ -2186,8 +2280,12 @@ ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
a094f6
       break;
a094f6
     case BFD_RELOC_PPC_TPREL16_HI:		r = R_PPC64_TPREL16_HI;
a094f6
       break;
a094f6
+    case BFD_RELOC_PPC64_TPREL16_HIGH:		r = R_PPC64_TPREL16_HIGH;
a094f6
+      break;
a094f6
     case BFD_RELOC_PPC_TPREL16_HA:		r = R_PPC64_TPREL16_HA;
a094f6
       break;
a094f6
+    case BFD_RELOC_PPC64_TPREL16_HIGHA:		r = R_PPC64_TPREL16_HIGHA;
a094f6
+      break;
a094f6
     case BFD_RELOC_PPC_TPREL:			r = R_PPC64_TPREL64;
a094f6
       break;
a094f6
     case BFD_RELOC_PPC_DTPREL16:		r = R_PPC64_DTPREL16;
a094f6
@@ -2196,8 +2294,12 @@ ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
a094f6
       break;
a094f6
     case BFD_RELOC_PPC_DTPREL16_HI:		r = R_PPC64_DTPREL16_HI;
a094f6
       break;
a094f6
+    case BFD_RELOC_PPC64_DTPREL16_HIGH:		r = R_PPC64_DTPREL16_HIGH;
a094f6
+      break;
a094f6
     case BFD_RELOC_PPC_DTPREL16_HA:		r = R_PPC64_DTPREL16_HA;
a094f6
       break;
a094f6
+    case BFD_RELOC_PPC64_DTPREL16_HIGHA:	r = R_PPC64_DTPREL16_HIGHA;
a094f6
+      break;
a094f6
     case BFD_RELOC_PPC_DTPREL:			r = R_PPC64_DTPREL64;
a094f6
       break;
a094f6
     case BFD_RELOC_PPC_GOT_TLSGD16:		r = R_PPC64_GOT_TLSGD16;
a094f6
@@ -3514,6 +3616,8 @@ must_be_dyn_reloc (struct bfd_link_info *info,
a094f6
     case R_PPC64_TPREL16_HA:
a094f6
     case R_PPC64_TPREL16_DS:
a094f6
     case R_PPC64_TPREL16_LO_DS:
a094f6
+    case R_PPC64_TPREL16_HIGH:
a094f6
+    case R_PPC64_TPREL16_HIGHA:
a094f6
     case R_PPC64_TPREL16_HIGHER:
a094f6
     case R_PPC64_TPREL16_HIGHERA:
a094f6
     case R_PPC64_TPREL16_HIGHEST:
a094f6
@@ -5208,6 +5312,8 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
a094f6
 	case R_PPC64_DTPREL16_HA:
a094f6
 	case R_PPC64_DTPREL16_DS:
a094f6
 	case R_PPC64_DTPREL16_LO_DS:
a094f6
+	case R_PPC64_DTPREL16_HIGH:
a094f6
+	case R_PPC64_DTPREL16_HIGHA:
a094f6
 	case R_PPC64_DTPREL16_HIGHER:
a094f6
 	case R_PPC64_DTPREL16_HIGHERA:
a094f6
 	case R_PPC64_DTPREL16_HIGHEST:
a094f6
@@ -5368,6 +5474,8 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
a094f6
 	case R_PPC64_TPREL16_HA:
a094f6
 	case R_PPC64_TPREL16_DS:
a094f6
 	case R_PPC64_TPREL16_LO_DS:
a094f6
+	case R_PPC64_TPREL16_HIGH:
a094f6
+	case R_PPC64_TPREL16_HIGHA:
a094f6
 	case R_PPC64_TPREL16_HIGHER:
a094f6
 	case R_PPC64_TPREL16_HIGHERA:
a094f6
 	case R_PPC64_TPREL16_HIGHEST:
a094f6
@@ -5421,6 +5529,8 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
a094f6
 	case R_PPC64_ADDR16_DS:
a094f6
 	case R_PPC64_ADDR16_HA:
a094f6
 	case R_PPC64_ADDR16_HI:
a094f6
+	case R_PPC64_ADDR16_HIGH:
a094f6
+	case R_PPC64_ADDR16_HIGHA:
a094f6
 	case R_PPC64_ADDR16_HIGHER:
a094f6
 	case R_PPC64_ADDR16_HIGHERA:
a094f6
 	case R_PPC64_ADDR16_HIGHEST:
a094f6
@@ -7052,6 +7162,8 @@ dec_dynrel_count (bfd_vma r_info,
a094f6
     case R_PPC64_TPREL16_HA:
a094f6
     case R_PPC64_TPREL16_DS:
a094f6
     case R_PPC64_TPREL16_LO_DS:
a094f6
+    case R_PPC64_TPREL16_HIGH:
a094f6
+    case R_PPC64_TPREL16_HIGHA:
a094f6
     case R_PPC64_TPREL16_HIGHER:
a094f6
     case R_PPC64_TPREL16_HIGHERA:
a094f6
     case R_PPC64_TPREL16_HIGHEST:
a094f6
@@ -7073,6 +7185,8 @@ dec_dynrel_count (bfd_vma r_info,
a094f6
     case R_PPC64_ADDR16_DS:
a094f6
     case R_PPC64_ADDR16_HA:
a094f6
     case R_PPC64_ADDR16_HI:
a094f6
+    case R_PPC64_ADDR16_HIGH:
a094f6
+    case R_PPC64_ADDR16_HIGHA:
a094f6
     case R_PPC64_ADDR16_HIGHER:
a094f6
     case R_PPC64_ADDR16_HIGHERA:
a094f6
     case R_PPC64_ADDR16_HIGHEST:
a094f6
@@ -13531,6 +13645,8 @@ ppc64_elf_relocate_section (bfd *output_bfd,
a094f6
 	case R_PPC64_TPREL16_HA:
a094f6
 	case R_PPC64_TPREL16_DS:
a094f6
 	case R_PPC64_TPREL16_LO_DS:
a094f6
+	case R_PPC64_TPREL16_HIGH:
a094f6
+	case R_PPC64_TPREL16_HIGHA:
a094f6
 	case R_PPC64_TPREL16_HIGHER:
a094f6
 	case R_PPC64_TPREL16_HIGHERA:
a094f6
 	case R_PPC64_TPREL16_HIGHEST:
a094f6
@@ -13565,6 +13681,8 @@ ppc64_elf_relocate_section (bfd *output_bfd,
a094f6
 	case R_PPC64_DTPREL16_HA:
a094f6
 	case R_PPC64_DTPREL16_DS:
a094f6
 	case R_PPC64_DTPREL16_LO_DS:
a094f6
+	case R_PPC64_DTPREL16_HIGH:
a094f6
+	case R_PPC64_DTPREL16_HIGHA:
a094f6
 	case R_PPC64_DTPREL16_HIGHER:
a094f6
 	case R_PPC64_DTPREL16_HIGHERA:
a094f6
 	case R_PPC64_DTPREL16_HIGHEST:
a094f6
@@ -13597,6 +13715,8 @@ ppc64_elf_relocate_section (bfd *output_bfd,
a094f6
 	case R_PPC64_ADDR16_DS:
a094f6
 	case R_PPC64_ADDR16_HA:
a094f6
 	case R_PPC64_ADDR16_HI:
a094f6
+	case R_PPC64_ADDR16_HIGH:
a094f6
+	case R_PPC64_ADDR16_HIGHA:
a094f6
 	case R_PPC64_ADDR16_HIGHER:
a094f6
 	case R_PPC64_ADDR16_HIGHERA:
a094f6
 	case R_PPC64_ADDR16_HIGHEST:
a094f6
@@ -13911,21 +14031,20 @@ ppc64_elf_relocate_section (bfd *output_bfd,
a094f6
 	default:
a094f6
 	  break;
a094f6
 
a094f6
-	case R_PPC64_ADDR16_HA:
a094f6
 	case R_PPC64_REL16_HA:
a094f6
+	case R_PPC64_ADDR16_HA:
a094f6
+	case R_PPC64_ADDR16_HIGHA:
a094f6
 	case R_PPC64_ADDR16_HIGHERA:
a094f6
 	case R_PPC64_ADDR16_HIGHESTA:
a094f6
 	case R_PPC64_TOC16_HA:
a094f6
 	case R_PPC64_SECTOFF_HA:
a094f6
 	case R_PPC64_TPREL16_HA:
a094f6
-	case R_PPC64_DTPREL16_HA:
a094f6
-	case R_PPC64_TPREL16_HIGHER:
a094f6
+	case R_PPC64_TPREL16_HIGHA:
a094f6
 	case R_PPC64_TPREL16_HIGHERA:
a094f6
-	case R_PPC64_TPREL16_HIGHEST:
a094f6
 	case R_PPC64_TPREL16_HIGHESTA:
a094f6
-	case R_PPC64_DTPREL16_HIGHER:
a094f6
+	case R_PPC64_DTPREL16_HA:
a094f6
+	case R_PPC64_DTPREL16_HIGHA:
a094f6
 	case R_PPC64_DTPREL16_HIGHERA:
a094f6
-	case R_PPC64_DTPREL16_HIGHEST:
a094f6
 	case R_PPC64_DTPREL16_HIGHESTA:
a094f6
 	  /* It's just possible that this symbol is a weak symbol
a094f6
 	     that's not actually defined anywhere. In that case,
a094f6
--- a/bfd/libbfd.h
a094f6
+++ b/bfd/libbfd.h
a094f6
@@ -1397,6 +1397,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
a094f6
   "BFD_RELOC_PPC64_TOC16_LO_DS",
a094f6
   "BFD_RELOC_PPC64_PLTGOT16_DS",
a094f6
   "BFD_RELOC_PPC64_PLTGOT16_LO_DS",
a094f6
+  "BFD_RELOC_PPC64_ADDR16_HIGH",
a094f6
+  "BFD_RELOC_PPC64_ADDR16_HIGHA",
a094f6
   "BFD_RELOC_PPC_TLS",
a094f6
   "BFD_RELOC_PPC_TLSGD",
a094f6
   "BFD_RELOC_PPC_TLSLD",
a094f6
@@ -1439,6 +1441,10 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
a094f6
   "BFD_RELOC_PPC64_DTPREL16_HIGHERA",
a094f6
   "BFD_RELOC_PPC64_DTPREL16_HIGHEST",
a094f6
   "BFD_RELOC_PPC64_DTPREL16_HIGHESTA",
a094f6
+  "BFD_RELOC_PPC64_TPREL16_HIGH",
a094f6
+  "BFD_RELOC_PPC64_TPREL16_HIGHA",
a094f6
+  "BFD_RELOC_PPC64_DTPREL16_HIGH",
a094f6
+  "BFD_RELOC_PPC64_DTPREL16_HIGHA",
a094f6
   "BFD_RELOC_I370_D12",
a094f6
   "BFD_RELOC_CTOR",
a094f6
   "BFD_RELOC_ARM_PCREL_BRANCH",
a094f6
--- a/bfd/reloc.c
a094f6
+++ b/bfd/reloc.c
a094f6
@@ -2891,6 +2891,10 @@ ENUMX
a094f6
   BFD_RELOC_PPC64_PLTGOT16_DS
a094f6
 ENUMX
a094f6
   BFD_RELOC_PPC64_PLTGOT16_LO_DS
a094f6
+ENUMX
a094f6
+  BFD_RELOC_PPC64_ADDR16_HIGH
a094f6
+ENUMX
a094f6
+  BFD_RELOC_PPC64_ADDR16_HIGHA
a094f6
 ENUMDOC
a094f6
   Power(rs6000) and PowerPC relocations.
a094f6
 
a094f6
@@ -2978,6 +2982,14 @@ ENUMX
a094f6
   BFD_RELOC_PPC64_DTPREL16_HIGHEST
a094f6
 ENUMX
a094f6
   BFD_RELOC_PPC64_DTPREL16_HIGHESTA
a094f6
+ENUMX
a094f6
+  BFD_RELOC_PPC64_TPREL16_HIGH
a094f6
+ENUMX
a094f6
+  BFD_RELOC_PPC64_TPREL16_HIGHA
a094f6
+ENUMX
a094f6
+  BFD_RELOC_PPC64_DTPREL16_HIGH
a094f6
+ENUMX
a094f6
+  BFD_RELOC_PPC64_DTPREL16_HIGHA
a094f6
 ENUMDOC
a094f6
   PowerPC and PowerPC64 thread-local storage relocations.
a094f6
 
a094f6
### a/include/elf/ChangeLog
a094f6
### b/include/elf/ChangeLog
a094f6
## -1,3 +1,10 @@
a094f6
+2013-10-30  Alan Modra  <amodra@gmail.com>
a094f6
+
a094f6
+	* ppc64.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
a094f6
+	R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
a094f6
+	R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): New.
a094f6
+	(IS_PPC64_TLS_RELOC): Match new tls relocs.
a094f6
+
a094f6
 2013-10-14  Chao-ying Fu  <Chao-ying.Fu@imgtec.com>
a094f6
 
a094f6
 	* mips.h (enum): Add Tag_GNU_MIPS_ABI_MSA.
a094f6
--- a/include/elf/ppc64.h
a094f6
+++ b/include/elf/ppc64.h
a094f6
@@ -141,6 +141,14 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type)
a094f6
   RELOC_NUMBER (R_PPC64_TLSLD,		   108)
a094f6
   RELOC_NUMBER (R_PPC64_TOCSAVE,	   109)
a094f6
 
a094f6
+/* Added when HA and HI relocs were changed to report overflows.  */
a094f6
+  RELOC_NUMBER (R_PPC64_ADDR16_HIGH,	   110)
a094f6
+  RELOC_NUMBER (R_PPC64_ADDR16_HIGHA,	   111)
a094f6
+  RELOC_NUMBER (R_PPC64_TPREL16_HIGH,	   112)
a094f6
+  RELOC_NUMBER (R_PPC64_TPREL16_HIGHA,	   113)
a094f6
+  RELOC_NUMBER (R_PPC64_DTPREL16_HIGH,	   114)
a094f6
+  RELOC_NUMBER (R_PPC64_DTPREL16_HIGHA,	   115)
a094f6
+
a094f6
 #ifndef RELOC_MACROS_GEN_FUNC
a094f6
 /* Fake relocation only used internally by ld.  */
a094f6
   RELOC_NUMBER (R_PPC64_LO_DS_OPT,	   128)
a094f6
@@ -161,8 +169,9 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type)
a094f6
 
a094f6
 END_RELOC_NUMBERS (R_PPC64_max)
a094f6
 
a094f6
-#define IS_PPC64_TLS_RELOC(R) \
a094f6
-  ((R) >= R_PPC64_TLS && (R) <= R_PPC64_DTPREL16_HIGHESTA)
a094f6
+#define IS_PPC64_TLS_RELOC(R)						\
a094f6
+  (((R) >= R_PPC64_TLS && (R) <= R_PPC64_DTPREL16_HIGHESTA)		\
a094f6
+   || ((R) >= R_PPC64_TPREL16_HIGH && (R) <= R_PPC64_DTPREL16_HIGHA))
a094f6
 
a094f6
 /* Specify the start of the .glink section.  */
a094f6
 #define DT_PPC64_GLINK		DT_LOPROC