]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
LibVEX_GuestARM_get_cpsr: set CPSR.Q, .GE, .T and .M
authorJulian Seward <jseward@acm.org>
Thu, 23 Sep 2010 11:01:15 +0000 (11:01 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 23 Sep 2010 11:01:15 +0000 (11:01 +0000)
in the resulting value.  Fixes #251362.

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

VEX/priv/guest_arm_helpers.c

index 3b3eb30355c7cea25626c84ad7e5e9c9d568cc23..e90d44e2c647100f0a46ebb45534a40cd23361d1 100644 (file)
@@ -478,14 +478,39 @@ void LibVEX_GuestARM_put_flags ( UInt flags_native,
 /* VISIBLE TO LIBVEX CLIENT */
 UInt LibVEX_GuestARM_get_cpsr ( /*IN*/VexGuestARMState* vex_state )
 {
-   UInt nzcv;
-   nzcv = armg_calculate_flags_nzcv(
-              vex_state->guest_CC_OP,
-              vex_state->guest_CC_DEP1,
-              vex_state->guest_CC_DEP2,
-              vex_state->guest_CC_NDEP
-           );
-   return nzcv;
+   UInt cpsr = 0;
+   // NZCV
+   cpsr |= armg_calculate_flags_nzcv(
+               vex_state->guest_CC_OP,
+               vex_state->guest_CC_DEP1,
+               vex_state->guest_CC_DEP2,
+               vex_state->guest_CC_NDEP
+            );
+   vassert(0 == (cpsr & 0x0FFFFFFF));
+   // Q
+   if (vex_state->guest_QFLAG32 > 0)
+      cpsr |= (1 << 27);
+   // GE
+   if (vex_state->guest_GEFLAG0 > 0)
+      cpsr |= (1 << 16);
+   if (vex_state->guest_GEFLAG1 > 0)
+      cpsr |= (1 << 17);
+   if (vex_state->guest_GEFLAG2 > 0)
+      cpsr |= (1 << 18);
+   if (vex_state->guest_GEFLAG3 > 0)
+      cpsr |= (1 << 19);
+   // M
+   cpsr |= (1 << 4); // 0b10000 means user-mode
+   // J,T   J (bit 24) is zero by initialisation above
+   // T  we copy from R15T[0]
+   if (vex_state->guest_R15T & 1)
+      cpsr |= (1 << 5);
+   // ITSTATE we punt on for the time being.  Could compute it
+   // if needed though.
+   // E, endianness, 0 (littleendian) from initialisation above
+   // A,I,F disable some async exceptions.  Not sure about these.
+   // Leave as zero for the time being.
+   return cpsr;
 }
 
 /* VISIBLE TO LIBVEX CLIENT */