[PATCH v2 1/1] aarch64: Use build attributes for asm feature marking
Muhammad Kamran
muhammad.kamran@arm.com
Thu May 28 09:32:56 GMT 2026
On 27/05/2026 18:19, Adhemerval Zanella Netto wrote:
>
>
> On 18/05/26 07:47, Muhammad Kamran wrote:
>> When the compiler defines __ARM_BUILDATTR64_FV, emit AArch64
>> feature-and-bits build attributes for BTI, PAC, and GCS from sysdep.h
>> instead of a GNU property note. Keep the GNU property note as the
>> fallback for older toolchains.
>>
>> Mirror the same marking logic in elf/tst-asm-helper.h so custom test
>> DSOs and assembly tests that cannot include sysdep.h get consistent
>> feature marking.
>> ---
>> elf/tst-asm-helper.h | 61 +++++++++++++++++++++++++++-------------
>> sysdeps/aarch64/sysdep.h | 56 +++++++++++++++++++++++++-----------
>> 2 files changed, 82 insertions(+), 35 deletions(-)
>>
>> diff --git a/elf/tst-asm-helper.h b/elf/tst-asm-helper.h
>> index 51d079b94e..b4be9a37df 100644
>> --- a/elf/tst-asm-helper.h
>> +++ b/elf/tst-asm-helper.h
>> @@ -1,6 +1,5 @@
>> -/* Test header that defines macros for GNU properties that need to be
>> - used in some test assembly files where sysdep.h cannot be included
>> - for some reason.
>> +/* Test header that defines feature-marking macros used in some test
>> + assembly files where sysdep.h cannot be included for some reason.
>> Copyright (C) 2024-2026 Free Software Foundation, Inc.
>> This file is part of the GNU C Library.
>>
>> @@ -27,21 +26,45 @@
>> #define FEATURE_1_PAC 2
>> #define FEATURE_1_GCS 4
>>
>> +#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_GCS); \
>> + .aeabi_attribute Tag_Feature_GCS, 1; \
>> + .else; \
>> + .aeabi_attribute Tag_Feature_GCS, 0; \
>> + .endif; \
>> + .if ((value) & FEATURE_1_PAC); \
>> + .aeabi_attribute Tag_Feature_PAC, 1; \
>> + .else; \
>> + .aeabi_attribute Tag_Feature_PAC, 0; \
>> + .endif; \
>> + .text
>> +#else
>> /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
>> -#define GNU_PROPERTY(type, value) \
>> - .section .note.gnu.property, "a"; \
>> - .p2align 3; \
>> - .word 4; \
>> - .word 16; \
>> - .word 5; \
>> - .asciz "GNU"; \
>> - .word type; \
>> - .word 4; \
>> - .word value; \
>> - .word 0; \
>> - .text
>> -
>
> Please keep the same indentation for the internal fields, it helps to the git
> history since the idea of this patch is to add the .aeabi_attribute support.
>
> The patch itself looks ok to me.
>
Thanks for the review. I have posted v3 with the requested change: the
existing GNU_PROPERTY macro indentation is now kept unchanged, so the
diff is focused on adding the .aeabi_attribute support.
Thanks,
Kamran
>> -/* Add GNU property note with the supported features to all asm code
>> - where sysdep.h is included. */
>> -GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC|FEATURE_1_GCS)
>> +# define GNU_PROPERTY(type, value) \
>> + .section .note.gnu.property, "a"; \
>> + .p2align 3; \
>> + .word 4; \
>> + .word 16; \
>> + .word 5; \
>> + .asciz "GNU"; \
>> + .word type; \
>> + .word 4; \
>> + .word value; \
>> + .word 0; \
>> + .text
>> +
>> +# define FEATURE_1_AND_MARK(value) GNU_PROPERTY (FEATURE_1_AND, value)
>> +#endif /* __ARM_BUILDATTR64_FV */
>> +
>> +/* Add marking with the supported features to all asm code where this header
>> + is included. */
>> +FEATURE_1_AND_MARK (FEATURE_1_BTI | FEATURE_1_PAC | FEATURE_1_GCS)
>> #endif
>> diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
>> index da4b7f3fd3..6bf2f4fe0e 100644
>> --- a/sysdeps/aarch64/sysdep.h
>> +++ b/sysdeps/aarch64/sysdep.h
>> @@ -43,23 +43,47 @@
>> #define FEATURE_1_PAC 2
>> #define FEATURE_1_GCS 4
>>
>> +#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_GCS); \
>> + .aeabi_attribute Tag_Feature_GCS, 1; \
>> + .else; \
>> + .aeabi_attribute Tag_Feature_GCS, 0; \
>> + .endif; \
>> + .if ((value) & FEATURE_1_PAC); \
>> + .aeabi_attribute Tag_Feature_PAC, 1; \
>> + .else; \
>> + .aeabi_attribute Tag_Feature_PAC, 0; \
>> + .endif; \
>> + .text
>> +#else
>> /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
>> -#define GNU_PROPERTY(type, value) \
>> - .section .note.gnu.property, "a"; \
>> - .p2align 3; \
>> - .word 4; \
>> - .word 16; \
>> - .word 5; \
>> - .asciz "GNU"; \
>> - .word type; \
>> - .word 4; \
>> - .word value; \
>> - .word 0; \
>> - .text
>> -
>> -/* Add GNU property note with the supported features to all asm code
>> - where sysdep.h is included. */
>> -GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC|FEATURE_1_GCS)
>> +# define GNU_PROPERTY(type, value) \
>> + .section .note.gnu.property, "a"; \
>> + .p2align 3; \
>> + .word 4; \
>> + .word 16; \
>> + .word 5; \
>> + .asciz "GNU"; \
>> + .word type; \
>> + .word 4; \
>> + .word value; \
>> + .word 0; \
>> + .text
>> +
>> +# define FEATURE_1_AND_MARK(value) GNU_PROPERTY (FEATURE_1_AND, value)
>> +#endif /* __ARM_BUILDATTR64_FV */
>> +
>> +/* Add marking with the supported features to all asm code where sysdep.h
>> + is included. */
>> +FEATURE_1_AND_MARK (FEATURE_1_BTI | FEATURE_1_PAC | FEATURE_1_GCS)
>>
>> /* Define an entry point visible from C. */
>> #define ENTRY(name) \
>
More information about the Libc-alpha
mailing list