|
From: <sv...@va...> - 2012-03-27 09:25:06
|
sewardj 2012-03-27 10:24:54 +0100 (Tue, 27 Mar 2012)
New Revision: 12461
Log:
Keep the stack properly 16-aligned when delivering signals on
amd64-darwin. Fixes the failure shown in
https://bugs.kde.org/show_bug.cgi?id=254646#c13
Modified files:
trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c
Modified: trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c (+8 -3)
===================================================================
--- trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c 2012-03-27 09:44:17 +01:00 (rev 12460)
+++ trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c 2012-03-27 10:24:54 +01:00 (rev 12461)
@@ -124,12 +124,14 @@
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,12 +205,15 @@
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
restore it from saved ucontext. Oh well. */
|