From patchwork Tue Aug 15 16:27:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 801674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460396-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="c+SEwusN"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xWydQ5gsdz9sPm for ; Wed, 16 Aug 2017 02:30:34 +1000 (AEST) 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:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=OCLW124qhvTPc6FDIcQxNrCT5n4ftDxQ2iU+FP2aCi0knI+PkRnLk vurgwe8sGQO+S7Ut7EUifuhqHHFq76OyPq9UTq1ddHT6ZuCw77M7s3mTz61u4ep9 Xpt9EqZ7DDXzTolPajg/xMI+N2DHmt92fGCdOk8eyhpaSn4C2GWd0Y= 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:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=OLJWbUR7B4GWJCRkvfUEPeQkJ38=; b=c+SEwusN9uoYPDUbbiNdfz6umwPo pRIkHImVCLeY/kK/Ur+kXO1UeSqFiZZxyS4r4Au0kG2sm7RUvRfNZc0KmbIfPr/M mRxSkU4KJsB6z98EdIEWMbFUcIe1TOtEyS9YsXQqRbKxKImBX8+X1JnQ7c78onn0 9mP20l/F/APTwNw= Received: (qmail 130335 invoked by alias); 15 Aug 2017 16:28:16 -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 129707 invoked by uid 89); 15 Aug 2017 16:27:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0048.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Aug 2017 16:27:41 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by VI1PR08MB2670.eurprd08.prod.outlook.com (10.175.245.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.17; Tue, 15 Aug 2017 16:27:37 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a%18]) with mapi id 15.01.1341.020; Tue, 15 Aug 2017 16:27:37 +0000 From: Wilco Dijkstra To: GCC Patches , James Greenhalgh CC: nd Subject: Re: [PATCH][AArch64] PR71951: Fix unwinding with -fomit-frame-pointer Date: Tue, 15 Aug 2017 16:27:37 +0000 Message-ID: References: In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB2670; 6:pQVNpweEN5SNfv2prBnNbLqwGFjzvoEPA9KnrhOUJb/0vpiuRZipc/umcIlN8CiItWd3Kt/x/C1K54gBl64gDWpOGQ8pisAauc/rjXm+tseHYGNotrC4aB/r60RFPJp4EbFI+OUAIonKoUX/XeRfcjJhgywUB+39JCHpQYkjEmGgPEc0QdRWY1KaXjszweWXsIGw3AZfyFGO0RcD5xyCYHGsTc6pliHbwtEqYzprkHhGmTwxZwq89DCl3FaU9vgQS0xz1I+zXDG+CmO40+f85bbMDRUpFJ+uw1Ub2mwvvAQRHxc6o8CiyFlYGTMw39hlhcZiuBob5uWYMGmrQRYi2A==; 5:ePworEet7JTVunk0E5EqUmvQYLyTNV6kY8g1EgJcZL15U1XTqmHd9a69KimzxvMfi92UZFkW8sFlQCwX+LflQKwE4RbbCr7Hf1B8qHy9r0OLIdQkyZJtwaX3WXlYBKiiWXIHoqrCob/FksOET/LIjw==; 24:qcoM7OWIvQ29XOafpW4FJag2ShGk3BlWb/xzyvmicE3uWhu/FM+pTXGXpA4PnJGs/FLep+OFC8q7UlshkLsHUKgWDsjEvjbwsDlEyQzzMiY=; 7:r3+YW9pCsL5RtLrCrrMYkMTZyJVyr+b0Oi3CzrEqMmTIxoUmSUPMa2ge+fp2bMcdHKdzYd/OPS74LY5K3iQ3WIxKUd0Fk7epaYroPFoDMzFQ7E6nn7kpvCG/wdLZuo9Rf0pPezJXSSbEmC6GPy/hEjJveq0pFUGYKhLE/wiOzccgNdIreQcNvdsvf3VDTt9Zm9eSPdWKKUkACctuuS1kUs2Jw3yTvSQ37ro97i2n/Tk= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: db3d4903-9356-44ea-ea0b-08d4e3fa8ad6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR08MB2670; x-ms-traffictypediagnostic: VI1PR08MB2670: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR08MB2670; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR08MB2670; x-forefront-prvs: 04004D94E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(189002)(54534003)(199003)(377424004)(53936002)(305945005)(3846002)(3660700001)(2900100001)(7736002)(86362001)(575784001)(2950100002)(7696004)(478600001)(66066001)(5250100002)(6506006)(33656002)(8936002)(97736004)(189998001)(53546010)(2906002)(81156014)(230783001)(102836003)(6116002)(3280700002)(8676002)(81166006)(229853002)(68736007)(105586002)(101416001)(74316002)(50986999)(54356999)(6436002)(76176999)(25786009)(14454004)(106356001)(6246003)(6636002)(9686003)(5660300001)(4326008)(72206003)(55016002)(99286003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB2670; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Aug 2017 16:27:37.5345 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2670 ping From: Wilco Dijkstra Sent: 31 July 2017 16:57 To: GCC Patches; James Greenhalgh Cc: nd Subject: [PATCH][AArch64] PR71951: Fix unwinding with -fomit-frame-pointer   As described in PR71951, if libgcc is built with -fomit-frame-pointer, unwinding crashes, for example while doing a backtrace.  The underlying reason is the Dwarf unwinder does not setup the frame pointer register in the initialization code.  When later unwinding a function that uses the frame pointer, it tries to read FP using _Unwind_GetGR, and this crashes if has never restored FP.  To unwind correctly the first frame must save and restore FP (it is unwound in a special way so that it uses SP instead of FP).  This is done by adding -fno-omit-frame-pointer. OK for commit and backport to GCC6/7? ChangeLog: 2017-07-31  Wilco Dijkstra          PR target/71951         * config/aarch64/aarch64.h (LIBGCC2_UNWIND_ATTRIBUTE): Define. diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 7f91edb5713d7e8eda2f0a024a0f97b4e111c4b0..03fd93046bdbdb03bd7d0c4573928f504640f7e1 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -971,4 +971,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);  extern tree aarch64_fp16_type_node;  extern tree aarch64_fp16_ptr_type_node;   +/* The generic unwind code in libgcc does not initialize the frame pointer. +   So in order to unwind a function using a frame pointer, the very first +   function that is unwound must save the frame pointer.  That way the frame +   pointer is restored and its value is now valid - otherwise _Unwind_GetGR +   crashes.  Libgcc can now be safely built with -fomit-frame-pointer.  */ +#define LIBGCC2_UNWIND_ATTRIBUTE \ +  __attribute__((optimize ("no-omit-frame-pointer"))) +  #endif /* GCC_AARCH64_H */