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:
@@ -845,6 +845,8 @@ impl<I: VCodeInst> VCode<I> {
|
||||
ra_edits_per_block.push((end_edit_idx - start_edit_idx) as u32);
|
||||
}
|
||||
|
||||
let is_forward_edge_cfi_enabled = self.abi.is_forward_edge_cfi_enabled();
|
||||
|
||||
for (block_order_idx, &block) in final_order.iter().enumerate() {
|
||||
trace!("emitting block {:?}", block);
|
||||
let new_offset = I::align_basic_block(buffer.cur_offset());
|
||||
@@ -902,6 +904,13 @@ impl<I: VCodeInst> VCode<I> {
|
||||
last_offset = Some(cur_offset);
|
||||
}
|
||||
|
||||
if let Some(block_start) = I::gen_block_start(
|
||||
self.block_order.is_indirect_branch_target(block),
|
||||
is_forward_edge_cfi_enabled,
|
||||
) {
|
||||
do_emit(&block_start, &[], &mut disasm, &mut buffer, &mut state);
|
||||
}
|
||||
|
||||
for inst_or_edit in regalloc.block_insts_and_edits(&self, block) {
|
||||
match inst_or_edit {
|
||||
InstOrEdit::Inst(iix) => {
|
||||
|
||||
Reference in New Issue
Block a user