]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix for 32-bit mode, as per comment.
authorJulian Seward <jseward@acm.org>
Sat, 6 May 2006 14:40:40 +0000 (14:40 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 6 May 2006 14:40:40 +0000 (14:40 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@1610

VEX/priv/host-ppc/hdefs.c

index 801997a3276707d91887d5988591f116f8c64cdd..5498a7b85df7677a1337f4a93ae6a30853ee4edc 100644 (file)
@@ -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