Fix libafl_qemu i386 build (#924)

* fix

* fmt

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
This commit is contained in:
Dongjia "toka" Zhang 2022-12-04 23:07:30 +09:00 committed by GitHub
parent 71dd58396c
commit 8444cf7cc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -50,6 +50,15 @@ pub fn pc2basicblock(pc: GuestAddr, emu: &Emulator) -> Result<Vec<Instruction>,
.detail(true)
.build()
.unwrap();
#[cfg(cpu_target = "i386")]
let cs = Capstone::new()
.x86()
.mode(capstone::arch::x86::ArchMode::Mode32)
.detail(true)
.build()
.unwrap();
#[cfg(cpu_target = "arm")]
let cs = Capstone::new()
.arm()

View File

@ -15,9 +15,11 @@ use crate::{
GuestAddr, SYS_fstat, SYS_fstatfs, SYS_futex, SYS_getrandom, SYS_mprotect, SYS_mremap,
SYS_munmap, SYS_pread64, SYS_read, SYS_readlinkat, SYS_statfs,
};
#[cfg(cpu_target = "i386")]
use crate::{SYS_fstatat64, SYS_mmap};
#[cfg(cpu_target = "arm")]
use crate::{SYS_fstatat64, SYS_mmap2};
#[cfg(not(cpu_target = "arm"))]
#[cfg(not(any(cpu_target = "arm", cpu_target = "i386")))]
use crate::{SYS_mmap, SYS_newfstatat};
// TODO use the functions provided by Emulator
@ -630,14 +632,14 @@ where
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
h.access(a0 as GuestAddr, a3 as usize);
}
#[cfg(not(cpu_target = "arm"))]
#[cfg(not(any(cpu_target = "arm", cpu_target = "i386")))]
SYS_newfstatat => {
if a2 != 0 {
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
h.access(a2 as GuestAddr, 4096); // stat is not greater than a page
}
}
#[cfg(cpu_target = "arm")]
#[cfg(any(cpu_target = "arm", cpu_target = "i386"))]
SYS_fstatat64 => {
if a2 != 0 {
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();