xref: /netbsd-src/lib/libc/arch/arm/sys/__sigtramp2.S (revision 3f3a46002b04f3c5a00b58bb70b5c01c120fddae)
1*3f3a4600Sskrll/*	$NetBSD: __sigtramp2.S,v 1.5 2021/11/27 10:00:01 skrll Exp $	*/
2f3198687Smatt
3f3198687Smatt/*-
4f3198687Smatt * Copyright (c) 2002 The NetBSD Foundation, Inc.
5f3198687Smatt * All rights reserved.
6f3198687Smatt *
7f3198687Smatt * This code is derived from software contributed to The NetBSD Foundation
8f3198687Smatt * by Jason R. Thorpe.
9f3198687Smatt *
10f3198687Smatt * Redistribution and use in source and binary forms, with or without
11f3198687Smatt * modification, are permitted provided that the following conditions
12f3198687Smatt * are met:
13f3198687Smatt * 1. Redistributions of source code must retain the above copyright
14f3198687Smatt *    notice, this list of conditions and the following disclaimer.
15f3198687Smatt * 2. Redistributions in binary form must reproduce the above copyright
16f3198687Smatt *    notice, this list of conditions and the following disclaimer in the
17f3198687Smatt *    documentation and/or other materials provided with the distribution.
18f3198687Smatt *
19f3198687Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20f3198687Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21f3198687Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22f3198687Smatt * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23f3198687Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24f3198687Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25f3198687Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26f3198687Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27f3198687Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28f3198687Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29f3198687Smatt * POSSIBILITY OF SUCH DAMAGE.
30f3198687Smatt */
31f3198687Smatt
32f3198687Smatt#include "SYS.h"
33389a0704Sthorpej#include "assym.h"
34f3198687Smatt
35f3198687Smatt/*
36f3198687Smatt * The ARM signal trampoline is invoked only to return from
37f3198687Smatt * the signal; the kernel calls the signal handler directly.
38f3198687Smatt *
39f3198687Smatt * On entry, the stack looks like:
40f3198687Smatt *
41f3198687Smatt *		ucontext structure
42f3198687Smatt *	sp->	siginfo structure
43f3198687Smatt * and r5 points to the ucontext
44f3198687Smatt */
45389a0704Sthorpej
46389a0704Sthorpej#define	CFI_OFFSET(r)			.cfi_offset r, r * 4
47389a0704Sthorpej
48389a0704Sthorpej	_TEXT_SECTION
49389a0704Sthorpej	.cfi_startproc
50389a0704Sthorpej	.cfi_signal_frame
51389a0704Sthorpej	.cfi_def_cfa _REG_SP, SIZEOF_SIGINFO + _UC_GREGS
52389a0704Sthorpej	CFI_OFFSET(_REG_R0)
53389a0704Sthorpej	CFI_OFFSET(_REG_R1)
54389a0704Sthorpej	CFI_OFFSET(_REG_R2)
55389a0704Sthorpej	CFI_OFFSET(_REG_R3)
56389a0704Sthorpej	CFI_OFFSET(_REG_R4)
57389a0704Sthorpej	CFI_OFFSET(_REG_R5)
58389a0704Sthorpej	CFI_OFFSET(_REG_R6)
59389a0704Sthorpej	CFI_OFFSET(_REG_R7)
60389a0704Sthorpej	CFI_OFFSET(_REG_R8)
61389a0704Sthorpej	CFI_OFFSET(_REG_R9)
62389a0704Sthorpej	CFI_OFFSET(_REG_R10)
63389a0704Sthorpej	CFI_OFFSET(_REG_R11)
64389a0704Sthorpej	CFI_OFFSET(_REG_R12)
65389a0704Sthorpej	CFI_OFFSET(_REG_R13)	/* a.k.a. _REG_SP */
66389a0704Sthorpej	CFI_OFFSET(_REG_R14)	/* a.k.a. _REG_LR */
67389a0704Sthorpej	.cfi_return_column _REG_R15
68389a0704Sthorpej	CFI_OFFSET(_REG_R15)	/* a.k.a. _REG_PC */
69389a0704Sthorpej
70389a0704Sthorpej/*
71389a0704Sthorpej * The unwind entry includes the one instruction prior to the trampoline
72389a0704Sthorpej * because the unwinder will look up (return PC - 1) while unwinding.
73389a0704Sthorpej * Normally this would be the jump / branch, but since there isn't one in
74389a0704Sthorpej * this case, we place an explicit nop there instead.
75389a0704Sthorpej */
76389a0704Sthorpej	nop
77389a0704Sthorpej
78f3198687SmattENTRY_NP(__sigtramp_siginfo_2)
79f3198687Smatt	mov r0, r5				/* set the arg         */
80f3198687Smatt	SYSTRAP(setcontext)			/* and call setcontext */
81f3198687Smatt
82f3198687Smatt	/* If that failed, exit with the error code. */
83f3198687Smatt	SYSTRAP(exit)
84389a0704Sthorpej	.cfi_endproc
852fa2fc25SmattEND(__sigtramp_siginfo_2)
86