]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Define __ARM_BUILDATTR64_FV
authorMatthieu Longo <matthieu.longo@arm.com>
Mon, 24 Nov 2025 14:56:19 +0000 (14:56 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Thu, 27 Nov 2025 17:48:47 +0000 (17:48 +0000)
Support for Build Attributes (BA) was originally added in [1]. To facilitate their
use in customers codebases and avoid requiring a new Autotools test for BA support,
the specification was later amended. Toolchains that generate BA sections and
support the assembler directives should define the following preprocessor macro:
  __ARM_BUILDATTR64_FV <format-version>
Where <format-version> is the same value as in [2]. Currently, only version 'A'
(0x41) is defined.

This patch also introduces two tests: one that verifies the macro definition for
positive detection of BA support; and another that ensures that no such macro is
defined when BA support is absent.

[1]: 98f5547dce2503d9d0f0cd454184d6870a315538
[2]: [Formal syntax of an ELF Attributes Section](https://github.com/smithp35/
abi-aa/blob/build-attributes/buildattr64/buildattr64.rst#formal-syntax-of-an-elf
-attributes-section)

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc (aarch64_define_unconditional_macros): Define
__ARM_BUILDATTR64_FV when BA support is detected in GAS.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/build-attributes/build-attribute-define-nok.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-define-ok.c: New test.

gcc/config/aarch64/aarch64-c.cc
gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-define-nok.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-define-ok.c [new file with mode: 0644]

index c3957c762eff6e26a3722a398d3c762fab54f2cd..de4444bacb79804eaa6b31d3fc9783574feb249a 100644 (file)
@@ -65,6 +65,11 @@ aarch64_define_unconditional_macros (cpp_reader *pfile)
 
   builtin_define_with_int_value ("__ARM_ARCH_PROFILE",
       TARGET_V8R ? 'R' : 'A');
+
+#if HAVE_AS_AEABI_BUILD_ATTRIBUTES
+  builtin_define_with_int_value ("__ARM_BUILDATTR64_FV", 'A');
+#endif
+
   builtin_define ("__ARM_FEATURE_CLZ");
   builtin_define ("__ARM_FEATURE_IDIV");
   builtin_define ("__ARM_FEATURE_UNALIGNED");
diff --git a/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-define-nok.c b/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-define-nok.c
new file mode 100644 (file)
index 0000000..55b9de9
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile { target { aarch64*-*-linux* && { ! aarch64_gas_has_build_attributes } } } } */
+
+#if defined(__ARM_BUILDATTR64_FV)
+#error "Support for build attributes should not be enabled in this toolchain."
+#endif
diff --git a/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-define-ok.c b/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-define-ok.c
new file mode 100644 (file)
index 0000000..7ecb929
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile { target { aarch64*-*-linux* && { aarch64_gas_has_build_attributes } } } } */
+
+#if ! defined(__ARM_BUILDATTR64_FV)
+#error "Support for build attributes should be enabled in this toolchain."
+#elif __ARM_BUILDATTR64_FV != 'A'
+#error "The current build attributes version does not match the expected one."
+#endif