From: Julian Seward Date: Mon, 10 Sep 2007 16:52:09 +0000 (+0000) Subject: ppc64-linux equivalent to r6813 (use sigframe return stub in X-Git-Tag: svn/VALGRIND_3_3_0~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e8fce154898a219a01a119ea18d85654d6ccfe3;p=thirdparty%2Fvalgrind.git ppc64-linux equivalent to r6813 (use sigframe return stub in m_trampoline, not on the stack) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6814 --- diff --git a/coregrind/m_sigframe/sigframe-ppc64-linux.c b/coregrind/m_sigframe/sigframe-ppc64-linux.c index 530df2a6d3..437b3e7c93 100644 --- a/coregrind/m_sigframe/sigframe-ppc64-linux.c +++ b/coregrind/m_sigframe/sigframe-ppc64-linux.c @@ -260,8 +260,16 @@ void VG_(sigframe_create)( ThreadId tid, /* 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 @@ void VG_(sigframe_create)( ThreadId tid, 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) */ diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index 10d5ec4036..7b6f7a3abe 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -365,6 +365,12 @@ VG_(trampoline_stuff_end): .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): diff --git a/coregrind/pub_core_trampoline.h b/coregrind/pub_core_trampoline.h index da9ff416ec..6aac398bbf 100644 --- a/coregrind/pub_core_trampoline.h +++ b/coregrind/pub_core_trampoline.h @@ -77,6 +77,7 @@ extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int ); #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