]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH 12/15] arm: implement bti injection
authorAndrea Corallo <andrea.corallo@arm.com>
Thu, 7 Apr 2022 09:51:56 +0000 (11:51 +0200)
committerAndrea Corallo <andrea.corallo@arm.com>
Thu, 9 Mar 2023 14:57:23 +0000 (14:57 +0000)
commita93bf01521c09d99a21086ece64e74345069fa03
tree4aad5f6585f17a8e38ef000009225a5a170c3c96
parentf1ba236eaabe05f8503abfd6a5dce961376c04a1
[PATCH 12/15] arm: implement bti injection

Hi all,

this patch enables Branch Target Identification Armv8.1-M Mechanism
[1].

This is achieved by using the bti pass made common with Aarch64.

The pass iterates through the instructions and adds the necessary BTI
instructions at the beginning of every function and at every landing
pads targeted by indirect jumps.

Best Regards

  Andrea

[1]
<https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension>

gcc/ChangeLog

2022-04-07  Andrea Corallo  <andrea.corallo@arm.com>

* config.gcc (arm*-*-*): Add 'aarch-bti-insert.o' object.
* config/arm/arm-protos.h: Update.
* config/arm/aarch-common-protos.h: Declare
'aarch_bti_arch_check'.
* config/arm/arm.cc (aarch_bti_enabled) Update.
(aarch_bti_j_insn_p, aarch_pac_insn_p, aarch_gen_bti_c)
(aarch_gen_bti_j, aarch_bti_arch_check): New functions.
* config/arm/arm.md (bti_nop): New insn.
* config/arm/t-arm (PASSES_EXTRA): Add 'arm-passes.def'.
(aarch-bti-insert.o): New target.
* config/arm/unspecs.md (VUNSPEC_BTI_NOP): New unspec.
* config/arm/aarch-bti-insert.cc (rest_of_insert_bti): Verify arch
compatibility.
(gate): Make use of 'aarch_bti_arch_check'.
* config/arm/arm-passes.def: New file.
* config/aarch64/aarch64.cc (aarch_bti_arch_check): New function.

gcc/testsuite/ChangeLog

2022-04-07  Andrea Corallo  <andrea.corallo@arm.com>

* gcc.target/arm/bti-1.c: New testcase.
* gcc.target/arm/bti-2.c: Likewise.
12 files changed:
gcc/config.gcc
gcc/config/aarch64/aarch64.cc
gcc/config/arm/aarch-bti-insert.cc
gcc/config/arm/aarch-common-protos.h
gcc/config/arm/arm-passes.def [new file with mode: 0644]
gcc/config/arm/arm-protos.h
gcc/config/arm/arm.cc
gcc/config/arm/arm.md
gcc/config/arm/t-arm
gcc/config/arm/unspecs.md
gcc/testsuite/gcc.target/arm/bti-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/bti-2.c [new file with mode: 0644]