Fail to apply aarch64, v8.5a, BTI (branch target identification) feature

Hello,

When I apply bti (v8.5a) feature to make branch protection, the assembly code seen by objdump does not show BTI instruction.

Anyone has experience adapting 'BTI' feature over aarch64 target, please help.

  • feature
    target=aarch64-unknown-none
    target-feature=+v8.5a,+bti

  • toolchain
    installed toolchains
    nightly-x86_64-unknown-linux-gnu (default)
    ...
    installed targets for active toolchain
    aarch64-linux-android
    aarch64-unknown-linux-gnu
    aarch64-unknown-none
    x86_64-unknown-linux-gnu
    ...
    active toolchain
    nightly-x86_64-unknown-linux-gnu (default)
    rustc 1.55.0-nightly (e8cb1a4a5 2021-06-27)

  • rustc support
    $ rustc --target=aarch64-unknown-none --print target-features
    ...
    bti - Enable Branch Target Identification.
    ...
    v8.5a - Support ARM v8.5a instructions.

You could try -Cllvm-args=-mbranch-protection=bti.

I'v tried it, but llvm args has no support for it.

rustc -Cllvm-args="..." with: Unknown command line argument '-mbranch-protection=bti'. Try: 'rustc -Cllvm-args="..." with --help'
rustc -Cllvm-args="..." with: Did you mean '--tail-predication=bti'?

rustc -Cllvm-args="--help-list" shows its supporting list. and I could not found branch-protection.

-Cllvm-args=--tail-predication=bti may be the correct argument then. The LLVM argument names don't always exactly match clang.

Unfortunately, tail-predication does not accept bti.

rustc -Cllvm-args="..." with: for the --tail-predication option: Cannot find option named 'bti'!

--tail-predication= - MVE tail-predication pass options
=disabled - Don't tail-predicate loops
=enabled-no-reductions - Enable tail-predication, but not for reduction loops
=enabled - Enable tail-predication, including reduction loops
=force-enabled-no-reductions - Enable tail-predication, but not for reduction loops, and force this which might be unsafe
=force-enabled - Enable tail-predication, including reduction loops, and force this which might be unsafe

It may be the different feature.

Yeah, my bad.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.