Blame SOURCES/glibc-rh1162847-p1.patch

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