On 10/12/2021 16:36, Andrea Corallo via Gcc-patches wrote:
Richard Earnshaw via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
On 28/10/2021 12:43, Tejas Belagod via Gcc-patches wrote:
-----Original Message-----
From: Gcc-patches <gcc-patches-
bounces+belagod=gcc.gnu....@gcc.gnu.org> On Behalf Of Tejas Belagod via
Gcc-patches
Sent: Friday, October 8, 2021 1:19 PM
To: gcc-patches@gcc.gnu.org
Subject: [Patch 6/7, Arm, GCC] Emit build attributes for PACBTI target
feature.
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 <tbela...@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.
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
2021-10-25 Tejas Belagod <tbela...@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.
I'm not sure what the value of making these executable tests is. It
means that they can only be used when the test model has PAC/BTI
available. But they don't really test the PAC/BTI generation, so that
seems rather pointless.
Better, IMO to make them simple compile/scan-assembler tests that
check the build attributes are correct.
R.
Hi Richard,
agreed. Please find attached the updated version of the patch.
Thanks for reviewing
Andrea
Sorry, I've just been looking at this again and noted the following:
+ 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, bti);
+ arm_emit_eabi_attribute ("TAG_PACRET_use", 76, pac);
+ }
+ else
+ {
+ if (pac || bti)
+ {
+ 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, bti);
+ arm_emit_eabi_attribute ("TAG_PACRET_use", 76, pac);
+ }
+ }
+
Firstly, the if subclause inside the else can be lifted out to an 'else
if'; secondly, we don't want to emit TAG_BTI_use or TAG_PACRET_use if
the value is zero (since the default in the absence of the tag is zero).
So better to have this as:
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);
}
if (bti)
arm_emit_eabi_attribute ("TAG_BTI_use", 74, 1);
if (pac)
arm_emit_eabi_attribute ("TAG_PACRET_use", 76, 1);
And then adjust the tests for the zero case to use scan-assembler-not.
R.