]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
arm-linux: fix signal returning so that if SA_RESTORER is not
authorJulian Seward <jseward@acm.org>
Sun, 20 Nov 2011 09:35:51 +0000 (09:35 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 20 Nov 2011 09:35:51 +0000 (09:35 +0000)
specified, the handler returns to the previous context rather than to
whatever value happens to be parked in the link register (duh).
Previous behaviour made complete nonsense of signal returning on
Android.

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

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

index 441c351465551c4f7d2ff5e152870bf2d5ef02c9..cf68bdefdb6fdd788ef102fb2121545613cc8fbd 100644 (file)
@@ -259,7 +259,12 @@ void VG_(sigframe_create)( ThreadId tid,
    tst->arch.vex.guest_R0  = sigNo; 
 
    if (flags & VKI_SA_RESTORER)
-       tst->arch.vex.guest_R14 = (Addr) restorer; 
+       tst->arch.vex.guest_R14 = (Addr)restorer; 
+   else
+       tst->arch.vex.guest_R14 
+          = (flags & VKI_SA_SIGINFO)
+            ? (Addr)&VG_(arm_linux_SUBST_FOR_rt_sigreturn)
+            : (Addr)&VG_(arm_linux_SUBST_FOR_sigreturn);
 
    tst->arch.vex.guest_R15T = (Addr) handler; /* R15 == PC */
 }
index bc227005e11cfd16d3871b3bfddc0a711f45fae0..a9acfa6922d55d8e035bdd33fd556716ed045f6e 100644 (file)
@@ -517,6 +517,22 @@ VG_(trampoline_stuff_end):
 .global VG_(trampoline_stuff_start)
 VG_(trampoline_stuff_start):
 
+.global VG_(arm_linux_SUBST_FOR_sigreturn)
+.type   VG_(arm_linux_SUBST_FOR_sigreturn),#function
+VG_(arm_linux_SUBST_FOR_sigreturn):
+       mov r7, # __NR_sigreturn
+        svc #0
+        .long 0xFFFFFFFF /*illegal insn*/
+.size VG_(arm_linux_SUBST_FOR_sigreturn), .-VG_(arm_linux_SUBST_FOR_sigreturn)
+
+.global VG_(arm_linux_SUBST_FOR_rt_sigreturn)
+.type   VG_(arm_linux_SUBST_FOR_rt_sigreturn),#function
+VG_(arm_linux_SUBST_FOR_rt_sigreturn):
+       mov r7, # __NR_rt_sigreturn
+        svc #0
+        .long 0xFFFFFFFF /*illegal insn*/
+.size VG_(arm_linux_SUBST_FOR_rt_sigreturn), .-VG_(arm_linux_SUBST_FOR_rt_sigreturn)
+       
 .global VG_(arm_linux_REDIR_FOR_strlen)
 VG_(arm_linux_REDIR_FOR_strlen):
        mov     r2, r0
index 87fd86841ee5e5b54f27a26e08a468de92693fc0..72b577e97639944b5a5ca00f1653bb6205ebd62c 100644 (file)
@@ -93,6 +93,8 @@ extern Addr VG_(ppctoc_magic_redirect_return_stub);
 #endif
 
 #if defined(VGP_arm_linux)
+extern Addr  VG_(arm_linux_SUBST_FOR_sigreturn);
+extern Addr  VG_(arm_linux_SUBST_FOR_rt_sigreturn);
 extern UInt  VG_(arm_linux_REDIR_FOR_strlen)( void* );
 //extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int );
 extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );