diff --git a/lib/libc/arch/m68k/genassym.cf b/lib/libc/arch/m68k/genassym.cf index a9cad0aa4c29..3faac9623080 100644 --- a/lib/libc/arch/m68k/genassym.cf +++ b/lib/libc/arch/m68k/genassym.cf @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.1 2013/07/17 01:41:17 matt Exp $ +# $NetBSD: genassym.cf,v 1.2 2021/11/21 23:58:09 thorpej Exp $ # # Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -36,11 +36,32 @@ include define UC_LINK offsetof(ucontext_t, uc_link) define UC_SIGMASK offsetof(ucontext_t, uc_sigmask) +define UC_GREGS offsetof(ucontext_t, uc_mcontext.__gregs[0]) define UC_MCONTEXT_D0 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_D0]) define UC_MCONTEXT_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_A7]) define UC_MCONTEXT_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) define UC_SIZE sizeof(ucontext_t) +define _REG_D0 _REG_D0 +define _REG_D1 _REG_D1 +define _REG_D2 _REG_D2 +define _REG_D3 _REG_D3 +define _REG_D4 _REG_D4 +define _REG_D5 _REG_D5 +define _REG_D6 _REG_D6 +define _REG_D7 _REG_D7 +define _REG_A0 _REG_A0 +define _REG_A1 _REG_A1 +define _REG_A2 _REG_A2 +define _REG_A3 _REG_A3 +define _REG_A4 _REG_A4 +define _REG_A5 _REG_A5 +define _REG_A6 _REG_A6 +define _REG_A7 _REG_A7 +define _REG_PC _REG_PC + +define SIZEOF_SIGINFO sizeof(siginfo_t) + define SC_ONSTACK offsetof(struct sigcontext, sc_onstack) define SC___MASK13 offsetof(struct sigcontext, __sc_mask13) define SC_SP offsetof(struct sigcontext, sc_sp) diff --git a/lib/libc/arch/m68k/sys/__sigtramp2.S b/lib/libc/arch/m68k/sys/__sigtramp2.S index e1c78c5a15d7..a85f206f60b5 100755 --- a/lib/libc/arch/m68k/sys/__sigtramp2.S +++ b/lib/libc/arch/m68k/sys/__sigtramp2.S @@ -1,4 +1,4 @@ -/* $NetBSD: __sigtramp2.S,v 1.4 2013/07/16 22:19:16 matt Exp $ */ +/* $NetBSD: __sigtramp2.S,v 1.5 2021/11/21 23:58:09 thorpej Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -27,6 +27,7 @@ */ #include "SYS.h" +#include "assym.h" /* * The m68k signal trampoline is invoked only to return from @@ -39,7 +40,57 @@ * pointer to ucontext structure [8] * pointer to siginfo structure [4] * sp-> signal number [0] + * + * The DWARF register numbers are 0-7 (dX), 8-15 (aX), 16-23 (fpX), + * which maps nicely to _REG_D[0-7] and _REG_A[0-7]. For m68k, there + * is a DWARF pseudo-register for the return address, and additionally + * another DWARF pseudo-register for signal handler return addresses. + * We will specify both return address pseudo-registers (without + * explicitly specifying .cfi_return_column) to keep the compiler + * run-time happy with whichever one it decides to use. */ + +#define DWARF_RETURN_REG 24 +#if defined(__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__) +#define DWARF_SIGRETURN_REG __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__ +#else +#define DWARF_SIGRETURN_REG 25 +#endif + +#define CFI_OFFSET_DWARF_REG(d, r) .cfi_offset d, r * 4 +#define CFI_OFFSET(r) CFI_OFFSET_DWARF_REG(r, r) + + .text + .cfi_startproc simple + .cfi_signal_frame + .cfi_def_cfa _REG_A7, 12 + SIZEOF_SIGINFO + UC_GREGS + CFI_OFFSET(_REG_D0) + CFI_OFFSET(_REG_D1) + CFI_OFFSET(_REG_D2) + CFI_OFFSET(_REG_D3) + CFI_OFFSET(_REG_D4) + CFI_OFFSET(_REG_D5) + CFI_OFFSET(_REG_D6) + CFI_OFFSET(_REG_D7) + CFI_OFFSET(_REG_A0) + CFI_OFFSET(_REG_A1) + CFI_OFFSET(_REG_A2) + CFI_OFFSET(_REG_A3) + CFI_OFFSET(_REG_A4) + CFI_OFFSET(_REG_A5) + CFI_OFFSET(_REG_A6) + CFI_OFFSET(_REG_A7) + CFI_OFFSET_DWARF_REG(DWARF_RETURN_REG, _REG_PC) + CFI_OFFSET_DWARF_REG(DWARF_SIGRETURN_REG, _REG_PC) + +/* + * The unwind entry includes one instruction slot prior to the trampoline + * because the unwinder will look up to (return PC - 1 insn) while unwinding. + * Normally this would be the jump / branch, but since there isn't one in + * this case, we place an explicit nop there instead. + */ + nop + ENTRY_NOPROFILE(__sigtramp_siginfo_2) movl 8(%sp),%a0 /* get pointer to ucontext */ movl %a0,4(%sp) /* put it in the argument slot */ @@ -47,4 +98,5 @@ ENTRY_NOPROFILE(__sigtramp_siginfo_2) SYSTRAP(setcontext) movl %d0,4(%sp) /* error code */ SYSTRAP(exit) /* exit */ + .cfi_endproc END(__sigtramp_siginfo_2)