Skip to content

Check AArch64 branch-protection earlier in the pipeline. #105421

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

Merged
merged 3 commits into from
Dec 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
bug! if branch-protection makes it to non-AArch64 codegen.
  • Loading branch information
jacobbramley committed Dec 13, 2022
commit 73d374f3e7d5fe9635a23937cdc2f7e1d1c29224
10 changes: 7 additions & 3 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,8 @@ pub unsafe fn create_module<'ll>(
}
}

// AArch64-only options (checked in rustc_session).
if sess.target.arch == "aarch64" {
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if sess.target.arch == "aarch64" {
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
Expand All @@ -302,6 +301,11 @@ pub unsafe fn create_module<'ll>(
"sign-return-address-with-bkey\0".as_ptr().cast(),
u32::from(pac_opts.key == PAuthKey::B),
);
} else {
bug!(
"branch-protection used on non-AArch64 target; \
this should be checked in rustc_session."
);
}
}

Expand Down