From: Julian Seward Date: Tue, 27 Mar 2012 09:24:54 +0000 (+0000) Subject: Keep the stack properly 16-aligned when delivering signals on X-Git-Tag: svn/VALGRIND_3_8_0~392 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98653c13385ed8d7511dc447965fc9d506667e81;p=thirdparty%2Fvalgrind.git 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 git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12461 --- diff --git a/coregrind/m_sigframe/sigframe-amd64-darwin.c b/coregrind/m_sigframe/sigframe-amd64-darwin.c index 1cf8cd33e1..5f62f25a8c 100644 --- a/coregrind/m_sigframe/sigframe-amd64-darwin.c +++ b/coregrind/m_sigframe/sigframe-amd64-darwin.c @@ -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