Adds AArch64 GCS support

- Adds option to rustc config to enable GCS
- Passes `guarded-control-stack` flag to llvm if enabled
This commit is contained in:
Reuben Cruise
2025-09-01 16:53:50 +01:00
parent 2ebb1263e3
commit 6f813e887a
6 changed files with 18 additions and 4 deletions

View File

@@ -370,7 +370,8 @@ pub(crate) unsafe fn create_module<'ll>(
);
}
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if let Some(BranchProtection { bti, pac_ret, gcs }) = sess.opts.unstable_opts.branch_protection
{
if sess.target.arch == "aarch64" {
llvm::add_module_flag_u32(
llmod,
@@ -403,6 +404,12 @@ pub(crate) unsafe fn create_module<'ll>(
"sign-return-address-with-bkey",
u32::from(pac_opts.key == PAuthKey::B),
);
llvm::add_module_flag_u32(
llmod,
llvm::ModuleFlagMergeBehavior::Min,
"guarded-control-stack",
gcs.into(),
);
} else {
bug!(
"branch-protection used on non-AArch64 target; \