]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Keep the stack properly 16-aligned when delivering signals on
authorJulian Seward <jseward@acm.org>
Tue, 27 Mar 2012 09:24:54 +0000 (09:24 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 27 Mar 2012 09:24:54 +0000 (09:24 +0000)
amd64-darwin.  Fixes the failure shown in
https://bugs.kde.org/show_bug.cgi?id=254646#c13

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

coregrind/m_sigframe/sigframe-amd64-darwin.c

index 1cf8cd33e1bc43f1104504272faa06f368a07756..5f62f25a8c65411e58c760bc88eb3069212fa492 100644 (file)
@@ -124,12 +124,14 @@ void VG_(sigframe_create) ( ThreadId tid,
 
    sp_top_of_frame &= ~0xfUL;
    rsp = sp_top_of_frame - sizeof(struct hacky_sigframe);
+   rsp -= 8; /* ELF ABI says that rsp+8 must be 16 aligned on
+                entry to a function. */
 
    tst = VG_(get_ThreadState)(tid);
    if (!extend(tst, rsp, sp_top_of_frame - rsp))
       return;
 
-   vg_assert(VG_IS_16_ALIGNED(rsp));
+   vg_assert(VG_IS_16_ALIGNED(rsp+8));
 
    frame = (struct hacky_sigframe *) rsp;
 
@@ -203,11 +205,14 @@ void VG_(sigframe_destroy)( ThreadId tid, Bool isRT )
    rsp = VG_(get_SP)(tid);
 
    /* why -8 ? because the signal handler's return will have popped
-      the return address of the stack; and the return address is the
+      the return address off the stack; and the return address is the
       lowest-addressed element of hacky_sigframe. */
    frame = (struct hacky_sigframe*)(rsp - 8);
    vg_assert(frame->magicPI == 0x31415927);
-   vg_assert(VG_IS_16_ALIGNED(frame));
+
+   /* This +8 is because of the -8 referred to in the ELF ABI comment
+      in VG_(sigframe_create) just above. */
+   vg_assert(VG_IS_16_ALIGNED((Addr)frame + 8));
 
    /* restore the entire guest state, and shadows, from the
       frame.  Note, as per comments above, this is a kludge - should