From: Paul Floyd Date: Thu, 9 Dec 2021 21:11:04 +0000 (+0100) Subject: Minor sigreturn code cleaning for sigreturn / FreeBSD X-Git-Tag: VALGRIND_3_19_0~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bfe4a4f7afa6681415f46eb473c244e95efaafa;p=thirdparty%2Fvalgrind.git Minor sigreturn code cleaning for sigreturn / FreeBSD More comments + wrapper arg names matching man page (even if the syscall should never get called directly from client code). --- diff --git a/coregrind/m_syswrap/syswrap-amd64-freebsd.c b/coregrind/m_syswrap/syswrap-amd64-freebsd.c index 076f5b4c4d..c5685c4773 100644 --- a/coregrind/m_syswrap/syswrap-amd64-freebsd.c +++ b/coregrind/m_syswrap/syswrap-amd64-freebsd.c @@ -424,8 +424,8 @@ PRE(sys_sigreturn) PRE_REG_READ1(int, "sigreturn", struct vki_ucontext *, ucp); - PRE_MEM_READ( "sigreturn(ucp)", ARG1, sizeof(struct vki_ucontext) ); - PRE_MEM_WRITE( "sigreturn(ucp)", ARG1, sizeof(struct vki_ucontext) ); + PRE_MEM_READ( "sigreturn(scp)", ARG1, sizeof(struct vki_ucontext) ); + PRE_MEM_WRITE( "sigreturn(scp)", ARG1, sizeof(struct vki_ucontext) ); } static void restore_mcontext(ThreadState *tst, struct vki_mcontext *sc) diff --git a/coregrind/m_syswrap/syswrap-x86-freebsd.c b/coregrind/m_syswrap/syswrap-x86-freebsd.c index 0c8da316f9..4fd1ce5011 100644 --- a/coregrind/m_syswrap/syswrap-x86-freebsd.c +++ b/coregrind/m_syswrap/syswrap-x86-freebsd.c @@ -1468,10 +1468,10 @@ PRE(sys_fake_sigreturn) struct vki_ucontext *uc; PRINT("sys_sigreturn ( %#" FMT_REGWORD "x )", ARG1); PRE_REG_READ1(long, "sigreturn", - struct vki_ucontext *, ucp); + struct vki_ucontext *, scp); - PRE_MEM_READ( "sigreturn(ucp)", ARG1, sizeof(struct vki_ucontext) ); - PRE_MEM_WRITE( "sigreturn(ucp)", ARG1, sizeof(struct vki_ucontext) ); + PRE_MEM_READ( "sigreturn(scp)", ARG1, sizeof(struct vki_ucontext) ); + PRE_MEM_WRITE( "sigreturn(scp)", ARG1, sizeof(struct vki_ucontext) ); vg_assert(VG_(is_valid_tid)(tid)); vg_assert(tid >= 1 && tid < VG_N_THREADS); diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index ad1db3cb9f..da96972323 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -899,7 +899,29 @@ VG_(trampoline_stuff_start): VG_(amd64_freebsd_SUBST_FOR_sigreturn): /* This is a very specific sequence which GDB uses to recognize signal handler frames. */ + movq $__NR_fake_sigreturn, %rax + + /* running the preprocessor on + * src/amd64.amd64/lib/libc/sigreturn.S + * gives + * .text; .p2align 4,0x90; .globl __sys_sigreturn; + * .type __sys_sigreturn,@function; __sys_sigreturn:; + * .cfi_startproc; .weak sigreturn; .equ sigreturn,__sys_sigreturn; + * .weak _sigreturn; .equ _sigreturn,__sys_sigreturn; + * mov $417,%eax; + * movq %rcx, %r10; + * syscall; jb .cerror; ret; .size __sys_sigreturn, . - __sys_sigreturn; + * .cfi_endproc + */ + + /* + * sigframe in sigframe-amd64-freebsd.c + * differs from sigframe in /usr/include/x86/sigframe.h + * by having the address to this trampoline first + * so I assume that the +8 is to get back to the + * FreeBSD sigframe + */ movq %rsp, %rdi addq $8,%rdi syscall