aarch64: Add missing ACLE support for PAC-RET
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 2 Jul 2020 15:11:04 +0000 (16:11 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Mon, 13 Jul 2020 12:49:21 +0000 (13:49 +0100)
Define the __ARM_FEATURE_PAC_DEFAULT feature test
macro when PAC-RET branch protection is enabled.

2020-07-13  Szabolcs Nagy  <szabolcs.nagy@arm.com>

gcc/ChangeLog:

* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Add
__ARM_FEATURE_PAC_DEFAULT support.

gcc/config/aarch64/aarch64-c.c

index 1882288af8df4c9afae613282a645865b191cb14..1a1f4ecef04e3dd4f030d1d9f534e99592879e92 100644 (file)
@@ -181,6 +181,19 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
   aarch64_def_or_undef (aarch64_bti_enabled (),
                        "__ARM_FEATURE_BTI_DEFAULT", pfile);
 
+  cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT");
+  if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE)
+    {
+      int v = 0;
+      if (aarch64_ra_sign_key == AARCH64_KEY_A)
+       v |= 1;
+      if (aarch64_ra_sign_key == AARCH64_KEY_B)
+       v |= 2;
+      if (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL)
+       v |= 4;
+      builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v);
+    }
+
   aarch64_def_or_undef (TARGET_I8MM, "__ARM_FEATURE_MATMUL_INT8", pfile);
   aarch64_def_or_undef (TARGET_BF16_SIMD,
                        "__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile);