|
From: <sv...@va...> - 2007-09-10 16:52:07
|
Author: sewardj
Date: 2007-09-10 17:52:09 +0100 (Mon, 10 Sep 2007)
New Revision: 6814
Log:
ppc64-linux equivalent to r6813 (use sigframe return stub in
m_trampoline, not on the stack)
Modified:
trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c
trunk/coregrind/m_trampoline.S
trunk/coregrind/pub_core_trampoline.h
Modified: trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c
===================================================================
--- trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c 2007-09-10 16:28:38 UTC (rev 6813)
+++ trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c 2007-09-10 16:52:09 UTC (rev 6814)
@@ -260,8 +260,16 @@
/* XXX should do FP and vector regs */
/* set up signal return trampoline */
- frame->tramp[0] = 0x38000000U + __NR_rt_sigreturn; /* li 0,__NR_rt_sigreturn */
- frame->tramp[1] = 0x44000002U; /* sc */
+ /* NB. 5 Sept 07. mc->mc_pad[0..1] used to contain a the code to
+ which the signal handler returns, and it just did sys_sigreturn
+ or sys_rt_sigreturn. But this doesn't work if the stack is
+ non-executable, and it isn't consistent with the x86-linux and
+ amd64-linux scheme for removing the stack frame. So instead be
+ consistent and use a stub in m_trampoline. Then it doesn't
+ matter whether or not the (guest) stack is executable. This
+ fixes #149519 and #145837. */
+ frame->tramp[0] = 0; /* invalid */
+ frame->tramp[1] = 0; /* invalid */
VG_TRACK(post_mem_write, Vg_CoreSignal, tst->tid,
(Addr)&frame->tramp, sizeof(frame->tramp));
@@ -270,7 +278,7 @@
sizeof(frame->tramp), "stack_mcontext" );
/* set the signal handler to return to the trampoline */
- SET_SIGNAL_LR(tst, (Addr) &frame->tramp[0]);
+ SET_SIGNAL_LR(tst, (Addr)&VG_(ppc64_linux_SUBST_FOR_rt_sigreturn));
/* Stack pointer for the handler .. (note, back chain set
earlier) */
Modified: trunk/coregrind/m_trampoline.S
===================================================================
--- trunk/coregrind/m_trampoline.S 2007-09-10 16:28:38 UTC (rev 6813)
+++ trunk/coregrind/m_trampoline.S 2007-09-10 16:52:09 UTC (rev 6814)
@@ -365,6 +365,12 @@
.global VG_(trampoline_stuff_start)
VG_(trampoline_stuff_start):
+.global VG_(ppc64_linux_SUBST_FOR_rt_sigreturn)
+VG_(ppc64_linux_SUBST_FOR_rt_sigreturn):
+ li 0,__NR_rt_sigreturn
+ sc
+ .long 0 /*illegal insn*/
+
/* See comment in pub_core_trampoline.h for what this is for */
.global VG_(ppctoc_magic_redirect_return_stub)
VG_(ppctoc_magic_redirect_return_stub):
Modified: trunk/coregrind/pub_core_trampoline.h
===================================================================
--- trunk/coregrind/pub_core_trampoline.h 2007-09-10 16:28:38 UTC (rev 6813)
+++ trunk/coregrind/pub_core_trampoline.h 2007-09-10 16:52:09 UTC (rev 6814)
@@ -77,6 +77,7 @@
#endif
#if defined(VGP_ppc64_linux)
+extern void VG_(ppc64_linux_SUBST_FOR_rt_sigreturn);
extern UInt VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
/* A label (sans dot) marking the ultra-magical return stub via which
|