From patchwork Wed Nov 27 10:43:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Leach X-Patchwork-Id: 294556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 17C782C007C for ; Wed, 27 Nov 2013 21:43:30 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=yZnXxmzFUuCGVKfT Jb/7/uZdKwHJYLTXKwTGF6sudITNUr1v1NHshRDIhVjMeDBW7lTErkgKo8M08hwf KKPKtwR9Sd0Ub5MdR/6n/EzXBmikupLmKvMDUOrtBcS60F832kf+lFa7Yxdb65FL psLyUaUpfTEf4LH/l9mOy1XrlAc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=pqLFM/L8axl6j/RmxaLcjd rtaBw=; b=ezUwQxwbkD0JrjS4s3O2hcxIGMOdv1DEYQD8KYTISdnTDU3vvgdoSK fuBZHXH+0Axv8vp8SM7EYvTMhIkvkphzJ11Gi14rCQyGWkGEymLmH8Rw2MU//k3G CrvAEuEKVTcPbttIO1CHxkHFkJSh10whsJmzjlAbR3CgA7Wk9t/J0= Received: (qmail 10010 invoked by alias); 27 Nov 2013 10:43:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9999 invoked by uid 89); 27 Nov 2013 10:43:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.6 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: service87.mimecast.com Received: from Unknown (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Nov 2013 10:43:19 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 27 Nov 2013 10:43:10 +0000 Received: from e106496-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 27 Nov 2013 10:43:07 +0000 From: Matthew Leach To: gcc-patches@gcc.gnu.org Cc: pinskia@gmail.com, Matthew Leach Subject: [PATCH v2] libgcc: AArch64: Check for correct signal insns on BE when unwinding Date: Wed, 27 Nov 2013 10:43:04 +0000 Message-Id: <1385548984-24298-1-git-send-email-matthew.leach@arm.com> X-MC-Unique: 113112710431003101 X-IsSubscribed: yes Hi, When unwinding the stack, the unwind code checks for two opcodes that denote a registrations of a signal handler. This is broken on BE as the opcodes will be in the wrong byte-order as insns are always LE. Add the correct checks when compiling for AArch64 big endian. This patch fixes all glibc backtrace tests and causes no other regressions on glibc. Please note that I don't have commit access, if this is OK could someone merge it for me? Thanks, Matt Leach libgcc/ 2013-11-26 Matthew Leach * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state): Check for correct opcodes on BE. diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h index fde4d14..8b0d7fe 100644 --- a/libgcc/config/aarch64/linux-unwind.h +++ b/libgcc/config/aarch64/linux-unwind.h @@ -25,6 +25,19 @@ #include #include + +/* Since insns are always stored LE, on a BE system the opcodes will + be loaded byte-reversed. Therefore, define two sets of opcodes, + one for LE and one for BE. */ + +#if __AARCH64EB__ +#define MOVZ_X8_8B 0x681180d2 +#define SVC_0 0x010000d4 +#else +#define MOVZ_X8_8B 0xd2801168 +#define SVC_0 0xd4000001 +#endif + #define MD_FALLBACK_FRAME_STATE_FOR aarch64_fallback_frame_state static _Unwind_Reason_Code @@ -55,7 +68,7 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, 0xd2801168 movz x8, #0x8b 0xd4000001 svc 0x0 */ - if (pc[0] != 0xd2801168 || pc[1] != 0xd4000001) + if (pc[0] != MOVZ_X8_8B || pc[1] != SVC_0) { return _URC_END_OF_STACK; }