aarch64: Fix return_address_sign_ab_exception.C regression
Checks
Commit Message
Hi all,
this is to fix the regression of
g++.target/aarch64/return_address_sign_ab_exception.C that I
introduced with d8dadbc9a5199bf7bac1ab7376b0f84f45e94350.
'aarch_ra_sign_key' for aarch64 ended up being non defined in the opt
file and the function attribute "branch-protection=pac-ret+leaf+b-key"
stopped working as expected.
This patch moves the definition of 'aarch_ra_sign_key' to the opt
files for both Arm back-ends.
Regards
Andera Corallo
gcc/ChangeLog:
* config/aarch64/aarch64-protos.h (aarch_ra_sign_key): Remove
declaration.
* config/aarch64/aarch64.cc (aarch_ra_sign_key): Remove
definition.
* config/aarch64/aarch64.opt (aarch64_ra_sign_key): Rename
to 'aarch_ra_sign_key'.
* config/arm/aarch-common.cc (aarch_ra_sign_key): Remove
declaration.
* config/arm/arm-protos.h (aarch_ra_sign_key): Likewise.
* config/arm/arm.cc (enum aarch_key_type): Remove definition.
* config/arm/arm.opt: Define.
---
gcc/config/aarch64/aarch64-protos.h | 2 --
gcc/config/aarch64/aarch64.cc | 2 --
gcc/config/aarch64/aarch64.opt | 2 +-
gcc/config/arm/aarch-common.cc | 1 -
gcc/config/arm/arm-protos.h | 1 -
gcc/config/arm/arm.cc | 3 ---
gcc/config/arm/arm.opt | 3 +++
7 files changed, 4 insertions(+), 10 deletions(-)
Comments
Andrea Corallo via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> Hi all,
>
> this is to fix the regression of
> g++.target/aarch64/return_address_sign_ab_exception.C that I
> introduced with d8dadbc9a5199bf7bac1ab7376b0f84f45e94350.
>
> 'aarch_ra_sign_key' for aarch64 ended up being non defined in the opt
> file and the function attribute "branch-protection=pac-ret+leaf+b-key"
> stopped working as expected.
>
> This patch moves the definition of 'aarch_ra_sign_key' to the opt
> files for both Arm back-ends.
>
> Regards
>
> Andera Corallo
>
> gcc/ChangeLog:
>
> * config/aarch64/aarch64-protos.h (aarch_ra_sign_key): Remove
> declaration.
> * config/aarch64/aarch64.cc (aarch_ra_sign_key): Remove
> definition.
> * config/aarch64/aarch64.opt (aarch64_ra_sign_key): Rename
> to 'aarch_ra_sign_key'.
> * config/arm/aarch-common.cc (aarch_ra_sign_key): Remove
> declaration.
> * config/arm/arm-protos.h (aarch_ra_sign_key): Likewise.
> * config/arm/arm.cc (enum aarch_key_type): Remove definition.
> * config/arm/arm.opt: Define.
OK, thanks.
Richard
> ---
> gcc/config/aarch64/aarch64-protos.h | 2 --
> gcc/config/aarch64/aarch64.cc | 2 --
> gcc/config/aarch64/aarch64.opt | 2 +-
> gcc/config/arm/aarch-common.cc | 1 -
> gcc/config/arm/arm-protos.h | 1 -
> gcc/config/arm/arm.cc | 3 ---
> gcc/config/arm/arm.opt | 3 +++
> 7 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
> index 6ab6d49af37..f75eb892f3d 100644
> --- a/gcc/config/aarch64/aarch64-protos.h
> +++ b/gcc/config/aarch64/aarch64-protos.h
> @@ -662,8 +662,6 @@ enum simd_immediate_check {
> AARCH64_CHECK_MOV = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC
> };
>
> -extern enum aarch_key_type aarch_ra_sign_key;
> -
> extern struct tune_params aarch64_tune_params;
>
> /* The available SVE predicate patterns, known in the ACLE as "svpattern". */
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index acc0cfe5f94..1b498979af1 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -2759,8 +2759,6 @@ static const struct processor all_cores[] =
> {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, NULL}
> };
>
> -enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A;
> -
> /* The current tuning set. */
> struct tune_params aarch64_tune_params = generic_tunings;
>
> diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
> index 137e506fe19..1d7967db9c0 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -40,7 +40,7 @@ TargetVariable
> unsigned aarch_enable_bti = 2
>
> TargetVariable
> -enum aarch64_key_type aarch64_ra_sign_key = AARCH64_KEY_A
> +enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A
>
> ; The TLS dialect names to use with -mtls-dialect.
>
> diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc
> index 27e6c8f39b4..5b96ff4c2e8 100644
> --- a/gcc/config/arm/aarch-common.cc
> +++ b/gcc/config/arm/aarch-common.cc
> @@ -661,7 +661,6 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
>
> #define BRANCH_PROTECT_STR_MAX 255
> extern char *accepted_branch_protection_string;
> -extern enum aarch_key_type aarch_ra_sign_key;
>
> static enum aarch_parse_opt_result
> aarch_handle_no_branch_protection (char* str, char* rest)
> diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
> index aea472bfbb9..c8ae5e1e9c1 100644
> --- a/gcc/config/arm/arm-protos.h
> +++ b/gcc/config/arm/arm-protos.h
> @@ -585,7 +585,6 @@ struct cpu_option
> extern const arch_option all_architectures[];
> extern const cpu_option all_cores[];
>
> -extern enum aarch_key_type aarch_ra_sign_key;
>
> const cpu_option *arm_parse_cpu_option_name (const cpu_option *, const char *,
> const char *, bool = true);
> diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
> index efc48349dd3..3d778b2982e 100644
> --- a/gcc/config/arm/arm.cc
> +++ b/gcc/config/arm/arm.cc
> @@ -2420,9 +2420,6 @@ const struct tune_params arm_fa726te_tune =
> tune_params::SCHED_AUTOPREF_OFF
> };
>
> -/* Key type for Pointer Authentication extension. */
> -enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A;
> -
> char *accepted_branch_protection_string = NULL;
>
> /* Auto-generated CPU, FPU and architecture tables. */
> diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt
> index 260700f16bc..3a49b51ece0 100644
> --- a/gcc/config/arm/arm.opt
> +++ b/gcc/config/arm/arm.opt
> @@ -30,6 +30,9 @@ 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:
Richard Sandiford <richard.sandiford@arm.com> writes:
> Andrea Corallo via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>> Hi all,
>>
>> this is to fix the regression of
>> g++.target/aarch64/return_address_sign_ab_exception.C that I
>> introduced with d8dadbc9a5199bf7bac1ab7376b0f84f45e94350.
>>
>> 'aarch_ra_sign_key' for aarch64 ended up being non defined in the opt
>> file and the function attribute "branch-protection=pac-ret+leaf+b-key"
>> stopped working as expected.
>>
>> This patch moves the definition of 'aarch_ra_sign_key' to the opt
>> files for both Arm back-ends.
>>
>> Regards
>>
>> Andera Corallo
>>
>> gcc/ChangeLog:
>>
>> * config/aarch64/aarch64-protos.h (aarch_ra_sign_key): Remove
>> declaration.
>> * config/aarch64/aarch64.cc (aarch_ra_sign_key): Remove
>> definition.
>> * config/aarch64/aarch64.opt (aarch64_ra_sign_key): Rename
>> to 'aarch_ra_sign_key'.
>> * config/arm/aarch-common.cc (aarch_ra_sign_key): Remove
>> declaration.
>> * config/arm/arm-protos.h (aarch_ra_sign_key): Likewise.
>> * config/arm/arm.cc (enum aarch_key_type): Remove definition.
>> * config/arm/arm.opt: Define.
>
> OK, thanks.
>
> Richard
Thanks for reviewing, in as b1d26458839.
Best Regards
Andrea
@@ -662,8 +662,6 @@ enum simd_immediate_check {
AARCH64_CHECK_MOV = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC
};
-extern enum aarch_key_type aarch_ra_sign_key;
-
extern struct tune_params aarch64_tune_params;
/* The available SVE predicate patterns, known in the ACLE as "svpattern". */
@@ -2759,8 +2759,6 @@ static const struct processor all_cores[] =
{NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, NULL}
};
-enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A;
-
/* The current tuning set. */
struct tune_params aarch64_tune_params = generic_tunings;
@@ -40,7 +40,7 @@ TargetVariable
unsigned aarch_enable_bti = 2
TargetVariable
-enum aarch64_key_type aarch64_ra_sign_key = AARCH64_KEY_A
+enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A
; The TLS dialect names to use with -mtls-dialect.
@@ -661,7 +661,6 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
#define BRANCH_PROTECT_STR_MAX 255
extern char *accepted_branch_protection_string;
-extern enum aarch_key_type aarch_ra_sign_key;
static enum aarch_parse_opt_result
aarch_handle_no_branch_protection (char* str, char* rest)
@@ -585,7 +585,6 @@ struct cpu_option
extern const arch_option all_architectures[];
extern const cpu_option all_cores[];
-extern enum aarch_key_type aarch_ra_sign_key;
const cpu_option *arm_parse_cpu_option_name (const cpu_option *, const char *,
const char *, bool = true);
@@ -2420,9 +2420,6 @@ const struct tune_params arm_fa726te_tune =
tune_params::SCHED_AUTOPREF_OFF
};
-/* Key type for Pointer Authentication extension. */
-enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A;
-
char *accepted_branch_protection_string = NULL;
/* Auto-generated CPU, FPU and architecture tables. */
@@ -30,6 +30,9 @@ 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: