From patchwork Thu Dec 5 10:59:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 1204579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515211-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=foss.arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hFYdTk1T"; 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 47TCQx3jNKz9sPJ for ; Thu, 5 Dec 2019 21:59:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Y9FIQyaiIRjqd8591yCTbfFlgqJV/Kx64TWk2SqMi3V8qkryy1 B12/ljbYBkphLNS2hG1ZPNsA8TpSK4NXzsALfyhMC+OrXT0DGxjSkE01Syso/vhK gwZ0UjrytmtyaXzPVH6cxGS2GOrgoAZLEtKWm6t43CpRyXvqf/zu9I4cQ= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=07WrMZlfltYt2hif+6EymDvgPi0=; b=hFYdTk1TNOGJ7d/iYqf8 jjUVyvy6yo6ohgmAq9q64FDfy9xR1nytCZfxK9/Lbb2DcYQ31cvFgxc367x9VYw5 mE6/bHPZSNxXN+CeTeT0DcZ5UgRxmjVWTIWMu5UpFBAlKYPIQxkxmjDFQrPNqPxO 1YHgDDO16D5d/Mi0txCHrgg= Received: (qmail 42039 invoked by alias); 5 Dec 2019 10:59:27 -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 42031 invoked by uid 89); 5 Dec 2019 10:59:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, KAM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Dec 2019 10:59:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 69CD631B for ; Thu, 5 Dec 2019 02:59:24 -0800 (PST) Received: from [10.2.80.62] (e120808-lin.cambridge.arm.com [10.2.80.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2EC6A3F52E for ; Thu, 5 Dec 2019 02:59:24 -0800 (PST) To: "gcc-patches@gcc.gnu.org" From: Kyrill Tkachov Subject: [PATCH][gas] Implement .cfi_negate_ra_state directive Message-ID: <5bd99166-a553-30d2-70c8-95ac3d62231e@foss.arm.com> Date: Thu, 5 Dec 2019 10:59:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 Hi all, This patch implements the .cfi_negate_ra_state to be consistent with LLVM (https://reviews.llvm.org/D50136). The relevant DWARF code DW_CFA_AARCH64_negate_ra_state is multiplexed on top of DW_CFA_GNU_window_save, as per https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00753.html I believe this is the simplest patch implementing this and is needed to allow users to build, for example, the Linux kernel with Armv8.3-A pointer authentication support with Clang while using gas as the assembler, which is a common usecase. Tested gas aarch64-none-elf. Ok for master and the release branches? Thanks, Kyrill gas/ 2019-12-05  Kyrylo Tkachov      * dw2gencfi.c (cfi_pseudo_table): Add cfi_negate_ra_state.     * testsuite/gas/aarch64/pac_negate_ra_state.s: New file.     * testsuite/gas/aarch64/pac_negate_ra_state.d: Likewise. diff --git a/gas/dw2gencfi.c b/gas/dw2gencfi.c index 6c0478a72063801f1f91441a11350daa94605843..707830cbe82f860d21c3b9b8f7cbe1999568398b 100644 --- a/gas/dw2gencfi.c +++ b/gas/dw2gencfi.c @@ -726,6 +726,7 @@ const pseudo_typeS cfi_pseudo_table[] = { "cfi_remember_state", dot_cfi, DW_CFA_remember_state }, { "cfi_restore_state", dot_cfi, DW_CFA_restore_state }, { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save }, + { "cfi_negate_ra_state", dot_cfi, DW_CFA_AARCH64_negate_ra_state }, { "cfi_escape", dot_cfi_escape, 0 }, { "cfi_signal_frame", dot_cfi, CFI_signal_frame }, { "cfi_personality", dot_cfi_personality, 0 }, diff --git a/gas/testsuite/gas/aarch64/pac_negate_ra_state.d b/gas/testsuite/gas/aarch64/pac_negate_ra_state.d new file mode 100644 index 0000000000000000000000000000000000000000..7ab0f2369dece1a71fc064ae38f6e273128bf074 --- /dev/null +++ b/gas/testsuite/gas/aarch64/pac_negate_ra_state.d @@ -0,0 +1,26 @@ +#objdump: --dwarf=frames + +.+: file .+ + +Contents of the .eh_frame section: + +00000000 0000000000000010 00000000 CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: 4 + Data alignment factor: -8 + Return address column: 30 + Augmentation data: 1b + DW_CFA_def_cfa: r31 \(sp\) ofs 0 + +00000014 0000000000000018 00000018 FDE cie=00000000 pc=0000000000000000..0000000000000008 + DW_CFA_advance_loc: 4 to 0000000000000004 + DW_CFA_GNU_window_save + DW_CFA_advance_loc: 4 to 0000000000000008 + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r29 \(x29\) at cfa-16 + DW_CFA_offset: r30 \(x30\) at cfa-8 + DW_CFA_nop + DW_CFA_nop + + diff --git a/gas/testsuite/gas/aarch64/pac_negate_ra_state.s b/gas/testsuite/gas/aarch64/pac_negate_ra_state.s new file mode 100644 index 0000000000000000000000000000000000000000..36ddbeb43b7002a68eb6787a21599eb20d2b965e --- /dev/null +++ b/gas/testsuite/gas/aarch64/pac_negate_ra_state.s @@ -0,0 +1,20 @@ + .arch armv8-a + .text + .align 2 + .global _Z5foo_av + .type _Z5foo_av, %function +_Z5foo_av: +.LFB0: + .cfi_startproc + hint 25 // paciasp + .cfi_negate_ra_state + stp x29, x30, [sp, -16]! + .cfi_def_cfa_offset 16 + .cfi_offset 29, -16 + .cfi_offset 30, -8 + .cfi_endproc +.LFE0: + .size _Z5foo_av, .-_Z5foo_av + .align 2 + .global _Z5foo_bv + .type _Z5foo_bv, %function