Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sysvabi64] Document requirements for tools wrt BTI #282

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

smithp35
Copy link
Contributor

Add requirements for when a tool must generate a BTI instruction. This permits tools to elide BTI instructions when they can prove that no indirect branch to that location is possible from local information available to the tool.

Static linkers are not allowed to assume that all direct branch targets have a BTI instruction. If a veneer is required then the static linker must generate additional BTI instructions if needed.

A static linker is allowed to assume that a symbol that is exported to the dynamic symbol table has a BTI instruction.

In practice this will permit compilers to remove BTI instructions from static functions that do not have their address taken and that address escapes the function.

This matches the behavior of the GNU toolchain.

Fixes #196

Add requirements for when a tool must generate a BTI instruction.
This permits tools to elide BTI instructions when they can prove that
no indirect branch to that location is possible from local information
available to the tool.

Static linkers are not allowed to assume that all direct branch
targets have a BTI instruction. If a veneer is required then the
static linker must generate additional BTI instructions if needed.

A static linker is allowed to assume that a symbol that is exported
to the dynamic symbol table has a BTI instruction.

In practice this will permit compilers to remove BTI instructions from
static functions that do not have their address taken and that address
escapes the function.

This matches the behavior of the GNU toolchain.

Fixes ARM-software#196
@smithp35
Copy link
Contributor Author

LLD patch to implement BTI aware thunks llvm/llvm-project#108989

It is possible to provide a static linker with branch targets
using absolute symbols. For example using --defsym. The static
cannot disassemble the location of these symbols so it isn't
possible to check whether A BTI landing pad is necessary, nor
is it always possible to place a BTI landing pad within range
of the absolute symbol address.

A user providing the static linker with function addresses
using absolute symbols is responsible for putting BTI
compatible landing pads at the start of these addresses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sysvabi64] document requirement for bti c in more detail
1 participant