From: Paul Brook <paul@codesourcery.com>
To: Andrew Haley <aph@redhat.com>
Cc: gcc@gcc.gnu.org, Daniel Jacobowitz <drow@false.org>,
Ken Werner <ken.werner@linaro.org>,
ramana.radhakrishnan@arm.com, richard.earnshaw@arm.com
Subject: Re: ARM Linux EABI: unwinding through a segfault handler
Date: Thu, 27 Oct 2011 13:25:00 -0000 [thread overview]
Message-ID: <201110271354.26961.paul@codesourcery.com> (raw)
In-Reply-To: <4EA94748.1050702@redhat.com>
> I'm trying to understand what you mean, but your comments are rather
> obscure. Which file do you think I should change? Just tell me where to
> look and I'll do it.
glibc/ports/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S Currently has:
.fnstart
.save {r0-r15}
.pad #32
nop
ENTRY(__default_sa_restorer_v2)
mov r7, $SYS_ify(sigreturn)
swi 0x0
.fnend
This needs changing to:
.fnstart
.personality __gnu_personality_sigframe
nop
ENTRY(__default_sa_restorer_v2)
mov r7, $SYS_ify(sigreturn)
swi 0x0
.fnend
The implementation of __gnu_personality_sigframe looks something like:
#include <unwind.h>
static void adjust_sp(context, int n)
{
_Unwind_Word sp;
_Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp);
sp += n;
_Unwind_VRS_Set (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp);
}
static uint32_t get_cpsr(context)
{
return sp[...];
}
_Unwind_Reason_Code
__gnu_personality_sigframe (_Unwind_State state,
_Unwind_Control_Block *ucbp,
_Unwind_Context *context)
{
int reg;
uint32_t cpsr;
uint32_t pc;
uint32_t *sp;
/* We never have any handlers or cleanups.
Just Unwind the signal frame and keep going. */
_Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp);
sp -= ...;
if (GLRO (dl_hwcap) & HWCAP_ARM_VFP)
{
foreach(vfp_reg)
_Unwind_VRS_Set(context, _UVRSC_VFP, ..., _UVRSD_DOUBLE, &sp[...]);
/* Don't forget about VFP3 (i.e. D16-D31 if they exist). */
}
foreach(core_reg)
_Unwind_VRS_Set (context, _UVRSC_CORE, ..., _UVRSD_UINT32, &sp[...]);
pc = sp[...];
cpsr = sp[...];
/* Set mode bit from saved CPSR. */
pc &= ~1;
if (cpsr & CPSR_T)
pc |= 1;
/* Advance PC past the faulting instruction. */
if ((cpsr & CPSR_T) && (*(uint16_t *)(pc & ~1) < 0xe800))
pc += 2;
else
pc += 4;
_Unwind_VRS_Set (context, _UVRSC_CORE, R_PC, _UVRSD_UINT32, &pc);
/* We don't/can't restore CPSR and FPSR. However the EABI requires these
have fixed values at public entry points. Hope that subsequent
catch/cleanup handlers are ok with that value. */
return _URC_CONTINUE_UNWIND;
}
For bonus points have __gnu_personality_sigframe automagically handle bit old
and new layouts, removing the _v1/_v2 hacks.
Paul
next prev parent reply other threads:[~2011-10-27 12:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-25 12:26 Andrew Haley
2011-08-25 16:57 ` David Daney
2011-08-25 17:01 ` Andrew Haley
2011-08-29 15:19 ` Ken Werner
2011-08-29 17:14 ` Daniel Jacobowitz
2011-08-30 9:11 ` Andrew Haley
2011-08-30 15:28 ` Joseph S. Myers
2011-10-27 8:33 ` Paul Brook
2011-10-27 9:06 ` Andrew Haley
2011-10-27 12:54 ` Paul Brook
2011-10-27 12:55 ` Andrew Haley
2011-10-27 13:25 ` Paul Brook [this message]
2015-02-03 22:41 ` mads_bn
2015-09-18 15:37 ` Matthijs van Duin
2015-10-03 20:41 ` Matthijs van Duin
2015-10-04 8:05 ` Andrew Haley
2015-10-04 12:09 ` Matthijs van Duin
2015-10-05 15:24 ` Ian Lance Taylor
2015-02-03 22:42 ` mads_bn
2014-08-01 12:25 ` prafullakota
2015-10-04 8:50 SV: " mads_bn
2015-10-04 13:09 ` Matthijs van Duin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201110271354.26961.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=aph@redhat.com \
--cc=drow@false.org \
--cc=gcc@gcc.gnu.org \
--cc=ken.werner@linaro.org \
--cc=ramana.radhakrishnan@arm.com \
--cc=richard.earnshaw@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).