Blame SOURCES/gdb-rhbz1125820-ppc64le-enablement-28of37.patch

2c2fa1
commit 0ff3e01fdc67a3842ee54224cf197e9a55f0a750
2c2fa1
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2c2fa1
Date:   Tue Feb 4 18:34:19 2014 +0100
2c2fa1
2c2fa1
    PowerPC64 little-endian fixes: 128-bit DFP parameters / registers
2c2fa1
    
2c2fa1
    The powerpc64le-linux ABI specifies that when a 128-bit DFP value is
2c2fa1
    passed in a pair of floating-point registers, the first register holds
2c2fa1
    the most-significant part of the value.  This is as opposed to the
2c2fa1
    usual rule on little-endian systems, where the first register would
2c2fa1
    hold the least-significant part.
2c2fa1
    
2c2fa1
    This affects two places in GDB, the read/write routines for the
2c2fa1
    128-bit DFP pseudo-registers, and the function call / return
2c2fa1
    sequence.  For the former, current code already distinguishes
2c2fa1
    between big- and little-endian targets, but gets the latter
2c2fa1
    wrong.  This is presumably because *GCC* also got it wrong,
2c2fa1
    and GDB matches the old GCC behavior.  But GCC is now fixed:
2c2fa1
    http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02145.html
2c2fa1
    so GDB needs to be fixed too.  (Old code shouldn't really be
2c2fa1
    an issue since there is no code "out there" so far that uses
2c2fa1
    dfp128 on little-endian ...)
2c2fa1
    
2c2fa1
    gdb/ChangeLog:
2c2fa1
    
2c2fa1
    	* ppc-sysv-tdep.c (ppc64_sysv_abi_push_freg): Use correct order
2c2fa1
    	within a register pair holding a DFP 128-bit value on little-endian.
2c2fa1
    	(ppc64_sysv_abi_return_value_base): Likewise.
2c2fa1
    	* rs6000-tdep.c (dfp_pseudo_register_read): Likewise.
2c2fa1
    	(dfp_pseudo_register_write): Likewise.
2c2fa1
    
2c2fa1
    gdb/testsuite/ChangeLog:
2c2fa1
    
2c2fa1
    	* gdb.arch/powerpc-d128-regs.exp: Enable on powerpc64*-*.
2c2fa1
2c2fa1
Index: gdb-7.6.1/gdb/ppc-sysv-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/ppc-sysv-tdep.c
2c2fa1
+++ gdb-7.6.1/gdb/ppc-sysv-tdep.c
2c2fa1
@@ -1269,9 +1269,11 @@ ppc64_sysv_abi_push_freg (struct gdbarch
2c2fa1
       if (argpos->regcache && argpos->freg <= 12)
2c2fa1
 	{
2c2fa1
 	  int regnum = tdep->ppc_fp0_regnum + argpos->freg;
2c2fa1
+	  int lopart = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 : 0;
2c2fa1
+	  int hipart = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 0 : 8;
2c2fa1
 
2c2fa1
-	  regcache_cooked_write (argpos->regcache, regnum, val);
2c2fa1
-	  regcache_cooked_write (argpos->regcache, regnum + 1, val + 8);
2c2fa1
+	  regcache_cooked_write (argpos->regcache, regnum, val + hipart);
2c2fa1
+	  regcache_cooked_write (argpos->regcache, regnum + 1, val + lopart);
2c2fa1
 	}
2c2fa1
 
2c2fa1
       argpos->freg += 2;
2c2fa1
@@ -1684,16 +1686,18 @@ ppc64_sysv_abi_return_value_base (struct
2c2fa1
       && TYPE_CODE (valtype) == TYPE_CODE_DECFLOAT)
2c2fa1
     {
2c2fa1
       int regnum = tdep->ppc_fp0_regnum + 2 + 2 * index;
2c2fa1
+      int lopart = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 : 0;
2c2fa1
+      int hipart = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 0 : 8;
2c2fa1
 
2c2fa1
       if (writebuf != NULL)
2c2fa1
 	{
2c2fa1
-	  regcache_cooked_write (regcache, regnum, writebuf);
2c2fa1
-	  regcache_cooked_write (regcache, regnum + 1, writebuf + 8);
2c2fa1
+	  regcache_cooked_write (regcache, regnum, writebuf + hipart);
2c2fa1
+	  regcache_cooked_write (regcache, regnum + 1, writebuf + lopart);
2c2fa1
 	}
2c2fa1
       if (readbuf != NULL)
2c2fa1
 	{
2c2fa1
-	  regcache_cooked_read (regcache, regnum, readbuf);
2c2fa1
-	  regcache_cooked_read (regcache, regnum + 1, readbuf + 8);
2c2fa1
+	  regcache_cooked_read (regcache, regnum, readbuf + hipart);
2c2fa1
+	  regcache_cooked_read (regcache, regnum + 1, readbuf + lopart);
2c2fa1
 	}
2c2fa1
       return 1;
2c2fa1
     }
2c2fa1
Index: gdb-7.6.1/gdb/rs6000-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/rs6000-tdep.c
2c2fa1
+++ gdb-7.6.1/gdb/rs6000-tdep.c
2c2fa1
@@ -2723,10 +2723,10 @@ dfp_pseudo_register_read (struct gdbarch
2c2fa1
   else
2c2fa1
     {
2c2fa1
       status = regcache_raw_read (regcache, tdep->ppc_fp0_regnum +
2c2fa1
-				  2 * reg_index + 1, buffer + 8);
2c2fa1
+				  2 * reg_index + 1, buffer);
2c2fa1
       if (status == REG_VALID)
2c2fa1
 	status = regcache_raw_read (regcache, tdep->ppc_fp0_regnum +
2c2fa1
-				    2 * reg_index, buffer);
2c2fa1
+				    2 * reg_index, buffer + 8);
2c2fa1
     }
2c2fa1
 
2c2fa1
   return status;
2c2fa1
@@ -2752,9 +2752,9 @@ dfp_pseudo_register_write (struct gdbarc
2c2fa1
   else
2c2fa1
     {
2c2fa1
       regcache_raw_write (regcache, tdep->ppc_fp0_regnum +
2c2fa1
-			  2 * reg_index + 1, buffer + 8);
2c2fa1
+			  2 * reg_index + 1, buffer);
2c2fa1
       regcache_raw_write (regcache, tdep->ppc_fp0_regnum +
2c2fa1
-			  2 * reg_index, buffer);
2c2fa1
+			  2 * reg_index, buffer + 8);
2c2fa1
     }
2c2fa1
 }
2c2fa1
 
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
2c2fa1
@@ -20,7 +20,7 @@
2c2fa1
 
2c2fa1
 # Testcase for ppc decimal128 pseudo-registers.
2c2fa1
 
2c2fa1
-if ![istarget "powerpc64-*"] then {
2c2fa1
+if ![istarget "powerpc64*-*"] then {
2c2fa1
     verbose "Skipping powerpc Decimal128 pseudo-registers testcase."
2c2fa1
     return
2c2fa1
 }