@@ -235,9 +235,9 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE)
{
int v = 0;
- if (aarch_ra_sign_key == AARCH_KEY_A)
+ if (aarch64_ra_sign_key == AARCH64_KEY_A)
v |= 1;
- if (aarch_ra_sign_key == AARCH_KEY_B)
+ if (aarch64_ra_sign_key == AARCH64_KEY_B)
v |= 2;
if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL)
v |= 4;
@@ -9461,12 +9461,12 @@ aarch64_expand_prologue (void)
/* Sign return address for functions. */
if (aarch64_return_address_signing_enabled ())
{
- switch (aarch_ra_sign_key)
+ switch (aarch64_ra_sign_key)
{
- case AARCH_KEY_A:
+ case AARCH64_KEY_A:
insn = emit_insn (gen_paciasp ());
break;
- case AARCH_KEY_B:
+ case AARCH64_KEY_B:
insn = emit_insn (gen_pacibsp ());
break;
default:
@@ -9880,12 +9880,12 @@ aarch64_expand_epilogue (rtx_call_insn *sibcall)
if (aarch64_return_address_signing_enabled ()
&& (sibcall || !TARGET_ARMV8_3))
{
- switch (aarch_ra_sign_key)
+ switch (aarch64_ra_sign_key)
{
- case AARCH_KEY_A:
+ case AARCH64_KEY_A:
insn = emit_insn (gen_autiasp ());
break;
- case AARCH_KEY_B:
+ case AARCH64_KEY_B:
insn = emit_insn (gen_autibsp ());
break;
default:
@@ -18541,6 +18541,61 @@ aarch64_set_asm_isa_flags (aarch64_feature_flags flags)
aarch64_set_asm_isa_flags (&global_options, flags);
}
+static void
+aarch64_handle_no_branch_protection (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_NONE;
+ aarch_enable_bti = 0;
+}
+
+static void
+aarch64_handle_standard_branch_protection (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF;
+ aarch64_ra_sign_key = AARCH64_KEY_A;
+ aarch_enable_bti = 1;
+}
+
+static void
+aarch64_handle_pac_ret_protection (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF;
+ aarch64_ra_sign_key = AARCH64_KEY_A;
+}
+
+static void
+aarch64_handle_pac_ret_leaf (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_ALL;
+}
+
+static void
+aarch64_handle_pac_ret_b_key (void)
+{
+ aarch64_ra_sign_key = AARCH64_KEY_B;
+}
+
+static void
+aarch64_handle_bti_protection (void)
+{
+ aarch_enable_bti = 1;
+}
+
+static const struct aarch_branch_protect_type aarch64_pac_ret_subtypes[] = {
+ { "leaf", false, aarch64_handle_pac_ret_leaf, NULL, 0 },
+ { "b-key", false, aarch64_handle_pac_ret_b_key, NULL, 0 },
+ { NULL, false, NULL, NULL, 0 }
+};
+
+const struct aarch_branch_protect_type aarch_branch_protect_types[] = {
+ { "none", true, aarch64_handle_no_branch_protection, NULL, 0 },
+ { "standard", true, aarch64_handle_standard_branch_protection, NULL, 0 },
+ { "pac-ret", false, aarch64_handle_pac_ret_protection,
+ aarch64_pac_ret_subtypes, ARRAY_SIZE (aarch64_pac_ret_subtypes) },
+ { "bti", false, aarch64_handle_bti_protection, NULL, 0 },
+ { NULL, false, NULL, NULL, 0 }
+};
+
/* Implement TARGET_OPTION_OVERRIDE. This is called once in the beginning
and is used to parse the -m{cpu,tune,arch} strings and setup the initial
tuning structs. In particular it must set selected_tune and
@@ -23380,7 +23435,7 @@ void
aarch64_post_cfi_startproc (FILE *f, tree ignored ATTRIBUTE_UNUSED)
{
if (cfun->machine->frame.laid_out && aarch64_return_address_signing_enabled ()
- && aarch_ra_sign_key == AARCH_KEY_B)
+ && aarch64_ra_sign_key == AARCH64_KEY_B)
asm_fprintf (f, "\t.cfi_b_key_frame\n");
}
@@ -1002,7 +1002,7 @@ (define_insn "*do_return"
if (aarch64_return_address_signing_enabled ()
&& (TARGET_PAUTH))
{
- if (aarch_ra_sign_key == AARCH_KEY_B)
+ if (aarch64_ra_sign_key == AARCH64_KEY_B)
ret = "retab";
else
ret = "retaa";
@@ -40,7 +40,7 @@ TargetVariable
unsigned aarch_enable_bti = 2
TargetVariable
-enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A
+enum aarch64_key_type aarch64_ra_sign_key = AARCH64_KEY_A
; The TLS dialect names to use with -mtls-dialect.
@@ -660,61 +660,6 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
return saw_asm_flag ? seq : NULL;
}
-static void
-aarch_handle_no_branch_protection (void)
-{
- aarch_ra_sign_scope = AARCH_FUNCTION_NONE;
- aarch_enable_bti = 0;
-}
-
-static void
-aarch_handle_standard_branch_protection (void)
-{
- aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF;
- aarch_ra_sign_key = AARCH_KEY_A;
- aarch_enable_bti = 1;
-}
-
-static void
-aarch_handle_pac_ret_protection (void)
-{
- aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF;
- aarch_ra_sign_key = AARCH_KEY_A;
-}
-
-static void
-aarch_handle_pac_ret_leaf (void)
-{
- aarch_ra_sign_scope = AARCH_FUNCTION_ALL;
-}
-
-static void
-aarch_handle_pac_ret_b_key (void)
-{
- aarch_ra_sign_key = AARCH_KEY_B;
-}
-
-static void
-aarch_handle_bti_protection (void)
-{
- aarch_enable_bti = 1;
-}
-
-static const struct aarch_branch_protect_type aarch_pac_ret_subtypes[] = {
- { "leaf", false, aarch_handle_pac_ret_leaf, NULL, 0 },
- { "b-key", false, aarch_handle_pac_ret_b_key, NULL, 0 },
- { NULL, false, NULL, NULL, 0 }
-};
-
-static const struct aarch_branch_protect_type aarch_branch_protect_types[] = {
- { "none", true, aarch_handle_no_branch_protection, NULL, 0 },
- { "standard", true, aarch_handle_standard_branch_protection, NULL, 0 },
- { "pac-ret", false, aarch_handle_pac_ret_protection, aarch_pac_ret_subtypes,
- ARRAY_SIZE (aarch_pac_ret_subtypes) },
- { "bti", false, aarch_handle_bti_protection, NULL, 0 },
- { NULL, false, NULL, NULL, 0 }
-};
-
/* In-place split *str at delim, return *str and set *str to the tail
of the string or NULL if the end is reached. */
@@ -44,12 +44,7 @@ enum aarch_function_type {
AARCH_FUNCTION_ALL
};
-/* The key type that -msign-return-address should use. */
-enum aarch_key_type {
- AARCH_KEY_A,
- AARCH_KEY_B
-};
-
+/* Specifies a -mbranch-protection= argument. */
struct aarch_branch_protect_type
{
/* The type's name that the user passes to the branch-protection option
@@ -64,4 +59,8 @@ struct aarch_branch_protect_type
unsigned int num_subtypes;
};
+/* Target specific data and callbacks for parsing -mbranch-protection=.
+ The first item is used to reset the branch-protection settings. */
+extern const struct aarch_branch_protect_type aarch_branch_protect_types[];
+
#endif /* GCC_AARCH_COMMON_H */
@@ -248,8 +248,6 @@ arm_cpu_builtins (struct cpp_reader* pfile)
{
unsigned int pac = 1;
- gcc_assert (aarch_ra_sign_key == AARCH_KEY_A);
-
if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL)
pac |= 0x4;
@@ -3259,6 +3259,52 @@ static sbitmap isa_all_fpubits_internal;
static sbitmap isa_all_fpbits;
static sbitmap isa_quirkbits;
+static void
+arm_handle_no_branch_protection (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_NONE;
+ aarch_enable_bti = 0;
+}
+
+static void
+arm_handle_standard_branch_protection (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF;
+ aarch_enable_bti = 1;
+}
+
+static void
+arm_handle_pac_ret_protection (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF;
+}
+
+static void
+arm_handle_pac_ret_leaf (void)
+{
+ aarch_ra_sign_scope = AARCH_FUNCTION_ALL;
+}
+
+static void
+arm_handle_bti_protection (void)
+{
+ aarch_enable_bti = 1;
+}
+
+static const struct aarch_branch_protect_type arm_pac_ret_subtypes[] = {
+ { "leaf", false, arm_handle_pac_ret_leaf, NULL, 0 },
+ { NULL, false, NULL, NULL, 0 }
+};
+
+const struct aarch_branch_protect_type aarch_branch_protect_types[] = {
+ { "none", true, arm_handle_no_branch_protection, NULL, 0 },
+ { "standard", true, arm_handle_standard_branch_protection, NULL, 0 },
+ { "pac-ret", false, arm_handle_pac_ret_protection, arm_pac_ret_subtypes,
+ ARRAY_SIZE (arm_pac_ret_subtypes) },
+ { "bti", false, arm_handle_bti_protection, NULL, 0 },
+ { NULL, false, NULL, NULL, 0 }
+};
+
/* Configure a build target TARGET from the user-specified options OPTS and
OPTS_SET. If WARN_COMPATIBLE, emit a diagnostic if both the CPU and
architecture have been specified, but the two are not identical. */
@@ -3308,12 +3354,6 @@ arm_configure_build_target (struct arm_build_target *target,
{
aarch_validate_mbranch_protection (opts->x_arm_branch_protection_string,
"-mbranch-protection=");
-
- if (aarch_ra_sign_key != AARCH_KEY_A)
- {
- warning (0, "invalid key type for %<-mbranch-protection=%>");
- aarch_ra_sign_key = AARCH_KEY_A;
- }
}
if (arm_selected_arch)
@@ -30,9 +30,6 @@ enum aarch_function_type aarch_ra_sign_scope = AARCH_FUNCTION_NONE
TargetVariable
unsigned aarch_enable_bti = 0
-TargetVariable
-enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A
-
Enum
Name(tls_type) Type(enum arm_tls_type)
TLS dialect to use: