https://gcc.gnu.org/g:71c9b1d162595b76691fecb4a46f5083e62fa085
commit r17-1616-g71c9b1d162595b76691fecb4a46f5083e62fa085 Author: Muhammad Kamran <[email protected]> Date: Wed Jun 17 13:23:50 2026 +0000 libatomic: Mark AArch64 asm features with build attributes Use AArch64 build attributes to record BTI, PAC and GCS feature bits when __ARM_BUILDATTR64_FV is available. Fall back to the existing GNU property note emission otherwise. libatomic/ChangeLog: * config/linux/aarch64/atomic_16.S (FEATURE_1_AND_MARK): Define. Use AArch64 build attributes when __ARM_BUILDATTR64_FV is available, otherwise emit a GNU property note. Diff: --- libatomic/config/linux/aarch64/atomic_16.S | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/libatomic/config/linux/aarch64/atomic_16.S b/libatomic/config/linux/aarch64/atomic_16.S index a58255345dff..6d398ffc4b36 100644 --- a/libatomic/config/linux/aarch64/atomic_16.S +++ b/libatomic/config/linux/aarch64/atomic_16.S @@ -796,7 +796,6 @@ END_FEAT (compare_exchange_16, LSE) # define GCS_FLAG 0 #endif -/* Add a NT_GNU_PROPERTY_TYPE_0 note. */ #define GNU_PROPERTY(type, value) \ .section .note.gnu.property, "a"; \ .p2align 3; \ @@ -809,11 +808,35 @@ END_FEAT (compare_exchange_16, LSE) .word value; \ .word 0; +#ifdef __ARM_BUILDATTR64_FV +/* Add AArch64 feature bits build attributes. */ +# define FEATURE_1_AND_MARK(value) \ + .aeabi_subsection aeabi_feature_and_bits, optional, ULEB128; \ + .if ((value) & FEATURE_1_BTI); \ + .aeabi_attribute Tag_Feature_BTI, 1; \ + .else; \ + .aeabi_attribute Tag_Feature_BTI, 0; \ + .endif; \ + .if ((value) & FEATURE_1_PAC); \ + .aeabi_attribute Tag_Feature_PAC, 1; \ + .else; \ + .aeabi_attribute Tag_Feature_PAC, 0; \ + .endif; \ + .if ((value) & FEATURE_1_GCS); \ + .aeabi_attribute Tag_Feature_GCS, 1; \ + .else; \ + .aeabi_attribute Tag_Feature_GCS, 0; \ + .endif; +#else +/* Add a NT_GNU_PROPERTY_TYPE_0 note. */ +# define FEATURE_1_AND_MARK(value) GNU_PROPERTY (FEATURE_1_AND, value) +#endif + #if defined(__linux__) || defined(__FreeBSD__) .section .note.GNU-stack, "", %progbits -/* Add GNU property note if built with branch protection. */ +/* Add markings if built with branch protection. */ # if (BTI_FLAG|PAC_FLAG|GCS_FLAG) != 0 -GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG|GCS_FLAG) +FEATURE_1_AND_MARK (BTI_FLAG|PAC_FLAG|GCS_FLAG) # endif #endif
