]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
ppc64-linux equivalent to r6813 (use sigframe return stub in
authorJulian Seward <jseward@acm.org>
Mon, 10 Sep 2007 16:52:09 +0000 (16:52 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 10 Sep 2007 16:52:09 +0000 (16:52 +0000)
m_trampoline, not on the stack)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6814

coregrind/m_sigframe/sigframe-ppc64-linux.c
coregrind/m_trampoline.S
coregrind/pub_core_trampoline.h

index 530df2a6d3f1741f11bca53053b591dfbd76861a..437b3e7c930d55876661743218ee061251c8d821 100644 (file)
@@ -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) */
index 10d5ec403600744fd3e12c39a80fa0a72960ba37..7b6f7a3abe7986c4e970d4e3b7379ca6594c5da0 100644 (file)
@@ -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):
index da9ff416eccab5d31b69df08bce300965cba3f85..6aac398bbf5d351a0d682b09605ac1a0c66f802e 100644 (file)
@@ -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