From patchwork Tue Mar 15 18:15:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Werner X-Patchwork-Id: 591 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:44:01 -0000 Delivered-To: patches@linaro.org Received: by 10.151.46.5 with SMTP id y5cs77955ybj; Tue, 15 Mar 2011 11:15:58 -0700 (PDT) Received: by 10.227.209.138 with SMTP id gg10mr4292509wbb.212.1300212955781; Tue, 15 Mar 2011 11:15:55 -0700 (PDT) Received: from mtagate2.uk.ibm.com (mtagate2.uk.ibm.com [194.196.100.162]) by mx.google.com with ESMTPS id e5si121528wbi.91.2011.03.15.11.15.54 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Mar 2011 11:15:54 -0700 (PDT) Received-SPF: neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) client-ip=194.196.100.162; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) smtp.mail=ken.werner@linaro.org Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p2FIFkUd015979 for ; Tue, 15 Mar 2011 18:15:46 GMT Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2FIG5171437868 for ; Tue, 15 Mar 2011 18:16:05 GMT Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2FIFjkc008752 for ; Tue, 15 Mar 2011 12:15:45 -0600 Received: from localhost.localdomain (dyn-9-152-224-51.boeblingen.de.ibm.com [9.152.224.51]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p2FIFjdb008732; Tue, 15 Mar 2011 12:15:45 -0600 From: Ken Werner To: libunwind-devel@nongnu.org Subject: [PATCH 1/4] Add ARM signal frame detection Date: Tue, 15 Mar 2011 18:15:41 +0000 Message-Id: <1300212944-24984-2-git-send-email-ken.werner@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1300212944-24984-1-git-send-email-ken.werner@linaro.org> References: <1300212944-24984-1-git-send-email-ken.werner@linaro.org> From: Zachary T Welch Implements a check for call to sigreturn that the kernel will have setup before jumping to the signal handler. Signed-off-by: Ken Werner --- src/arm/Gis_signal_frame.c | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/src/arm/Gis_signal_frame.c b/src/arm/Gis_signal_frame.c index 77548d5..a746182 100644 --- a/src/arm/Gis_signal_frame.c +++ b/src/arm/Gis_signal_frame.c @@ -1,5 +1,6 @@ /* libunwind - a platform-independent unwind library Copyright (C) 2008 CodeSourcery + Copyright 2011 Linaro Limited This file is part of libunwind. @@ -25,11 +26,39 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include "unwind_i.h" -/* FIXME for ARM. */ +#ifdef __linux__ +#include + +#define ARM_SIGRETURN (0xef000000UL |(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)) +#define THUMB_SIGRETURN (0xdf00UL << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE)) +#define MOV_R7_SIGRETURN (0xe3a07000UL | (__NR_sigreturn - __NR_SYSCALL_BASE)) +#endif PROTECTED int unw_is_signal_frame (unw_cursor_t *cursor) { +#ifdef __linux__ + struct cursor *c = (struct cursor *) cursor; + unw_word_t w0, ip; + unw_addr_space_t as; + unw_accessors_t *a; + void *arg; + int ret; + + as = c->dwarf.as; + a = unw_get_accessors (as); + arg = c->dwarf.as_arg; + + ip = c->dwarf.ip; + if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0) + return ret; + ret = (w0 == ARM_SIGRETURN) || (w0 == MOV_R7_SIGRETURN) + || (w0 == THUMB_SIGRETURN); + fprintf (stderr, "w0=%8.8x ret=%d\n", w0, ret); + Debug (16, "returning %d\n", ret); + return ret; +#else printf ("%s: implement me\n", __FUNCTION__); return -UNW_ENOINFO; +#endif }