|
|
5de29b |
# commit 7ec07d9a7b501f1b7d740fda02ba5f39d6d684e5
|
|
|
5de29b |
# Author: Alan Modra <amodra@gmail.com>
|
|
|
5de29b |
# Date: Wed Dec 4 06:44:06 2013 -0600
|
|
|
5de29b |
#
|
|
|
5de29b |
# PowerPC64: Report overflow on @h and @ha relocations
|
|
|
5de29b |
#
|
|
|
5de29b |
# This patch updates glibc in accordance with the binutils patch checked in here:
|
|
|
5de29b |
# https://sourceware.org/ml/binutils/2013-10/msg00372.html
|
|
|
5de29b |
#
|
|
|
5de29b |
# This changes the various R_PPC64_..._HI and _HA relocations to report
|
|
|
5de29b |
# 32-bit overflows. The motivation is that existing uses of @h / @ha
|
|
|
5de29b |
# are to build up 32-bit offsets (for the "medium model" TOC access
|
|
|
5de29b |
# that GCC now defaults to), and we'd really like to see failures at
|
|
|
5de29b |
# link / load time rather than silent truncations.
|
|
|
5de29b |
#
|
|
|
5de29b |
# For those rare cases where a modifier is needed to build up a 64-bit
|
|
|
5de29b |
# constant, new relocations _HIGH / _HIGHA are supported.
|
|
|
5de29b |
#
|
|
|
5de29b |
# The patch also fixes a bug in overflow checking for the R_PPC64_ADDR30
|
|
|
5de29b |
# and R_PPC64_ADDR32 relocations.
|
|
|
5de29b |
#
|
|
|
12745e |
diff -urN glibc-2.17-c758a686/elf/elf.h glibc-2.17-c758a686/elf/elf.h
|
|
|
12745e |
--- glibc-2.17-c758a686/elf/elf.h 2014-05-29 13:17:35.000000000 -0500
|
|
|
12745e |
+++ glibc-2.17-c758a686/elf/elf.h 2014-05-29 13:17:35.000000000 -0500
|
|
|
5de29b |
@@ -2243,6 +2243,17 @@
|
|
|
5de29b |
#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
|
|
|
5de29b |
#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
|
|
|
5de29b |
#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
|
|
|
5de29b |
+#define R_PPC64_TLSGD 107 /* none (sym+add)@tlsgd */
|
|
|
5de29b |
+#define R_PPC64_TLSLD 108 /* none (sym+add)@tlsld */
|
|
|
5de29b |
+#define R_PPC64_TOCSAVE 109 /* none */
|
|
|
5de29b |
+
|
|
|
5de29b |
+/* Added when HA and HI relocs were changed to report overflows. */
|
|
|
5de29b |
+#define R_PPC64_ADDR16_HIGH 110
|
|
|
5de29b |
+#define R_PPC64_ADDR16_HIGHA 111
|
|
|
5de29b |
+#define R_PPC64_TPREL16_HIGH 112
|
|
|
5de29b |
+#define R_PPC64_TPREL16_HIGHA 113
|
|
|
5de29b |
+#define R_PPC64_DTPREL16_HIGH 114
|
|
|
5de29b |
+#define R_PPC64_DTPREL16_HIGHA 115
|
|
|
5de29b |
|
|
|
5de29b |
/* GNU extension to support local ifunc. */
|
|
|
5de29b |
#define R_PPC64_JMP_IREL 247
|
|
|
12745e |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h
|
|
|
12745e |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h 2014-05-29 13:17:34.000000000 -0500
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h 2014-05-29 13:17:35.000000000 -0500
|
|
|
5de29b |
@@ -663,11 +663,25 @@
|
|
|
5de29b |
|
|
|
5de29b |
case R_PPC64_TPREL16_HI:
|
|
|
5de29b |
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
5de29b |
+ if (dont_expect (value + 0x80000000 >= 0x100000000LL))
|
|
|
5de29b |
+ _dl_reloc_overflow (map, "R_PPC64_TPREL16_HI", reloc_addr, refsym);
|
|
|
5de29b |
+ *(Elf64_Half *) reloc_addr = PPC_HI (value);
|
|
|
5de29b |
+ break;
|
|
|
5de29b |
+
|
|
|
5de29b |
+ case R_PPC64_TPREL16_HIGH:
|
|
|
5de29b |
+ value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
5de29b |
*(Elf64_Half *) reloc_addr = PPC_HI (value);
|
|
|
5de29b |
break;
|
|
|
5de29b |
|
|
|
5de29b |
case R_PPC64_TPREL16_HA:
|
|
|
5de29b |
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
5de29b |
+ if (dont_expect (value + 0x80008000 >= 0x100000000LL))
|
|
|
5de29b |
+ _dl_reloc_overflow (map, "R_PPC64_TPREL16_HA", reloc_addr, refsym);
|
|
|
5de29b |
+ *(Elf64_Half *) reloc_addr = PPC_HA (value);
|
|
|
5de29b |
+ break;
|
|
|
5de29b |
+
|
|
|
5de29b |
+ case R_PPC64_TPREL16_HIGHA:
|
|
|
5de29b |
+ value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
5de29b |
*(Elf64_Half *) reloc_addr = PPC_HA (value);
|
|
|
5de29b |
break;
|
|
|
5de29b |
|
|
|
5de29b |
@@ -703,17 +717,23 @@
|
|
|
5de29b |
break;
|
|
|
5de29b |
|
|
|
5de29b |
case R_PPC64_ADDR16_HI:
|
|
|
5de29b |
+ if (dont_expect (value + 0x80000000 >= 0x100000000LL))
|
|
|
5de29b |
+ _dl_reloc_overflow (map, "R_PPC64_ADDR16_HI", reloc_addr, refsym);
|
|
|
5de29b |
+ case R_PPC64_ADDR16_HIGH:
|
|
|
5de29b |
*(Elf64_Half *) reloc_addr = PPC_HI (value);
|
|
|
5de29b |
break;
|
|
|
5de29b |
|
|
|
5de29b |
case R_PPC64_ADDR16_HA:
|
|
|
5de29b |
+ if (dont_expect (value + 0x80008000 >= 0x100000000LL))
|
|
|
5de29b |
+ _dl_reloc_overflow (map, "R_PPC64_ADDR16_HA", reloc_addr, refsym);
|
|
|
5de29b |
+ case R_PPC64_ADDR16_HIGHA:
|
|
|
5de29b |
*(Elf64_Half *) reloc_addr = PPC_HA (value);
|
|
|
5de29b |
break;
|
|
|
5de29b |
|
|
|
5de29b |
case R_PPC64_ADDR30:
|
|
|
5de29b |
{
|
|
|
5de29b |
Elf64_Addr delta = value - (Elf64_Xword) reloc_addr;
|
|
|
5de29b |
- if (dont_expect ((delta + 0x80000000) >= 0x10000000
|
|
|
5de29b |
+ if (dont_expect ((delta + 0x80000000) >= 0x100000000LL
|
|
|
5de29b |
|| (delta & 3) != 0))
|
|
|
5de29b |
_dl_reloc_overflow (map, "R_PPC64_ADDR30", reloc_addr, refsym);
|
|
|
5de29b |
BIT_INSERT (*(Elf64_Word *) reloc_addr, delta, 0xfffffffc);
|
|
|
5de29b |
@@ -762,7 +782,7 @@
|
|
|
5de29b |
return;
|
|
|
5de29b |
|
|
|
5de29b |
case R_PPC64_ADDR32:
|
|
|
5de29b |
- if (dont_expect ((value + 0x80000000) >= 0x10000000))
|
|
|
5de29b |
+ if (dont_expect ((value + 0x80000000) >= 0x100000000LL))
|
|
|
5de29b |
_dl_reloc_overflow (map, "R_PPC64_ADDR32", reloc_addr, refsym);
|
|
|
5de29b |
*(Elf64_Word *) reloc_addr = value;
|
|
|
5de29b |
return;
|