From patchwork Mon Jul 31 15:57:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 795843 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-459391-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="L3o8xzZg"; 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 3xLkdP15msz9s8J for ; Tue, 1 Aug 2017 01:58:32 +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:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=rB8 IJv/uZ3RUiuoIAj0S5+m+n3Fd0JofKftAoHUv/4TKTfi+hh8gO6pohdaFjtnrwJE 2YDmkZDkQnKpjx6kvpO4erZNpHJbY0jyzs9z7vb5mQJD8z1/KTkZSepAd3IVd0N1 rKwVooaz7mIbi8Ks3/ppS1PbnNTYF1DdXo29/HWk= 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:mime-version; s=default; bh=a1Hcdjc+G kO+8pnj5gUZe4hry+E=; b=L3o8xzZgE5pfGHde+s0oaLmjH2IO1P/UyaaHXPPKu 43cFFN83Op9L5CdqxvsCDSHFrZrBGxydOU5G4RUehWNmY+1UVq6rf2dO790kNQOs T4IjwHl4aJI+6p2p5SLPfaEA5qHyyweXv0JrMFfsxM0PMKFUtBWZelnatMRDUY5d Ek= Received: (qmail 45083 invoked by alias); 31 Jul 2017 15:58:25 -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 45023 invoked by uid 89); 31 Jul 2017 15:58:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 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=Hx-languages-length:1710 X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0046.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Jul 2017 15:58:21 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by DB6PR08MB2661.eurprd08.prod.outlook.com (10.175.234.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1304.22; Mon, 31 Jul 2017 15:58:18 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::cd9d:80f1:82d8:5181]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::cd9d:80f1:82d8:5181%18]) with mapi id 15.01.1304.022; Mon, 31 Jul 2017 15:57:57 +0000 From: Wilco Dijkstra To: GCC Patches , James Greenhalgh CC: nd Subject: [PATCH][AArch64] PR71951: Fix unwinding with -fomit-frame-pointer Date: Mon, 31 Jul 2017 15:57:57 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR08MB2661; 7:ywyfF7BKyMzjgCUSdHldnxajgmKAX3YoTyfmxJLy/SEDyuRxQBZsy+rAkf23dhWxPt/kPEX3XnAkUq3fmUXwkTy2iwqzrCg/9JBqEv5DEb+gC36FozVqhAYvTn7S4I1uWpOD2w3syIWh4BTsQZ0PeZifb2D+IHY2PZJrxuxZ4CWdfm12HIl2Ye609ZZTvTg8cl3Mt24bI6Sbl657ph+rDFWmoGxphg8zB0ViRlehmAEQGtex8EcLQRSC5woyA/FBtA9G4bm7D6nb/lgJgPQbjevYxQKlfTaUT7icojVjKSJD8GuZ2rQ1K/HFkjHKkqKIuciXAdj7bfqRjpxLqUplDupSgzMS5msR1lAwbe6FA66mn/fIDUSGeaDKCuH2tOsrS2Xh18xTiA12pndJZzL5nGtEiaqiYOGWZ9A0Wcc3DZNSfosuaD5lKiZYzI7oTr979MfpX8sdBbWh9/WEjBZG96wMAkpzt4wpRq4SbP4dzlhHM/9Au58VoZK2dtVx0x3NFhbXFo1t940CzB3v9FR9aFHUcRGgBYDMDOKCdKmkznKS972TF2xf70kFmoUFbSD+24gqhS1iwKzKc/W12BVWusUnqRIJHfVwx/CkVNFKn+9pPQc3sdKzX1zc7QG/0WbXiszI0YgoOpIDZQPqBaWH9pY3FjbNF5zWFXCdhzTTGUyPucDPZq3pKSYouWWSRYSyLLQDKZdZ14mKPBodF+EvmREI3nm2S3ps3snt7gX0Xo3E3fCRIChIsDgdL2DdVo+goj9AGhMF4+my3RdGBmIUiXx683ei17uQ+vpjTpg9o7c= x-ms-office365-filtering-correlation-id: 85aebbc4-6030-4d1c-ca14-08d4d82ce985 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DB6PR08MB2661; x-ms-traffictypediagnostic: DB6PR08MB2661: 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)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR08MB2661; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR08MB2661; x-forefront-prvs: 03853D523D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39410400002)(39450400003)(39860400002)(39850400002)(39840400002)(54534003)(199003)(189002)(377424004)(74316002)(3660700001)(14454004)(66066001)(478600001)(5660300001)(305945005)(7696004)(6436002)(6636002)(99286003)(55016002)(72206003)(33656002)(3280700002)(9686003)(53936002)(7736002)(230783001)(106356001)(81156014)(38730400002)(25786009)(81166006)(8676002)(97736004)(5250100002)(50986999)(2900100001)(68736007)(54356999)(105586002)(101416001)(189998001)(4326008)(2906002)(6116002)(102836003)(3846002)(86362001)(575784001)(8936002)(6506006); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR08MB2661; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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: 31 Jul 2017 15:57:57.1290 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2661 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 */