]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
(merge from 20020320)
authorJulian Seward <jseward@acm.org>
Sun, 24 Mar 2002 10:03:17 +0000 (10:03 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 24 Mar 2002 10:03:17 +0000 (10:03 +0000)
Modify codegen_SAHF so the instrumenter doesn't generate spurious
value errors if parts of %eax other than %ah are undefined.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13

coregrind/vg_to_ucode.c
vg_to_ucode.c

index 5cef0b843412e3b2c08a5e5a037e1e6fe9acd2a1..c03f5817d2f4368554e97e8ec983e7c51759e980 100644 (file)
@@ -2644,8 +2644,23 @@ void codegen_xchg_eAX_Reg ( UCodeBlock* cb, Int sz, Int reg )
 static 
 void codegen_SAHF ( UCodeBlock* cb )
 {
-   Int t  = newTemp(cb);
+   Int t   = newTemp(cb);
+   Int t2  = newTemp(cb);
    uInstr2(cb, GET,   4, ArchReg, R_EAX, TempReg, t);
+
+   /* Mask out parts of t not corresponding to %AH.  This stops the
+      instrumenter complaining if they are undefined.  Otherwise, the
+      instrumenter would check all 32 bits of t at the PUSH, which
+      could be the cause of incorrect warnings.  Discovered by Daniel
+      Veillard <veillard@redhat.com>. 
+   */
+   uInstr2(cb, MOV, 4, Literal, 0, TempReg, t2);
+   uLiteral(cb, 0x0000FF00);
+   uInstr2(cb, AND, 4, TempReg, t2, TempReg, t);
+   /* We deliberately don't set the condition codes here, since this
+      AND is purely internal to Valgrind and nothing to do with the
+      client's state. */
+
    uInstr0(cb, CALLM_S, 0);
    uInstr1(cb, PUSH,  4, TempReg, t);
    uInstr1(cb, CALLM, 0, Lit16,   VGOFF_(helper_SAHF));
index 5cef0b843412e3b2c08a5e5a037e1e6fe9acd2a1..c03f5817d2f4368554e97e8ec983e7c51759e980 100644 (file)
@@ -2644,8 +2644,23 @@ void codegen_xchg_eAX_Reg ( UCodeBlock* cb, Int sz, Int reg )
 static 
 void codegen_SAHF ( UCodeBlock* cb )
 {
-   Int t  = newTemp(cb);
+   Int t   = newTemp(cb);
+   Int t2  = newTemp(cb);
    uInstr2(cb, GET,   4, ArchReg, R_EAX, TempReg, t);
+
+   /* Mask out parts of t not corresponding to %AH.  This stops the
+      instrumenter complaining if they are undefined.  Otherwise, the
+      instrumenter would check all 32 bits of t at the PUSH, which
+      could be the cause of incorrect warnings.  Discovered by Daniel
+      Veillard <veillard@redhat.com>. 
+   */
+   uInstr2(cb, MOV, 4, Literal, 0, TempReg, t2);
+   uLiteral(cb, 0x0000FF00);
+   uInstr2(cb, AND, 4, TempReg, t2, TempReg, t);
+   /* We deliberately don't set the condition codes here, since this
+      AND is purely internal to Valgrind and nothing to do with the
+      client's state. */
+
    uInstr0(cb, CALLM_S, 0);
    uInstr1(cb, PUSH,  4, TempReg, t);
    uInstr1(cb, CALLM, 0, Lit16,   VGOFF_(helper_SAHF));