Initial forward-edge CFI implementation (#3693)
* Initial forward-edge CFI implementation Give the user the option to start all basic blocks that are targets of indirect branches with the BTI instruction introduced by the Branch Target Identification extension to the Arm instruction set architecture. Copyright (c) 2022, Arm Limited. * Refactor `from_artifacts` to avoid second `make_executable` (#1) This involves "parsing" twice but this is parsing just the header of an ELF file so it's not a very intensive operation and should be ok to do twice. * Address the code review feedback Copyright (c) 2022, Arm Limited. Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This commit is contained in:
@@ -67,7 +67,11 @@ fn saved_reg_stack_size(
|
||||
/// point for the trait; it is never actually instantiated.
|
||||
pub struct AArch64MachineDeps;
|
||||
|
||||
impl IsaFlags for aarch64_settings::Flags {}
|
||||
impl IsaFlags for aarch64_settings::Flags {
|
||||
fn is_forward_edge_cfi_enabled(&self) -> bool {
|
||||
self.use_bti()
|
||||
}
|
||||
}
|
||||
|
||||
impl ABIMachineSpec for AArch64MachineDeps {
|
||||
type I = Inst;
|
||||
@@ -549,13 +553,21 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if flags.unwind_info() && call_conv.extends_apple_aarch64() {
|
||||
// The macOS unwinder seems to require this.
|
||||
insts.push(Inst::Unwind {
|
||||
inst: UnwindInst::Aarch64SetPointerAuth {
|
||||
return_addresses: false,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
if isa_flags.use_bti() {
|
||||
insts.push(Inst::Bti {
|
||||
targets: BranchTargetType::C,
|
||||
});
|
||||
}
|
||||
|
||||
if flags.unwind_info() && call_conv.extends_apple_aarch64() {
|
||||
// The macOS unwinder seems to require this.
|
||||
insts.push(Inst::Unwind {
|
||||
inst: UnwindInst::Aarch64SetPointerAuth {
|
||||
return_addresses: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
insts
|
||||
|
||||
Reference in New Issue
Block a user