Skip to content

[PAC] Fixes for entries in init/fini arrays - #165758

Open
jchlanda wants to merge 2 commits into
rust-lang:mainfrom
jchlanda:jakub/init_fini_addr
Open

jchlanda wants to merge 2 commits into
rust-lang:mainfrom
jchlanda:jakub/init_fini_addr

Conversation

@jchlanda

Copy link
Copy Markdown
Contributor

This PR brings three main groups of fixes:

  • Reject functions with unsupported ABIs in init/fini entries (those functions would not be signed). As the loader authenticates every entry in the init/fini arrays, they would fail to authenticate. Instead, issue an error, and suggest using a supported ABI.
  • I got the address discrimination of init/fini entries wrong way round. Fix it, such that enabling it uses a placeholder value of 1 (later resolved by the loader).
  • Split the bitfields in the ABI version to match Clang's behaviour: use explicit values for bot enabling init/fini and enabling address discrimination of init/fini.

r? @davidtwco

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2026
@rust-bors

This comment has been minimized.

For pointer authentication and `init-fini` enabled, the loader
authenticates every `.init_array` and `.fini_array` entry with the
init/fini signing schema. However, rust only signs function pointers
with `extern "C"` and `extern "system"` ABIs, all other ABIs stay
unsigned and failed authentication when the loader ran it.

Also, report an error for such entries (and suggest supported ABI).
`init-fini-address-discrimination` was mapped the wrong way round:

* enabling it selected (incorrect) hardware address discrimination,
* disabling it selected the synthetic placeholder `1`.

To make the matters even worst there was no way to disable it.

This patch cleans it up, so that Rust follows Clang in enabling (the
default) placeholder `1`.

I've followed Clang and split the flag for enabling init/fini from
init/fini's address discriminator when the ABI version is calculated.
@jchlanda
jchlanda force-pushed the jakub/init_fini_addr branch from 5e457f8 to 6e04572 Compare November 12, 2026 14:12
@rustbot

rustbot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants