From patchwork Tue Oct 8 15:20:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1173388 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-510476-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="puAMxPQs"; 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 46ngzL3LVSz9sP7 for ; Wed, 9 Oct 2019 02:21:02 +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 :in-reply-to:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=OofZXNXiJY4wxbsVFLWAYQ4diMYco YFE7eekewNDxpoyG/N/UTgaw0zw+WY+kwgY9gUhdEVzGV3/avySFwaS7tkVK40vZ ANVi7AOGBIvzv32nMfWWZHeDTx0bP/52OgPvwm2m+XHZ0Z0Mdgu+LO6o3NakE/o3 1l1Y3pL+wzvqrs= 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 :in-reply-to:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=RGbLmH7a580Yq9Tvxn/LcldKCyY=; b=puA MxPQsbybZlJhW8qFz+rFHuGrGUKeNnCgZpmWLUGj3V5d8pAD1ox6379dKYCyWKVl NmjTny6p6yYvoNGTcFY5D8Lky6BOaG0HKQEZMfV9NvK6KPzS+Xf93Vn8P/fmkkI7 hPay5CE20WhTgrVggVRsIEOOkXjSwvdhT8kD/d7I= Received: (qmail 100240 invoked by alias); 8 Oct 2019 15:20:48 -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 100117 invoked by uid 89); 8 Oct 2019 15:20:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS 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; Tue, 08 Oct 2019 15:20:45 +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 17B7E1570 for ; Tue, 8 Oct 2019 08:20:44 -0700 (PDT) Received: from [10.2.206.37] (e107157-lin.cambridge.arm.com [10.2.206.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D2C093F68E for ; Tue, 8 Oct 2019 08:20:43 -0700 (PDT) In-Reply-To: To: gcc-patches From: "Andre Vieira (lists)" Subject: [Patch 2/2][Arm] Implement TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES to remove cmse_nonsecure_entry Message-ID: <5a9d0431-f483-01bb-01d0-949e9badb765@arm.com> Date: Tue, 8 Oct 2019 16:20:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, This patch implements the TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES for the arm backend to remove the 'cmse_nonsecure_entry' attribute from cmse. Bootstrapped the series on x86_64 and built arm-none-eabi, running the cmse testsuite for armv8-m.main and armv8-m.base. Is this OK for trunk? Cheers, Andre gcc/ChangeLog: 2019-10-08 Andre Vieira * config/arm/arm.c (TARGET_SANITIZE_CLONE_ATTRIBUTES): Define. (arm_sanitize_clone_attributes): New. gcc/testsuite/ChangeLog: 2019-10-08 Andre Vieira * gcc.target/arm/cmse/ipa-clone.c: New test. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 9f0975dc0710626ef46abecaa3a205e993821118..173172bd28303469faded6b7a84a0b353b62de18 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -811,6 +811,9 @@ static const struct attribute_spec arm_attribute_table[] = #undef TARGET_CONSTANT_ALIGNMENT #define TARGET_CONSTANT_ALIGNMENT arm_constant_alignment + +#undef TARGET_SANITIZE_CLONE_ATTRIBUTES +#define TARGET_SANITIZE_CLONE_ATTRIBUTES arm_sanitize_clone_attributes /* Obstack for minipool constant handling. */ static struct obstack minipool_obstack; @@ -31999,6 +32002,15 @@ arm_constant_alignment (const_tree exp, HOST_WIDE_INT align) return align; } +static void +arm_sanitize_clone_attributes (struct cgraph_node * node) +{ + tree attrs = DECL_ATTRIBUTES (node->decl); + if (lookup_attribute ("cmse_nonsecure_entry", attrs)) + attrs = remove_attribute ("cmse_nonsecure_entry", attrs); + DECL_ATTRIBUTES (node->decl) = attrs; +} + /* Emit a speculation barrier on target architectures that do not have DSB/ISB directly. Such systems probably don't need a barrier themselves, but if the code is ever run on a later architecture, it diff --git a/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c b/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c new file mode 100644 index 0000000000000000000000000000000000000000..6ab4c34f7499f9615b5d44c633bb5f9d69e88d39 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-mcmse" } */ +/* { dg-additional-options "-Ofast" } */ + +#include + +int __attribute__ ((cmse_nonsecure_entry)) +foo (int a) +{ + return 1; +} + +int __attribute__ ((cmse_nonsecure_entry)) +bar (int a) +{ + return 1; +} + +int main (void) +{ + return 0; +} + +/* { dg-final { scan-assembler "foo.constprop.0:" } } */ +/* { dg-final { scan-assembler-not "__acle_se_foo.constprop.0:" } } */ +/* { dg-final { scan-assembler "foo:" } } */ +/* { dg-final { scan-assembler "__acle_se_foo:" } } */ +