|
From: Julian S. <se...@so...> - 2018-10-03 13:32:24
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3e214c4858a6fdd5697e767543a0c19e30505582 commit 3e214c4858a6fdd5697e767543a0c19e30505582 Author: Julian Seward <js...@ac...> Date: Wed Oct 3 15:29:42 2018 +0200 sigframe construction for x86-linux: ensure that ESP is correctly aligned before entering the handler. n-i-bz. Without this, a signal handler compiled by Clang 6, which uses movdqa to load/store relative to ESP, segfaults because the resulting address isn't 16-aligned. Diff: --- coregrind/m_sigframe/sigframe-x86-linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coregrind/m_sigframe/sigframe-x86-linux.c b/coregrind/m_sigframe/sigframe-x86-linux.c index 27ca4c2..63bcf19 100644 --- a/coregrind/m_sigframe/sigframe-x86-linux.c +++ b/coregrind/m_sigframe/sigframe-x86-linux.c @@ -430,7 +430,7 @@ static Addr build_sigframe(ThreadState *tst, vg_assert((flags & VKI_SA_SIGINFO) == 0); esp -= sizeof(*frame); - esp = VG_ROUNDDN(esp, 16); + esp = VG_ROUNDDN(esp, 16) - 4; frame = (struct sigframe *)esp; if (! ML_(sf_maybe_extend_stack)(tst, esp, sizeof(*frame), flags)) @@ -487,7 +487,7 @@ static Addr build_rt_sigframe(ThreadState *tst, vg_assert((flags & VKI_SA_SIGINFO) != 0); esp -= sizeof(*frame); - esp = VG_ROUNDDN(esp, 16); + esp = VG_ROUNDDN(esp, 16) - 4; frame = (struct rt_sigframe *)esp; if (! ML_(sf_maybe_extend_stack)(tst, esp, sizeof(*frame), flags)) |