]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fish ppc32 instruction words out of memory bigendianly regardless of
authorJulian Seward <jseward@acm.org>
Sun, 30 Jan 2005 12:52:14 +0000 (12:52 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 30 Jan 2005 12:52:14 +0000 (12:52 +0000)
the endianness of the host.

git-svn-id: svn://svn.valgrind.org/vex/trunk@776

VEX/priv/guest-ppc32/toIR.c

index a6bc9d15fa0f3f7cdd2c6a45b9ef2b1839911d5f..72521f8065b66d2b76afc21f1ba473882592e3e3 100644 (file)
@@ -308,7 +308,7 @@ IRBB* bbToIR_PPC32 ( UChar*           ppc32code,
 
 /*------------------------------------------------------------*/
 /*--- Helper bits and pieces for deconstructing the        ---*/
-/*--- x86 insn stream.                                     ---*/
+/*--- ppc32 insn stream.                                   ---*/
 /*------------------------------------------------------------*/
 
 /* Add a statement to the list held by "irbb". */
@@ -360,6 +360,19 @@ static UInt extend_s_24to32 ( UInt x )
    return (UInt)((((Int)x) << 8) >> 8);
 }
 
+/* Do a big-endian load of a 32-bit word, regardless of the endianness
+   of the underlying host. */
+static UInt getUIntBigendianly ( HChar* hp )
+{
+   UChar* p = (UChar*)hp;
+   UInt   w = 0;
+   w = (w << 8) | p[0];
+   w = (w << 8) | p[1];
+   w = (w << 8) | p[2];
+   w = (w << 8) | p[3];
+   return w;
+}
+
 
 /*------------------------------------------------------------*/
 /*--- Helpers for constructing IR.                         ---*/
@@ -1337,7 +1350,7 @@ static DisResult disInstr ( /*IN*/  Bool    resteerOK,
       decode. */
    *size = 0;
 
-   theInstr = *(UInt*)(&guest_code[delta]);
+   theInstr = getUIntBigendianly( (HChar*)(&guest_code[delta]) );
 
 //   vex_printf("START: 0x%x, %,b\n", theInstr, theInstr );