]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: add support for AEABI Build Attributes
authorMatthieu Longo <matthieu.longo@arm.com>
Wed, 11 Sep 2024 15:11:55 +0000 (16:11 +0100)
committerMatthieu Longo <matthieu.longo@arm.com>
Mon, 16 Jun 2025 13:23:12 +0000 (14:23 +0100)
commit98f5547dce2503d9d0f0cd454184d6870a315538
treec82069049e7166299683cebd831e6319af2bd2b5
parent0b4a3c146312fa9edde12abba31b1f285b5a378d
aarch64: add support for AEABI Build Attributes

GCS (Guarded Control Stack, an Armv9.4-a extension) requires some
caution at runtime. The runtime linker needs to reason about the
compatibility of a set of relocable object files that might not
have been compiled with the same compiler.
Up until now, those metadata, used for the previously mentioned
runtime checks, have been provided to the runtime linker via GNU
properties which are stored in the ELF section ".note.gnu.property".
However, GNU properties are limited in their expressibility, and a
long-term commmitment was taken in the ABI for the Arm architecture
[1] to provide Build Attributes (a.k.a. BAs).

This patch adds the support for emitting AArch64 Build Attributes.
This support includes generating two new assembler directives:
.aeabi_subsection and .aeabi_attribute. These directives are generated
as per the syntax mentioned in spec "Build Attributes for the ArmĀ®
64-bit Architecture (AArch64)" available at [1].

gcc/configure.ac now includes a new check to test whether the
assembler being used to build the toolchain supports these new
directives.
Two behaviors can be observed when -mbranch-protection=[standard|...]
is passed:
- If the assembler support BAs, GCC emits the BAs directives and
no GNU properties.  Note: the static linker will derive the values
of GNU properties from the BAs, and will emit both BAs and GNU
properties into the output object.
- If the assembler do not support them, only .note.gnu.property
section will contain the relevant information.

Bootstrapped on aarch64-none-linux-gnu, and no regression found.

[1]: https://github.com/ARM-software/abi-aa/pull/230

gcc/ChangeLog:

* config.in: Regenerate.
* config/aarch64/aarch64-elf-metadata.h
(class aeabi_subsection): New class for BAs.
* config/aarch64/aarch64-protos.h
(aarch64_pacret_enabled): New function.
* config/aarch64/aarch64.cc
(HAVE_AS_AEABI_BUILD_ATTRIBUTES): New definition.
(aarch64_file_end_indicate_exec_stack): Emit BAss.
(aarch64_pacret_enabled): New function.
(aarch64_start_file): Indent.
* configure: Regenerate.
* configure.ac: New configure check for BAs support in binutils.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp:
(check_effective_target_aarch64_gas_has_build_attributes): New checker.
* gcc.target/aarch64/build-attributes/aarch64-build-attributes.exp: New DejaGNU file.
* gcc.target/aarch64/build-attributes/build-attribute-bti.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-gcs.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-pac.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-standard.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-bti.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-gcs.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-pac.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-standard.c: New test.

Co-Authored-By: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
16 files changed:
gcc/config.in
gcc/config/aarch64/aarch64-elf-metadata.h
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64.cc
gcc/configure
gcc/configure.ac
gcc/testsuite/gcc.target/aarch64/build-attributes/aarch64-build-attributes.exp [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-bti.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-gcs.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-pac.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-standard.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/no-build-attribute-bti.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/no-build-attribute-gcs.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/no-build-attribute-pac.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/build-attributes/no-build-attribute-standard.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp