libafl_qemu: unset thumb bit for breakpoints (#2619)

* unset thumb bit for breakpoints
This commit is contained in:
Romain Malmain 2024-10-17 09:42:56 +02:00 committed by GitHub
parent 23e966c702
commit 3b31b4d796
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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());
}