|
|
ce426f |
#
|
|
|
ce426f |
# commit f8e3e9f31bfd71641418897228fa1732170b69cc
|
|
|
ce426f |
# Author: Alan Modra <amodra@gmail.com>
|
|
|
ce426f |
# Date: Thu Oct 3 13:51:52 2013 +0930
|
|
|
ce426f |
#
|
|
|
ce426f |
# Correct little-endian relocation of UADDR64,32,16.
|
|
|
ce426f |
#
|
|
|
ce426f |
# * sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
|
|
|
ce426f |
# Correct handling of unaligned relocs for little-endian.
|
|
|
ce426f |
# * sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.
|
|
|
ce426f |
#
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/dl-machine.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/dl-machine.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/dl-machine.c 2012-12-24 22:02:13.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/dl-machine.c 2014-11-11 18:51:36.140570654 -0500
|
|
|
ce426f |
@@ -423,6 +423,12 @@
|
|
|
ce426f |
Elf32_Addr const finaladdr,
|
|
|
ce426f |
int rinfo)
|
|
|
ce426f |
{
|
|
|
ce426f |
+ union unaligned
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ unsigned u2 __attribute__ ((mode (HI)));
|
|
|
ce426f |
+ unsigned u4 __attribute__ ((mode (SI)));
|
|
|
ce426f |
+ } __attribute__((__packed__));
|
|
|
ce426f |
+
|
|
|
ce426f |
switch (rinfo)
|
|
|
ce426f |
{
|
|
|
ce426f |
case R_PPC_NONE:
|
|
|
ce426f |
@@ -439,10 +445,7 @@
|
|
|
ce426f |
return;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC_UADDR32:
|
|
|
ce426f |
- ((char *) reloc_addr)[0] = finaladdr >> 24;
|
|
|
ce426f |
- ((char *) reloc_addr)[1] = finaladdr >> 16;
|
|
|
ce426f |
- ((char *) reloc_addr)[2] = finaladdr >> 8;
|
|
|
ce426f |
- ((char *) reloc_addr)[3] = finaladdr;
|
|
|
ce426f |
+ ((union unaligned *) reloc_addr)->u4 = finaladdr;
|
|
|
ce426f |
break;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC_ADDR24:
|
|
|
ce426f |
@@ -460,8 +463,7 @@
|
|
|
ce426f |
case R_PPC_UADDR16:
|
|
|
ce426f |
if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
|
|
|
ce426f |
_dl_reloc_overflow (map, "R_PPC_UADDR16", reloc_addr, refsym);
|
|
|
ce426f |
- ((char *) reloc_addr)[0] = finaladdr >> 8;
|
|
|
ce426f |
- ((char *) reloc_addr)[1] = finaladdr;
|
|
|
ce426f |
+ ((union unaligned *) reloc_addr)->u2 = finaladdr;
|
|
|
ce426f |
break;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC_ADDR16_LO:
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h 2012-12-24 22:02:13.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h 2014-11-11 18:51:36.141570651 -0500
|
|
|
ce426f |
@@ -561,6 +561,12 @@
|
|
|
ce426f |
Elf64_Addr *const reloc_addr = reloc_addr_arg;
|
|
|
ce426f |
const int r_type = ELF64_R_TYPE (reloc->r_info);
|
|
|
ce426f |
const Elf64_Sym *const refsym = sym;
|
|
|
ce426f |
+ union unaligned
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ unsigned u2 __attribute__ ((mode (HI)));
|
|
|
ce426f |
+ unsigned u4 __attribute__ ((mode (SI)));
|
|
|
ce426f |
+ unsigned u8 __attribute__ ((mode (DI)));
|
|
|
ce426f |
+ } __attribute__((__packed__));
|
|
|
ce426f |
|
|
|
ce426f |
if (r_type == R_PPC64_RELATIVE)
|
|
|
ce426f |
{
|
|
|
ce426f |
@@ -742,23 +748,11 @@
|
|
|
ce426f |
return;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC64_UADDR64:
|
|
|
ce426f |
- /* We are big-endian. */
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[0] = (value >> 56) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[1] = (value >> 48) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[2] = (value >> 40) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[3] = (value >> 32) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[4] = (value >> 24) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[5] = (value >> 16) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[6] = (value >> 8) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[7] = (value >> 0) & 0xff;
|
|
|
ce426f |
+ ((union unaligned *) reloc_addr)->u8 = value;
|
|
|
ce426f |
return;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC64_UADDR32:
|
|
|
ce426f |
- /* We are big-endian. */
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[0] = (value >> 24) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[1] = (value >> 16) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[2] = (value >> 8) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[3] = (value >> 0) & 0xff;
|
|
|
ce426f |
+ ((union unaligned *) reloc_addr)->u4 = value;
|
|
|
ce426f |
return;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC64_ADDR32:
|
|
|
ce426f |
@@ -782,10 +776,8 @@
|
|
|
ce426f |
case R_PPC64_UADDR16:
|
|
|
ce426f |
if (dont_expect ((value + 0x8000) >= 0x10000))
|
|
|
ce426f |
_dl_reloc_overflow (map, "R_PPC64_UADDR16", reloc_addr, refsym);
|
|
|
ce426f |
- /* We are big-endian. */
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[0] = (value >> 8) & 0xff;
|
|
|
ce426f |
- ((char *) reloc_addr_arg)[1] = (value >> 0) & 0xff;
|
|
|
ce426f |
- break;
|
|
|
ce426f |
+ ((union unaligned *) reloc_addr)->u2 = value;
|
|
|
ce426f |
+ return;
|
|
|
ce426f |
|
|
|
ce426f |
case R_PPC64_ADDR16_DS:
|
|
|
ce426f |
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
|