Re: [PATCH 1/3] libgcc: Mark AArch64 asm features with build attributes

Andreas Schwab <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
On Mai 21 2026, Muhammad Kamran wrote:

> @@ -92,14 +91,39 @@
>    .word 0;				\
>    .previous
>  
> +#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;								\
> +    .previous

This does not work.  The .previous directive will not undo the
.aeabi_subsection switch, instead it will switch to the .note.GNU-stack
section ...

> +#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__)
>  /* Do not require executable stack.  */
>  .section .note.GNU-stack, "", %progbits
>  .previous

... which was temporarily entered here.  Thus all the rest of the code
will end up there instead of .text.

> -/* Add GNU property note if built with branch protection.  */
> +/* Add marking 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

-- 
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.