1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-05-19 03:25:18 +02:00

Provide the FreeBSD implementation for _UI_siglongjmp_cont on x86.

On FreeBSD, _NSIG is at least 128, so just pass a pointer to the
signal mask in the register.
Add my copyright.
This commit is contained in:
Konstantin Belousov 2012-02-05 11:47:47 +02:00
parent 1774384098
commit 59328832f7
2 changed files with 30 additions and 1 deletions

View file

@ -92,7 +92,8 @@ siglongjmp (sigjmp_buf env, int val)
if (!resume_restores_sigmask (&c, wp) && wp[JB_MASK_SAVED])
{
/* sigmask was saved */
if (UNW_NUM_EH_REGS < 4 || _NSIG >= 16 * sizeof (unw_word_t))
#if defined(__linux__)
if (UNW_NUM_EH_REGS < 4 || _NSIG > 16 * sizeof (unw_word_t))
/* signal mask doesn't fit into EH arguments and we can't
put it on the stack without overwriting something
else... */
@ -102,6 +103,12 @@ siglongjmp (sigjmp_buf env, int val)
|| (_NSIG > 8 * sizeof (unw_word_t)
&& unw_set_reg (&c, UNW_REG_EH + 3, wp[JB_MASK + 1]) < 0))
abort ();
#elif defined(__FreeBSD__)
if (unw_set_reg (&c, UNW_REG_EH + 2, &wp[JB_MASK]) < 0)
abort();
#else
#error Port me
#endif
cont = &_UI_siglongjmp_cont;
}

View file

@ -1,6 +1,7 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
Copyright (C) 2011 Konstantin Belousov <kib@FreeBSD.org>
This file is part of libunwind.
@ -25,7 +26,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
.globl _UI_siglongjmp_cont
#if defined(__linux__)
#define SIG_SETMASK 2
#elif defined(__FreeBSD__)
#define SIG_SETMASK 3
#endif
/* Stack layout at this point:
@ -39,6 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
.type _UI_siglongjmp_cont, @function
_UI_siglongjmp_cont:
.cfi_startproc
#ifdef __linux__
.cfi_register 8, 0 /* IP saved in EAX */
.cfi_def_cfa_offset 8
mov %esp, %ecx /* pass address of signal mask in 3rd sc arg */
@ -64,6 +70,22 @@ _UI_siglongjmp_cont:
lea 8(%esp), %esp /* pop sigmask */
.cfi_adjust_cfa_offset -4
jmp *%edx
#elif defined(__FreeBSD__)
pushl %eax
pushl %edx
pushl $0
pushl %ecx
pushl $SIG_SETMASK
movl $340,%eax
pushl %eax
int $0x80
addl $16,%esp
popl %eax
popl %edx
jmp *%edx
#else
#error Port me
#endif
.cfi_endproc
.size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont
/* We do not need executable stack. */