From patchwork Thu Apr 21 15:52:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Werner X-Patchwork-Id: 1148 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:39 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs169681qai; Thu, 21 Apr 2011 08:53:04 -0700 (PDT) Received: by 10.216.121.200 with SMTP id r50mr2226769weh.7.1303401183316; Thu, 21 Apr 2011 08:53:03 -0700 (PDT) Received: from mtagate3.uk.ibm.com (mtagate3.uk.ibm.com [194.196.100.163]) by mx.google.com with ESMTPS id s51si4423756weh.195.2011.04.21.08.53.02 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Apr 2011 08:53:03 -0700 (PDT) Received-SPF: neutral (google.com: 194.196.100.163 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) client-ip=194.196.100.163; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.196.100.163 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) smtp.mail=ken.werner@linaro.org Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p3LFqst3030374 for ; Thu, 21 Apr 2011 15:52:54 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p3LFrqO91654884 for ; Thu, 21 Apr 2011 16:53:52 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p3LFqsIg019617 for ; Thu, 21 Apr 2011 09:52:54 -0600 Received: from localhost.localdomain (dyn-9-152-224-51.boeblingen.de.ibm.com [9.152.224.51]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p3LFqroh019567; Thu, 21 Apr 2011 09:52:54 -0600 From: Ken Werner To: libunwind-devel@nongnu.org Subject: [PATCH 3/5] ARM: tests/Gtest-dyn1.c fixes. Date: Thu, 21 Apr 2011 17:52:40 +0200 Message-Id: <1303401162-14277-4-git-send-email-ken.werner@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1303401162-14277-1-git-send-email-ken.werner@linaro.org> References: <1303401162-14277-1-git-send-email-ken.werner@linaro.org> Define an appropriate fdesc struct and its corresponding accessors that take care of the thumb marker on ARM. Call the __clear_cache built-in instead of flush_cache if the GNU compiler is used. Signed-off-by: Ken Werner --- tests/Gtest-dyn1.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/tests/Gtest-dyn1.c b/tests/Gtest-dyn1.c index ad49a5c..b7b788f 100644 --- a/tests/Gtest-dyn1.c +++ b/tests/Gtest-dyn1.c @@ -62,6 +62,16 @@ struct fdesc # define get_fdesc(fdesc,func) (fdesc = *(struct fdesc *) &(func)) # define get_funcp(fdesc) ((template_t) &(fdesc)) # define get_gp(fdesc) ((fdesc).gp) +#elif __arm__ +struct fdesc + { + long code; + long is_thumb; + }; +# define get_fdesc(fdesc,func) ({(fdesc).code = (long) &(func) & ~0x1; \ + (fdesc).is_thumb = (long) &(func) & 0x1;}) +# define get_funcp(fdesc) ((template_t) ((fdesc).code | (fdesc).is_thumb)) +# define get_gp(fdesc) (0) #else struct fdesc { @@ -170,7 +180,12 @@ main (int argc, char *argv[]) memcpy (mem, (void *) fdesc.code, MAX_FUNC_SIZE); mprotect ((void *) ((long) mem & ~(getpagesize () - 1)), 2*getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC); + +#ifdef __GNUC__ + __clear_cache(mem, mem + MAX_FUNC_SIZE); +#else flush_cache (mem, MAX_FUNC_SIZE); +#endif signal (SIGSEGV, sighandler);