From: Julian Seward Date: Sat, 6 May 2006 14:40:40 +0000 (+0000) Subject: Fix for 32-bit mode, as per comment. X-Git-Tag: svn/VALGRIND_3_2_3^2~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d03e75c33a286f58578088c39c556cfb360074a;p=thirdparty%2Fvalgrind.git Fix for 32-bit mode, as per comment. git-svn-id: svn://svn.valgrind.org/vex/trunk@1610 --- diff --git a/VEX/priv/host-ppc/hdefs.c b/VEX/priv/host-ppc/hdefs.c index 801997a327..5498a7b85d 100644 --- a/VEX/priv/host-ppc/hdefs.c +++ b/VEX/priv/host-ppc/hdefs.c @@ -2468,6 +2468,16 @@ static UChar* mkLoadImm ( UChar* p, UInt r_dst, ULong imm, Bool mode64 ) { vassert(r_dst < 0x20); + if (!mode64) { + /* In 32-bit mode, make sure the top 32 bits of imm are a sign + extension of the bottom 32 bits, so that the range tests + below work correctly. */ + UInt u32 = (UInt)imm; + Int s32 = (Int)u32; + Long s64 = (Long)s32; + imm = (ULong)s64; + } + if (imm >= 0xFFFFFFFFFFFF8000ULL || imm < 0x8000) { // sign-extendable from 16 bits