Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/arch/vax Decorate the VAX signal trampoline with th...



details:   https://anonhg.NetBSD.org/src/rev/dd83029269ef
branches:  trunk
changeset: 1026423:dd83029269ef
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Nov 24 15:05:15 2021 +0000

description:
Decorate the VAX signal trampoline with the appropriate .cfi
directives to allow exception unwind / backtrace across a signal
handler.

N.B. This is currently disabled, as these .cfi directives cause
linker warnings about incompatible TEXTREL relocations in .eh_frame.

diffstat:

 lib/libc/arch/vax/genassym.cf       |  33 ++++++++++-------
 lib/libc/arch/vax/sys/__sigtramp3.S |  68 ++++++++++++++++++++++++++++++++----
 2 files changed, 79 insertions(+), 22 deletions(-)

diffs (142 lines):

diff -r 288a86f5ea25 -r dd83029269ef lib/libc/arch/vax/genassym.cf
--- a/lib/libc/arch/vax/genassym.cf     Wed Nov 24 14:34:51 2021 +0000
+++ b/lib/libc/arch/vax/genassym.cf     Wed Nov 24 15:05:15 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.5 2011/01/25 02:38:15 matt Exp $
+#      $NetBSD: genassym.cf,v 1.6 2021/11/24 15:05:15 thorpej Exp $
 
 #
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -43,18 +43,25 @@
 define _UC_STACK       _UC_STACK
 define _UC_CPU         _UC_CPU
 
-define _REG_R0         4*_REG_R0
-define _REG_R1         4*_REG_R1
-define _REG_R2         4*_REG_R2
-define _REG_R4         4*_REG_R4
-define _REG_R6         4*_REG_R6
-define _REG_R8         4*_REG_R8
-define _REG_R10                4*_REG_R10
-define _REG_AP         4*_REG_AP
-define _REG_SP         4*_REG_SP
-define _REG_FP         4*_REG_FP
-define _REG_PC         4*_REG_PC
-define _REG_PSL                4*_REG_PSL
+define _REG_R0         _REG_R0
+define _REG_R1         _REG_R1
+define _REG_R2         _REG_R2
+define _REG_R3         _REG_R3
+define _REG_R4         _REG_R4
+define _REG_R5         _REG_R5
+define _REG_R6         _REG_R6
+define _REG_R7         _REG_R7
+define _REG_R8         _REG_R8
+define _REG_R9         _REG_R9
+define _REG_R10                _REG_R10
+define _REG_R11                _REG_R11
+define _REG_AP         _REG_AP
+define _REG_FP         _REG_FP
+define _REG_SP         _REG_SP
+define _REG_PC         _REG_PC
+define _REG_PSL                _REG_PSL
+
+define SIZEOF_SIGINFO  sizeof(siginfo_t)
 
 define SS_SP           offsetof(stack_t, ss_sp)
 define SS_SIZE         offsetof(stack_t, ss_size)
diff -r 288a86f5ea25 -r dd83029269ef lib/libc/arch/vax/sys/__sigtramp3.S
--- a/lib/libc/arch/vax/sys/__sigtramp3.S       Wed Nov 24 14:34:51 2021 +0000
+++ b/lib/libc/arch/vax/sys/__sigtramp3.S       Wed Nov 24 15:05:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __sigtramp3.S,v 1.2 2011/01/25 02:38:15 matt Exp $     */
+/*     $NetBSD: __sigtramp3.S,v 1.3 2021/11/24 15:05:16 thorpej Exp $  */
 
 /*
  * Copyright (c) 2003 Matt Thomas <matt%3am-software.com@localhost>
@@ -27,23 +27,70 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "SYS.h"
+#include "assym.h"
+
+#ifdef SYSLIBC_SCCS
+RCSID("$NetBSD: __sigtramp3.S,v 1.3 2021/11/24 15:05:16 thorpej Exp $")
+#endif
+
 /*
  * Signal trampoline; registers when called:
  *     pc, psl - obvious
- *     sp, ap - points to argument list
- *         4(ap) -- signo
- *         8(ap) -- pointer to siginfo
- *        12(ap) -- pointer to ucontext
+ *     sp, ap - points to a CALLG argument list
  *     fp - address of signal handler
+ *
+ * Stack is set up like so:
+ *             ucontext structure
+ *             siginfo structure
+ *             vvvv CALLG argument list vvvv
+ *             12(ap) -- pointer to ucontext
+ *              8(ap) -- pointer to siginfo
+ *              4(ap) -- signal number
+ *     sp ->    0(ap) -- argument count
+ *             ^^^^ CALLG argument list ^^^^
+ *
+ * N.B. all of the DWARF register numbers match our _REG_* constants.
+ * Also notice that while the %ap is adjusted inside the trampoline,
+ * the %sp is not adjusted, and so the CFA base does not change.
  */
 
-#include "SYS.h"
+#define        CFI_OFFSET(r)                   .cfi_offset r, r * 4
 
-#ifdef SYSLIBC_SCCS
-RCSID("$NetBSD: __sigtramp3.S,v 1.2 2011/01/25 02:38:15 matt Exp $")
+       .text
+#if 0
+       .cfi_startproc simple
+       .cfi_signal_frame
+       .cfi_def_cfa _REG_SP, 16 + SIZEOF_SIGINFO + UC_GREGS
+       CFI_OFFSET(_REG_R0)
+       CFI_OFFSET(_REG_R1)
+       CFI_OFFSET(_REG_R2)
+       CFI_OFFSET(_REG_R3)
+       CFI_OFFSET(_REG_R4)
+       CFI_OFFSET(_REG_R5)
+       CFI_OFFSET(_REG_R6)
+       CFI_OFFSET(_REG_R7)
+       CFI_OFFSET(_REG_R8)
+       CFI_OFFSET(_REG_R9)
+       CFI_OFFSET(_REG_R10)
+       CFI_OFFSET(_REG_R11)
+       CFI_OFFSET(_REG_AP)
+       CFI_OFFSET(_REG_FP)
+       CFI_OFFSET(_REG_SP)
+       CFI_OFFSET(_REG_PC)
+       CFI_OFFSET(_REG_PSL)
 #endif
 
-       .text
+/*
+ * The unwind entry includes one instruction slot prior to the trampoline
+ * because the unwinder will look up to (return PC - 1) 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.
+ */
+
+#if 0
+       nop
+#endif
        _ALIGN_TEXT
 
        .globl  _C_LABEL(__sigtramp_siginfo_3)
@@ -53,3 +100,6 @@
        addl2 $8,%ap                    # arg is pointer to ucontext
        SYSTRAP(setcontext)             # exit from here
        halt                            # illegal insn
+#if 0
+       .cfi_endproc
+#endif



Home | Main Index | Thread Index | Old Index