On 20/10/2022 15:47, Kyrylo Tkachov via Gcc-patches wrote:
Hi Andrea,
-----Original Message-----
From: Gcc-patches <gcc-patches-
bounces+kyrylo.tkachov=arm....@gcc.gnu.org> On Behalf Of Andrea
Corallo via Gcc-patches
Sent: Friday, August 12, 2022 4:31 PM
To: Andrea Corallo via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Richard Earnshaw <richard.earns...@arm.com>; nd <n...@arm.com>
Subject: [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.
<https://github.com/ARM-software/abi-
aa/releases/download/2021Q1/addenda32.pdf>
gcc/ChangeLog:
* config/arm/arm.c (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: 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 <tbela...@arm.com>
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 0068817b0f2..ceec14f84b6 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -28349,6 +28349,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));
@@ -28419,6 +28421,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);
+ }
This hunk will set both Tag_PAC_extension and Tag_BTI_extension if only one of
pac or bti is on. Is that intended?
Would it makes sense to instead set the two Tag_*_extension tags individually
as in the hunk below?
That's because they are one feature in armv8-m and these tags describe
the presence of the feature in the architecture.
+
+ if (bti)
+ arm_emit_eabi_attribute ("TAG_BTI_use", 74, 1);
+ if (pac)
+ arm_emit_eabi_attribute ("TAG_PACRET_use", 76, 1);
+
But this describes /use/ by the code of each feature.
R.
if (arm_lang_output_object_attributes_hook)
arm_lang_output_object_attributes_hook();
}
Thanks,
Kyrill