From patchwork Tue Mar 22 18:37:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Werner X-Patchwork-Id: 740 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:45:19 -0000 Delivered-To: patches@linaro.org Received: by 10.204.113.5 with SMTP id y5cs10162bkp; Tue, 22 Mar 2011 11:37:15 -0700 (PDT) Received: by 10.14.19.199 with SMTP id n47mr2120917een.48.1300819033236; Tue, 22 Mar 2011 11:37:13 -0700 (PDT) Received: from mtagate6.uk.ibm.com (mtagate6.uk.ibm.com [194.196.100.166]) by mx.google.com with ESMTPS id u50si9653320eei.24.2011.03.22.11.37.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Mar 2011 11:37:13 -0700 (PDT) Received-SPF: neutral (google.com: 194.196.100.166 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) client-ip=194.196.100.166; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.196.100.166 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) smtp.mail=ken.werner@linaro.org Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate6.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p2MIbBeM027771 for ; Tue, 22 Mar 2011 18:37:11 GMT Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2MIbbVw1974326 for ; Tue, 22 Mar 2011 18:37:37 GMT Received: from d06av10.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2MIbA17016692 for ; Tue, 22 Mar 2011 12:37:10 -0600 Received: from localhost.localdomain (dyn-9-152-224-51.boeblingen.de.ibm.com [9.152.224.51]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p2MIb9Tj016683; Tue, 22 Mar 2011 12:37:10 -0600 From: Ken Werner To: libunwind-devel@nongnu.org Subject: [PATCH 1/3] Add ARM signal frame detection Date: Tue, 22 Mar 2011 18:37:06 +0000 Message-Id: <1300819028-31314-2-git-send-email-ken.werner@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1300819028-31314-1-git-send-email-ken.werner@linaro.org> References: <1300819028-31314-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 }