From: Julian Seward Date: Sun, 30 Jan 2005 12:52:14 +0000 (+0000) Subject: Fish ppc32 instruction words out of memory bigendianly regardless of X-Git-Tag: svn/VALGRIND_3_0_1^2~558 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86e4f13a086d99c55a5f07e7074d1e7948e80245;p=thirdparty%2Fvalgrind.git Fish ppc32 instruction words out of memory bigendianly regardless of the endianness of the host. git-svn-id: svn://svn.valgrind.org/vex/trunk@776 --- diff --git a/VEX/priv/guest-ppc32/toIR.c b/VEX/priv/guest-ppc32/toIR.c index a6bc9d15fa..72521f8065 100644 --- a/VEX/priv/guest-ppc32/toIR.c +++ b/VEX/priv/guest-ppc32/toIR.c @@ -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 );