1*aeae5ce1Skamil/* $NetBSD: __sigtramp2.S,v 1.7 2020/10/19 11:31:01 kamil Exp $ */ 29c5c2215Schristos 39c5c2215Schristos/*- 49c5c2215Schristos * Copyright (c) 2002 The NetBSD Foundation, Inc. 59c5c2215Schristos * All rights reserved. 69c5c2215Schristos * 79c5c2215Schristos * This code is derived from software contributed to The NetBSD Foundation 89c5c2215Schristos * by Christos Zoulas. 99c5c2215Schristos * 109c5c2215Schristos * Redistribution and use in source and binary forms, with or without 119c5c2215Schristos * modification, are permitted provided that the following conditions 129c5c2215Schristos * are met: 139c5c2215Schristos * 1. Redistributions of source code must retain the above copyright 149c5c2215Schristos * notice, this list of conditions and the following disclaimer. 159c5c2215Schristos * 2. Redistributions in binary form must reproduce the above copyright 169c5c2215Schristos * notice, this list of conditions and the following disclaimer in the 179c5c2215Schristos * documentation and/or other materials provided with the distribution. 189c5c2215Schristos * 199c5c2215Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 209c5c2215Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 219c5c2215Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 229c5c2215Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 239c5c2215Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 249c5c2215Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 259c5c2215Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 269c5c2215Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 279c5c2215Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 289c5c2215Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 299c5c2215Schristos * POSSIBILITY OF SUCH DAMAGE. 309c5c2215Schristos */ 319c5c2215Schristos 329c5c2215Schristos#include "SYS.h" 330d692821Skamil#include "assym.h" 349c5c2215Schristos 359c5c2215Schristos/* 369c5c2215Schristos * The i386 signal trampoline is invoked only to return from 379c5c2215Schristos * the signal; the kernel calls the signal handler directly. 389c5c2215Schristos * 399c5c2215Schristos * On entry, stack looks like: 409c5c2215Schristos * 419c5c2215Schristos * ucontext structure [12+sizeof(siginfo_t)] 429c5c2215Schristos * siginfo structure [12] 439c5c2215Schristos * pointer to ucontext structure [8] 449c5c2215Schristos * pointer to siginfo structure [4] 459c5c2215Schristos * sp-> signal number [0] 460d692821Skamil * 470d692821Skamil * The unwind entry includes the one byte prior to the trampoline 480d692821Skamil * because the unwinder will look up (return PC - 1) while unwinding. 490d692821Skamil * Normally (return PC - 1) computes an address inside the call 500d692821Skamil * instruction that created the child frame, but here there is no call 510d692821Skamil * instruction so we have to manually add padding. 529c5c2215Schristos */ 530d692821Skamil .cfi_startproc simple 540d692821Skamil .cfi_signal_frame 550d692821Skamil .cfi_def_cfa esp, 140 560d692821Skamil .cfi_offset eax, UC_GREGS_EAX 570d692821Skamil .cfi_offset ecx, UC_GREGS_ECX 580d692821Skamil .cfi_offset edx, UC_GREGS_EDX 590d692821Skamil .cfi_offset ebx, UC_GREGS_EBX 60*aeae5ce1Skamil .cfi_offset esp, UC_GREGS_ESP 610d692821Skamil .cfi_offset ebp, UC_GREGS_EBP 620d692821Skamil .cfi_offset esi, UC_GREGS_ESI 630d692821Skamil .cfi_offset edi, UC_GREGS_EDI 640d692821Skamil .cfi_offset eip, UC_GREGS_EIP 650d692821Skamil nop 669c5c2215SchristosNENTRY(__sigtramp_siginfo_2) 6758bd20f6Sdrochner leal 12+128(%esp),%eax /* get address of ucontext */ 689c5c2215Schristos movl %eax,4(%esp) /* put it in the argument slot */ 699c5c2215Schristos /* fake return address already there */ 709c5c2215Schristos SYSTRAP(setcontext) /* do setcontext */ 7158bd20f6Sdrochner movl $-1,4(%esp) /* if we return here, something is wrong */ 729c5c2215Schristos SYSTRAP(exit) /* exit */ 730d692821Skamil .cfi_endproc 740d34bfa2SuebayasiEND(__sigtramp_siginfo_2) 75