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.
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");
--- /dev/null
+/* { 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
--- /dev/null
+/* { 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