]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge from trunk, r2229 and 2230 (lame workaround for the fact that
authorJulian Seward <jseward@acm.org>
Tue, 1 Nov 2011 07:10:37 +0000 (07:10 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 1 Nov 2011 07:10:37 +0000 (07:10 +0000)
VEX doesn't keep the stack properly aligned for function calls on Darwin)

git-svn-id: svn://svn.valgrind.org/vex/branches/VEX_3_7_BRANCH@2231

VEX/priv/guest_x86_helpers.c

index 2bfe2104db335c3c8bae66696c56a39429527637..d14d08b0fb125228f12e96340bf676d84cfd095c 100644 (file)
@@ -1787,7 +1787,20 @@ VexEmWarn x86g_dirtyhelper_FXRSTOR ( VexGuestX86State* gst, HWord addr )
 
    /* Copy the x87 registers out of the image, into a temporary
       Fpu_State struct. */
-   for (i = 0; i < 14; i++) tmp.env[i] = 0;
+
+   /* LLVM on Darwin turns the following loop into a movaps plus a
+      handful of scalar stores.  This would work fine except for the
+      fact that VEX doesn't keep the stack correctly (16-) aligned for
+      the call, so it segfaults.  Hence, split the loop into two
+      pieces (and pray LLVM doesn't merely glue them back together) so
+      it's composed only of scalar stores and so is alignment
+      insensitive.  Of course this is a kludge of the lamest kind --
+      VEX should be fixed properly. */
+   /* Code that seems to trigger the problem:
+      for (i = 0; i < 14; i++) tmp.env[i] = 0; */
+   for (i = 0; i < 7; i++) tmp.env[i+0] = 0;
+   for (i = 0; i < 7; i++) tmp.env[i+7] = 0;
+   
    for (i = 0; i < 80; i++) tmp.reg[i] = 0;
    /* fill in tmp.reg[0..7] */
    for (stno = 0; stno < 8; stno++) {