Skip to content

Commit

Permalink
libafl_qemu: unset thumb bit for breakpoints (AFLplusplus#2619)
Browse files Browse the repository at this point in the history
* unset thumb bit for breakpoints
  • Loading branch information
rmalmain authored Oct 17, 2024
1 parent 23e966c commit 3b31b4d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libafl_qemu/src/qemu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,26 @@ impl Qemu {
}

pub fn set_breakpoint(&self, addr: GuestAddr) {
// Remove thumb bit encoded in addresses.
// Since ARMv7, instructions are (half-)word aligned, so this is safe.
// For ARMv6 and before, this could be wrong since SCTLR.U could be 0.
// TODO: check precisely for architecture before doing this.
#[cfg(target_arch = "arm")]
let addr = { addr & !1 };

unsafe {
libafl_qemu_set_breakpoint(addr.into());
}
}

pub fn remove_breakpoint(&self, addr: GuestAddr) {
// Remove thumb bit encoded in addresses.
// Since ARMv7, instructions are (half-)word aligned, so this is safe.
// For ARMv6 and before, this could be wrong since SCTLR.U could be 0.
// TODO: check precisely for architecture before doing this.
#[cfg(target_arch = "arm")]
let addr = { addr & !1 };

unsafe {
libafl_qemu_remove_breakpoint(addr.into());
}
Expand Down

0 comments on commit 3b31b4d

Please sign in to comment.