[6/7,Arm] Emit build attributes for PACBTI target feature.
Commit Message
Hi,
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)
Tested on arm-none-eabi.
2021-10-04 Tejas Belagod <tbelagod@arm.com>
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: New test.
* gcc.target/arm/acle/pacbti-m-predef-6.c: New test.
@@ -28305,6 +28305,27 @@ 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);
+ arm_emit_eabi_attribute ("TAG_BTI_use", 74, arm_enable_pacbti & 0x1);
+ arm_emit_eabi_attribute ("TAG_PACRET_use", 76,
+ (arm_enable_pacbti >> 1 != 0));
+ }
+ else
+ {
+ if (arm_enable_pacbti != 0)
+ {
+ arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 1);
+ arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 1);
+ arm_emit_eabi_attribute ("TAG_BTI_use", 74,
+ arm_enable_pacbti & 0x1);
+ arm_emit_eabi_attribute ("TAG_PACRET_use", 76,
+ (arm_enable_pacbti >> 1 != 0));
+ }
+ }
+
if (arm_lang_output_object_attributes_hook)
arm_lang_output_object_attributes_hook();
}
new file mode 100644
@@ -0,0 +1,22 @@
+
+/* { dg-do run } */
+/* { dg-require-effective-target arm_pacbti_hw } */
+/* { dg-additional-options " -mbranch-protection=pac-ret+bti --save-temps" } */
+
+/* { 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 "\.eabi_attribute 74, 1" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */
+
+int
+main()
+{
+ if (__ARM_FEATURE_BTI_DEFAULT != 1)
+ __builtin_abort ();
+
+ if (__ARM_FEATURE_PAC_DEFAULT != 1)
+ __builtin_abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,21 @@
+
+/* { dg-do run } */
+/* { dg-require-effective-target arm_pacbti_hw } */
+/* { dg-additional-options " -mbranch-protection=pac-ret+b-key+leaf --save-temps" } */
+
+/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 74, 0" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */
+
+int
+main()
+{
+ if (__ARM_FEATURE_BTI_DEFAULT != 0)
+ __builtin_abort ();
+
+ if (__ARM_FEATURE_PAC_DEFAULT != 6)
+ __builtin_abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,21 @@
+
+/* { dg-do run } */
+/* { dg-require-effective-target arm_pacbti_hw } */
+/* { dg-additional-options " -mbranch-protection=bti --save-temps" } */
+
+/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */
+/* { dg-final { scan-assembler "\.eabi_attribute 76, 0" } } */
+
+int
+main()
+{
+ if (__ARM_FEATURE_BTI_DEFAULT != 1)
+ __builtin_abort ();
+
+ if (__ARM_FEATURE_PAC_DEFAULT != 0)
+ __builtin_abort ();
+
+ return 0;
+}