From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2092) id 96C2F3858C50; Mon, 23 Jan 2023 10:46:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 96C2F3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674470816; bh=oshLZXT4GleDMT23Om4eLEPn6zBDVxlNgoIwskliQNA=; h=From:To:Subject:Date:From; b=U+MjYay6D4BraYN1euKnbAGoz/ZfQrnUra5nRZKDE5nVU0W6Novm/ObgkpGKia7Vw 7FGbdcNXjc/oj5NHVIx6oDeaX4s6ei6btbX0/dsxG4/ZTzw4EmdE226VYiSKAlvez2 NG91i6Y1J4Nnr0cJUIgTULaTzqpYLHFmRTRILxbY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrea Corallo To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5295] [PATCH 7/15] arm: Emit build attributes for PACBTI target feature X-Act-Checkin: gcc X-Git-Author: Andrea Corallo X-Git-Refname: refs/heads/master X-Git-Oldrev: 7161afc778699b90edafbcd750b2e185a1de00a6 X-Git-Newrev: 616c1d02bcea9ff24ff2873c6d2efc84c7be4192 Message-Id: <20230123104656.96C2F3858C50@sourceware.org> Date: Mon, 23 Jan 2023 10:46:56 +0000 (GMT) List-Id: https://gcc.gnu.org/g:616c1d02bcea9ff24ff2873c6d2efc84c7be4192 commit r13-5295-g616c1d02bcea9ff24ff2873c6d2efc84c7be4192 Author: Andrea Corallo Date: Mon Dec 6 11:42:24 2021 +0100 [PATCH 7/15] arm: Emit build attributes for PACBTI target feature This patch emits assembler directives for PACBTI build attributes as defined by the ABI. gcc/ChangeLog: * config/arm/arm.cc (arm_file_start): Emit EABI attributes for Tag_PAC_extension, Tag_BTI_extension, TAG_BTI_use, TAG_PACRET_use. gcc/testsuite/ChangeLog: * gcc.target/arm/acle/pacbti-m-predef-1.c: New test. * gcc.target/arm/acle/pacbti-m-predef-3.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-6.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-7.c: Likewise. Co-Authored-By: Tejas Belagod Diff: --- gcc/config/arm/arm.cc | 18 ++++++++++++++++++ gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c | 17 +++++++++++++++++ gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c | 17 +++++++++++++++++ gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c | 16 ++++++++++++++++ gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c | 17 +++++++++++++++++ 5 files changed, 85 insertions(+) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 76c6f94d6d6..358b813cb32 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -28478,6 +28478,8 @@ static void arm_file_start (void) { int val; + bool pac = (aarch_ra_sign_scope != AARCH_FUNCTION_NONE); + bool bti = (aarch_enable_bti == 1); arm_print_asm_arch_directives (asm_out_file, TREE_TARGET_OPTION (target_option_default_node)); @@ -28548,6 +28550,22 @@ arm_file_start (void) arm_emit_eabi_attribute ("Tag_ABI_FP_16bit_format", 38, (int) arm_fp16_format); + if (TARGET_HAVE_PACBTI) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 2); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 2); + } + else if (pac || bti) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 1); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 1); + } + + if (bti) + arm_emit_eabi_attribute ("TAG_BTI_use", 74, 1); + if (pac) + arm_emit_eabi_attribute ("TAG_PACRET_use", 76, 1); + if (arm_lang_output_object_attributes_hook) arm_lang_output_object_attributes_hook(); } diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c new file mode 100644 index 00000000000..122f7a762a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret+bti -mfloat-abi=hard --save-temps" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +/* { dg-final { scan-assembler-not "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c new file mode 100644 index 00000000000..b94f3447ad9 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret+leaf -mfloat-abi=hard --save-temps" } */ + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +/* { dg-final { scan-assembler-not "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 1" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 74" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c new file mode 100644 index 00000000000..ed52afc83c5 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=bti -mfloat-abi=hard --save-temps" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be undefined." +#endif +/* { dg-final { scan-assembler-not "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 76" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c new file mode 100644 index 00000000000..1b25907635e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-additional-options "-march=armv8.1-m.main+pacbti+fp --save-temps -mfloat-abi=hard" } */ + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +#if defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be undefined." +#endif + +/* { dg-final { scan-assembler "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 74" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 76" } } */