Index: arch/x86_64/Makefile.inc =================================================================== RCS file: /cvsroot/src/lib/libc/arch/x86_64/Makefile.inc,v retrieving revision 1.6 diff -u -r1.6 Makefile.inc --- arch/x86_64/Makefile.inc 15 Jul 2015 14:27:49 -0000 1.6 +++ arch/x86_64/Makefile.inc 12 Oct 2020 14:01:40 -0000 @@ -3,3 +3,5 @@ .if ${RUMPRUN} != "yes" SRCS+= __sigaction14_sigtramp.c __sigtramp2.S .endif + +CPPFLAGS+= -I. Index: arch/x86_64/genassym.cf =================================================================== RCS file: arch/x86_64/genassym.cf diff -N arch/x86_64/genassym.cf --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/x86_64/genassym.cf 12 Oct 2020 14:01:40 -0000 @@ -0,0 +1,45 @@ +# +# Copyright (c) 2020 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include + +define _OFFSETOF_UC_GREGS_RAX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RAX]) +define _OFFSETOF_UC_GREGS_RDX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RDX]) +define _OFFSETOF_UC_GREGS_RCX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RCX]) +define _OFFSETOF_UC_GREGS_RBX offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RBX]) +define _OFFSETOF_UC_GREGS_RSI offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RSI]) +define _OFFSETOF_UC_GREGS_RDI offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RDI]) +define _OFFSETOF_UC_GREGS_RBP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RBP]) +define _OFFSETOF_UC_GREGS_RSP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RSP]) +define _OFFSETOF_UC_GREGS_R8 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R8]) +define _OFFSETOF_UC_GREGS_R9 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R9]) +define _OFFSETOF_UC_GREGS_R10 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R10]) +define _OFFSETOF_UC_GREGS_R11 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R11]) +define _OFFSETOF_UC_GREGS_R12 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R12]) +define _OFFSETOF_UC_GREGS_R13 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R13]) +define _OFFSETOF_UC_GREGS_R14 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R14]) +define _OFFSETOF_UC_GREGS_R15 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R15]) +define _OFFSETOF_UC_GREGS_RIP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RIP]) Index: arch/x86_64/sys/__sigtramp2.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/x86_64/sys/__sigtramp2.S,v retrieving revision 1.7 diff -u -r1.7 __sigtramp2.S --- arch/x86_64/sys/__sigtramp2.S 2 Dec 2019 01:38:54 -0000 1.7 +++ arch/x86_64/sys/__sigtramp2.S 12 Oct 2020 14:01:40 -0000 @@ -36,14 +36,40 @@ */ #include "SYS.h" +#include "assym.h" /* * The x86-64 signal trampoline is invoked only to return from * the signal; the kernel calls the signal handler directly. + * + * The unwind entry includes the one byte prior to the trampoline + * because the unwinder will look up (return PC - 1) while unwinding. + * Normally (return PC - 1) computes an address inside the call + * instruction that created the child frame, but here there is no call + * instruction so we have to manually add padding. */ + .cfi_startproc simple + .cfi_signal_frame + .cfi_def_cfa r15, 0 + .cfi_offset rax, _OFFSETOF_UC_GREGS_RAX + .cfi_offset rdx, _OFFSETOF_UC_GREGS_RDX + .cfi_offset rcx, _OFFSETOF_UC_GREGS_RCX + .cfi_offset rbx, _OFFSETOF_UC_GREGS_RBX + .cfi_offset rsi, _OFFSETOF_UC_GREGS_RSI + .cfi_offset rdi, _OFFSETOF_UC_GREGS_RDI + .cfi_offset rbp, _OFFSETOF_UC_GREGS_RBP + /* The unwinder will use the CFA to restore RSP. */ + .cfi_offset r8, _OFFSETOF_UC_GREGS_R8 + .cfi_offset r9, _OFFSETOF_UC_GREGS_R9 + .cfi_offset r10, _OFFSETOF_UC_GREGS_R10 + .cfi_offset r11, _OFFSETOF_UC_GREGS_R11 + .cfi_offset r12, _OFFSETOF_UC_GREGS_R12 + .cfi_offset r13, _OFFSETOF_UC_GREGS_R13 + .cfi_offset r14, _OFFSETOF_UC_GREGS_R14 + .cfi_offset r15, _OFFSETOF_UC_GREGS_R15 + .cfi_offset rip, _OFFSETOF_UC_GREGS_RIP + nop NENTRY(__sigtramp_siginfo_2) - .cfi_startproc - .cfi_def_cfa rsp, 8 movq %r15,%rdi movq $SYS_setcontext, %rax syscall