Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco
rustc_codegen_llvm: Add a new 'pc' option to branch-protection Add a new 'pc' option to -Z branch-protection for aarch64 that enables the use of PC as a diversifier in PAC branch protection code. When the pauth-lr target feature is enabled in combination with -Z branch-protection=pac-ret,pc, the new 9.5-a instructions (pacibsppc, retaasppc, etc) will be generated.
This commit is contained in:
@@ -1320,6 +1320,7 @@ pub enum PAuthKey {
|
||||
#[derive(Clone, Copy, Hash, Debug, PartialEq)]
|
||||
pub struct PacRet {
|
||||
pub leaf: bool,
|
||||
pub pc: bool,
|
||||
pub key: PAuthKey,
|
||||
}
|
||||
|
||||
|
||||
@@ -442,8 +442,7 @@ mod desc {
|
||||
pub(crate) const parse_polonius: &str = "either no value or `legacy` (the default), or `next`";
|
||||
pub(crate) const parse_stack_protector: &str =
|
||||
"one of (`none` (default), `basic`, `strong`, or `all`)";
|
||||
pub(crate) const parse_branch_protection: &str =
|
||||
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
|
||||
pub(crate) const parse_branch_protection: &str = "a `,` separated combination of `bti`, `pac-ret`, followed by a combination of `pc`, `b-key`, or `leaf`";
|
||||
pub(crate) const parse_proc_macro_execution_strategy: &str =
|
||||
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
|
||||
pub(crate) const parse_remap_path_scope: &str =
|
||||
@@ -1401,7 +1400,7 @@ pub mod parse {
|
||||
match opt {
|
||||
"bti" => slot.bti = true,
|
||||
"pac-ret" if slot.pac_ret.is_none() => {
|
||||
slot.pac_ret = Some(PacRet { leaf: false, key: PAuthKey::A })
|
||||
slot.pac_ret = Some(PacRet { leaf: false, pc: false, key: PAuthKey::A })
|
||||
}
|
||||
"leaf" => match slot.pac_ret.as_mut() {
|
||||
Some(pac) => pac.leaf = true,
|
||||
@@ -1411,6 +1410,10 @@ pub mod parse {
|
||||
Some(pac) => pac.key = PAuthKey::B,
|
||||
_ => return false,
|
||||
},
|
||||
"pc" => match slot.pac_ret.as_mut() {
|
||||
Some(pac) => pac.pc = true,
|
||||
_ => return false,
|
||||
},
|
||||
_ => return false,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user