1/* libunwind - a platform-independent unwind library 2 Copyright (C) 2004 Hewlett-Packard Co 3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 4 Copyright (C) 2011 Konstantin Belousov <kib@FreeBSD.org> 5 6This file is part of libunwind. 7 8Permission is hereby granted, free of charge, to any person obtaining 9a copy of this software and associated documentation files (the 10"Software"), to deal in the Software without restriction, including 11without limitation the rights to use, copy, modify, merge, publish, 12distribute, sublicense, and/or sell copies of the Software, and to 13permit persons to whom the Software is furnished to do so, subject to 14the following conditions: 15 16The above copyright notice and this permission notice shall be 17included in all copies or substantial portions of the Software. 18 19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 26 27 .globl _UI_siglongjmp_cont 28 29#if defined(__linux__) 30#define SIG_SETMASK 2 31#elif defined(__FreeBSD__) 32#define SIG_SETMASK 3 33#endif 34 35 /* Stack layout at this point: 36 37 +------------+ <- original $esp (at time of setjmp() call) 38 | sigmask[1] | 39 +------------+ 40 | sigmask[0] | 41 +------------+ 42 */ 43 44 .type _UI_siglongjmp_cont, @function 45_UI_siglongjmp_cont: 46 .cfi_startproc 47#ifdef __linux__ 48 .cfi_register 8, 0 /* IP saved in EAX */ 49 .cfi_def_cfa_offset 8 50 mov %esp, %ecx /* pass address of signal mask in 3rd sc arg */ 51 push %eax /* save target IP */ 52 .cfi_adjust_cfa_offset 4 53 .cfi_offset 8, -12 54 push %edx /* save return value */ 55 .cfi_adjust_cfa_offset 4 56 push %ebx /* save %ebx (preserved) */ 57 .cfi_adjust_cfa_offset 4 58 .cfi_offset 3, -20 59 mov $SIG_SETMASK, %ebx /* 1st syscall arg (how) */ 60 xor %edx, %edx /* pass NULL as 3rd syscall arg (old maskp) */ 61 int $0x80 62 pop %ebx /* restore %ebx */ 63 .cfi_adjust_cfa_offset -4 64 .cfi_restore 3 65 pop %eax /* fetch return value */ 66 .cfi_adjust_cfa_offset -4 67 pop %edx /* pop target IP */ 68 .cfi_adjust_cfa_offset -4 69 .cfi_register 8, 2 /* saved IP is now n EDX */ 70 lea 8(%esp), %esp /* pop sigmask */ 71 .cfi_adjust_cfa_offset -4 72 jmp *%edx 73#elif defined(__FreeBSD__) 74 pushl %eax 75 pushl %edx 76 pushl $0 77 pushl %ecx 78 pushl $SIG_SETMASK 79 movl $340,%eax 80 pushl %eax 81 int $0x80 82 addl $16,%esp 83 popl %eax 84 popl %edx 85 jmp *%edx 86#else 87#error Port me 88#endif 89 .cfi_endproc 90 .size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont 91 /* We do not need executable stack. */ 92 .section .note.GNU-stack,"",@progbits 93