diff --git a/fuzzers/binary_only/qemu_cmin/Makefile.toml b/fuzzers/binary_only/qemu_cmin/Makefile.toml index 2b292c0505..1ea06ad45f 100644 --- a/fuzzers/binary_only/qemu_cmin/Makefile.toml +++ b/fuzzers/binary_only/qemu_cmin/Makefile.toml @@ -199,6 +199,7 @@ args = [ "build", "--profile", "${PROFILE}", + "--no-default-features", "--features", "${FEATURE}", "--target-dir", diff --git a/libafl_concolic/symcc_runtime/Cargo.toml b/libafl_concolic/symcc_runtime/Cargo.toml index 377e8c5c7f..415ed58aa0 100644 --- a/libafl_concolic/symcc_runtime/Cargo.toml +++ b/libafl_concolic/symcc_runtime/Cargo.toml @@ -44,7 +44,7 @@ cmake = { workspace = true } bindgen = { workspace = true } regex = { workspace = true } which = { workspace = true } -symcc_libafl = { workspace = true, default-features = true, version = "0.14.0" } +symcc_libafl = { workspace = true, default-features = true } [lints] workspace = true diff --git a/libafl_qemu/Cargo.toml b/libafl_qemu/Cargo.toml index f9cdf0e6f8..5c699baa3d 100644 --- a/libafl_qemu/Cargo.toml +++ b/libafl_qemu/Cargo.toml @@ -24,6 +24,7 @@ rustdoc-args = ["--cfg", "docsrs"] [features] default = [ "usermode", + "x86_64", "fork", "build_libgasan", "build_libqasan", @@ -49,7 +50,7 @@ build_libqasan = [] #! ## The following architecture features are mutually exclusive. -## build qemu for x86_64 (default) +## build qemu for x86_64 x86_64 = ["libafl_qemu_sys/x86_64"] i386 = ["libafl_qemu_sys/i386"] # build qemu for i386 arm = ["libafl_qemu_sys/arm"] # build qemu for arm @@ -90,7 +91,7 @@ clippy = ["libafl_qemu_sys/clippy"] [dependencies] libafl = { workspace = true, features = ["std", "derive", "regex"] } libafl_bolts = { workspace = true, features = ["std", "derive"] } -libafl_targets = { workspace = true, default-features = true, version = "0.14.0" } +libafl_targets = { workspace = true, default-features = true } libafl_qemu_sys = { workspace = true } libafl_derive = { workspace = true, default-features = true } @@ -131,7 +132,7 @@ getset = "0.1.3" document-features = { workspace = true, optional = true } [build-dependencies] -libafl_qemu_build = { workspace = true, default-features = true, version = "0.14.0" } +libafl_qemu_build = { workspace = true, default-features = true } pyo3-build-config = { version = "0.22.3", optional = true } rustversion = { workspace = true } bindgen = { workspace = true } diff --git a/libafl_qemu/build_linux.rs b/libafl_qemu/build_linux.rs index 239ec2ede2..29d4ee87a0 100644 --- a/libafl_qemu/build_linux.rs +++ b/libafl_qemu/build_linux.rs @@ -16,20 +16,6 @@ void __libafl_qemu_testfile() {} #[allow(clippy::too_many_lines)] pub fn build() { // Note: Unique features are checked in libafl_qemu_sys - println!( - r#"cargo::rustc-check-cfg=cfg(cpu_target, values("arm", "aarch64", "hexagon", "i386", "mips", "ppc", "riscv32", "riscv64", "x86_64"))"# - ); - - let emulation_mode = if cfg!(feature = "usermode") { - "usermode" - } else if cfg!(feature = "systemmode") { - "systemmode" - } else { - unreachable!( - "The macros `assert_unique_feature` and `assert_at_least_one_feature` in \ - `libafl_qemu_sys/build_linux.rs` should panic before this code is reached." - ); - }; let src_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let src_dir = PathBuf::from(src_dir); @@ -81,29 +67,29 @@ pub fn build() { println!("cargo:rerun-if-changed={}", libafl_runtime_dir.display()); let cpu_target = if cfg!(feature = "x86_64") { - "x86_64".to_string() + "x86_64" } else if cfg!(feature = "arm") { - "arm".to_string() + "arm" } else if cfg!(feature = "aarch64") { - "aarch64".to_string() + "aarch64" } else if cfg!(feature = "i386") { - "i386".to_string() + "i386" } else if cfg!(feature = "mips") { - "mips".to_string() + "mips" } else if cfg!(feature = "ppc") { - "ppc".to_string() + "ppc" } else if cfg!(feature = "riscv32") { - "riscv32".to_string() + "riscv32" } else if cfg!(feature = "riscv64") { - "riscv64".to_string() + "riscv64" } else if cfg!(feature = "hexagon") { - "hexagon".to_string() + "hexagon" } else { - env::var("CPU_TARGET").unwrap_or_else(|_| "x86_64".to_string()) + unreachable!( + "The macros `assert_unique_feature` and `assert_at_least_one_feature` in \ + `libafl_qemu_sys/build_linux.rs` should panic before this code is reached." + ); }; - println!("cargo:rerun-if-env-changed=CPU_TARGET"); - println!("cargo:rustc-cfg=cpu_target=\"{cpu_target}\""); - println!("cargo::rustc-check-cfg=cfg(cpu_target, values(\"x86_64\", \"arm\", \"aarch64\", \"i386\", \"mips\", \"ppc\", \"hexagon\", \"riscv32\", \"riscv64\"))"); let cross_cc = if cfg!(feature = "usermode") && (qemu_asan || qemu_asan_guest) { // TODO try to autodetect a cross compiler with the arch name (e.g. aarch64-linux-gnu-gcc) @@ -167,8 +153,8 @@ pub fn build() { .expect("Could not write bindings."); maybe_generate_stub_bindings( - &cpu_target, - emulation_mode, + cpu_target, + cfg!(feature = "usermode"), stub_runtime_bindings_file.as_path(), runtime_bindings_file.as_path(), ); diff --git a/libafl_qemu/libafl_qemu_build/src/lib.rs b/libafl_qemu/libafl_qemu_build/src/lib.rs index 57445cfe46..e851ada861 100644 --- a/libafl_qemu/libafl_qemu_build/src/lib.rs +++ b/libafl_qemu/libafl_qemu_build/src/lib.rs @@ -389,14 +389,11 @@ pub fn store_generated_content_if_different( #[allow(unused)] pub fn maybe_generate_stub_bindings( cpu_target: &str, - emulation_mode: &str, + is_usermode: bool, stub_bindings_file: &Path, bindings_file: &Path, ) { - if env::var("LIBAFL_QEMU_GEN_STUBS").is_ok() - && cpu_target == "x86_64" - && emulation_mode == "usermode" - { + if env::var("LIBAFL_QEMU_GEN_STUBS").is_ok() && cpu_target == "x86_64" && is_usermode { let current_rustc_version = rustc_version::version().expect("Could not get current rustc version"); diff --git a/libafl_qemu/libafl_qemu_sys/build.rs b/libafl_qemu/libafl_qemu_sys/build.rs index 6ad3e59ab1..b6cd28a0b2 100644 --- a/libafl_qemu/libafl_qemu_sys/build.rs +++ b/libafl_qemu/libafl_qemu_sys/build.rs @@ -20,10 +20,6 @@ fn nightly() {} fn main() { println!("cargo:rustc-check-cfg=cfg(nightly)"); - println!(r#"cargo::rustc-check-cfg=cfg(emulation_mode, values("usermode", "systemmode"))"#); - println!( - r#"cargo::rustc-check-cfg=cfg(cpu_target, values("arm", "aarch64", "hexagon", "i386", "mips", "ppc", "x86_64"))"# - ); nightly(); host_specific::build(); } diff --git a/libafl_qemu/libafl_qemu_sys/build_linux.rs b/libafl_qemu/libafl_qemu_sys/build_linux.rs index b3a5b6edf9..b2bf44ef88 100644 --- a/libafl_qemu/libafl_qemu_sys/build_linux.rs +++ b/libafl_qemu/libafl_qemu_sys/build_linux.rs @@ -28,22 +28,14 @@ pub fn build() { // Make sure that at least one qemu mode is set assert_at_least_one_feature!("usermode", "systemmode"); - let emulation_mode = if cfg!(feature = "usermode") { - "usermode" - } else if cfg!(feature = "systemmode") { - "systemmode" - } else { - unreachable!( - "The above macros, `assert_unique_feature` and `assert_at_least_one_feature`, should \ - panic before this code is reached." - ); - }; - // Make sure we have at most one architecutre feature set - // Else, we default to `x86_64` - having a default makes CI easier :) assert_unique_feature!( "arm", "aarch64", "i386", "x86_64", "mips", "ppc", "hexagon", "riscv32", "riscv64" ); + // Make sure we have at least one architecutre feature set + assert_at_least_one_feature!( + "arm", "aarch64", "i386", "x86_64", "mips", "ppc", "hexagon", "riscv32", "riscv64" + ); // Make sure that we don't have BE set for any architecture other than arm and mips // Sure aarch64 may support BE, but its not in common usage and we don't @@ -51,35 +43,31 @@ pub fn build() { assert_unique_feature!("be", "aarch64", "i386", "x86_64", "hexagon", "riscv32", "riscv64"); let cpu_target = if cfg!(feature = "x86_64") { - "x86_64".to_string() + "x86_64" } else if cfg!(feature = "arm") { - "arm".to_string() + "arm" } else if cfg!(feature = "aarch64") { - "aarch64".to_string() + "aarch64" } else if cfg!(feature = "i386") { - "i386".to_string() + "i386" } else if cfg!(feature = "mips") { - "mips".to_string() + "mips" } else if cfg!(feature = "ppc") { - "ppc".to_string() + "ppc" } else if cfg!(feature = "riscv32") { - "riscv32".to_string() + "riscv32" } else if cfg!(feature = "riscv64") { - "riscv64".to_string() + "riscv64" } else if cfg!(feature = "hexagon") { - "hexagon".to_string() + "hexagon" } else { - env::var("CPU_TARGET").unwrap_or_else(|_| { - println!( - "cargo:warning=No architecture feature enabled or CPU_TARGET env specified for libafl_qemu, supported: arm, aarch64, hexagon, i386, mips, ppc, riscv32, riscv64, x86_64 - defaulting to x86_64" - ); - "x86_64".to_string() - }) + unreachable!( + "The above macros, `assert_unique_feature` and `assert_at_least_one_feature`, should \ + panic before this code is reached." + ); }; - println!("cargo:rerun-if-env-changed=CPU_TARGET"); + println!("cargo:rerun-if-env-changed=LIBAFL_QEMU_GEN_STUBS"); - println!("cargo:rustc-cfg=cpu_target=\"{cpu_target}\""); - println!("cargo::rustc-check-cfg=cfg(cpu_target, values(\"x86_64\", \"arm\", \"aarch64\", \"i386\", \"mips\", \"ppc\", \"hexagon\", \"riscv32\", \"riscv64\"))"); let jobs = env::var("NUM_JOBS") .ok() @@ -100,9 +88,9 @@ pub fn build() { } build_with_bindings( - &cpu_target, + cpu_target, cfg!(feature = "be"), - emulation_mode == "usermode", + cfg!(feature = "usermode"), jobs, &bindings_file, ); @@ -111,8 +99,8 @@ pub fn build() { // If the bindings are built and differ from the current stub, replace it with the freshly generated bindings maybe_generate_stub_bindings( - &cpu_target, - emulation_mode, + cpu_target, + cfg!(feature = "usermode"), stub_bindings_file.as_path(), bindings_file.as_path(), ); diff --git a/libafl_qemu/src/arch/mod.rs b/libafl_qemu/src/arch/mod.rs index f4a03b63b8..71ace3bc73 100644 --- a/libafl_qemu/src/arch/mod.rs +++ b/libafl_qemu/src/arch/mod.rs @@ -1,39 +1,39 @@ -#[cfg(cpu_target = "aarch64")] +#[cfg(feature = "aarch64")] pub mod aarch64; -#[cfg(all(cpu_target = "aarch64", not(feature = "clippy")))] +#[cfg(all(feature = "aarch64", not(feature = "clippy")))] pub use aarch64::*; -#[cfg(cpu_target = "arm")] +#[cfg(feature = "arm")] pub mod arm; -#[cfg(all(cpu_target = "arm", not(feature = "clippy")))] +#[cfg(all(feature = "arm", not(feature = "clippy")))] pub use arm::*; -#[cfg(cpu_target = "i386")] +#[cfg(feature = "i386")] pub mod i386; -#[cfg(all(cpu_target = "i386", not(feature = "clippy")))] +#[cfg(all(feature = "i386", not(feature = "clippy")))] pub use i386::*; -#[cfg(cpu_target = "x86_64")] +#[cfg(feature = "x86_64")] pub mod x86_64; -#[cfg(cpu_target = "x86_64")] +#[cfg(feature = "x86_64")] pub use x86_64::*; -#[cfg(cpu_target = "mips")] +#[cfg(feature = "mips")] pub mod mips; -#[cfg(cpu_target = "mips")] +#[cfg(feature = "mips")] pub use mips::*; -#[cfg(cpu_target = "ppc")] +#[cfg(feature = "ppc")] pub mod ppc; -#[cfg(cpu_target = "ppc")] +#[cfg(feature = "ppc")] pub use ppc::*; -#[cfg(cpu_target = "hexagon")] +#[cfg(feature = "hexagon")] pub mod hexagon; -#[cfg(cpu_target = "hexagon")] +#[cfg(feature = "hexagon")] pub use hexagon::*; -#[cfg(any(cpu_target = "riscv32", cpu_target = "riscv64"))] +#[cfg(any(feature = "riscv32", feature = "riscv64"))] pub mod riscv; -#[cfg(any(cpu_target = "riscv32", cpu_target = "riscv64"))] +#[cfg(any(feature = "riscv32", feature = "riscv64"))] pub use riscv::*; diff --git a/libafl_qemu/src/elf.rs b/libafl_qemu/src/elf.rs index 40f0726941..eb5df7d1e3 100644 --- a/libafl_qemu/src/elf.rs +++ b/libafl_qemu/src/elf.rs @@ -54,17 +54,17 @@ impl<'a> EasyElf<'a> { return if sym.st_value == 0 { None } else if self.is_pic() { - #[cfg(cpu_target = "arm")] + #[cfg(feature = "arm")] // Required because of arm interworking addresses aka bit(0) for thumb mode let addr = (sym.st_value as GuestAddr + load_addr) & !(0x1 as GuestAddr); - #[cfg(not(cpu_target = "arm"))] + #[cfg(not(feature = "arm"))] let addr = sym.st_value as GuestAddr + load_addr; Some(addr) } else { - #[cfg(cpu_target = "arm")] + #[cfg(feature = "arm")] // Required because of arm interworking addresses aka bit(0) for thumb mode let addr = (sym.st_value as GuestAddr) & !(0x1 as GuestAddr); - #[cfg(not(cpu_target = "arm"))] + #[cfg(not(feature = "arm"))] let addr = sym.st_value as GuestAddr; Some(addr) }; diff --git a/libafl_qemu/src/lib.rs b/libafl_qemu/src/lib.rs index 13401b3a77..7541fcdd10 100644 --- a/libafl_qemu/src/lib.rs +++ b/libafl_qemu/src/lib.rs @@ -9,7 +9,7 @@ // This lint triggers too often on the current GuestAddr type when emulating 64-bit targets because // u64::from(GuestAddr) is a no-op, but the .into() call is needed when GuestAddr is u32. #![cfg_attr( - any(cpu_target = "x86_64", cpu_target = "aarch64"), + any(feature = "x86_64", feature = "aarch64"), allow(clippy::useless_conversion) )] // libafl_qemu_sys export types with empty struct markers (e.g. struct {} start_init_save) diff --git a/libafl_qemu/src/modules/calls.rs b/libafl_qemu/src/modules/calls.rs index ecb47e1b97..53dbbd64e6 100644 --- a/libafl_qemu/src/modules/calls.rs +++ b/libafl_qemu/src/modules/calls.rs @@ -283,7 +283,7 @@ where return None; } - #[cfg(cpu_target = "arm")] + #[cfg(feature = "arm")] h.cs.set_mode(if pc & 1 == 1 { arch::arm::ArchMode::Thumb.into() } else { diff --git a/libafl_qemu/src/modules/cmplog.rs b/libafl_qemu/src/modules/cmplog.rs index b595971374..ce0d577c0c 100644 --- a/libafl_qemu/src/modules/cmplog.rs +++ b/libafl_qemu/src/modules/cmplog.rs @@ -309,7 +309,7 @@ impl CmpLogRoutinesModule { return None; } - #[cfg(cpu_target = "arm")] + #[cfg(feature = "arm")] h.cs.set_mode(if pc & 1 == 1 { capstone::arch::arm::ArchMode::Thumb.into() } else { diff --git a/libafl_qemu/src/modules/mod.rs b/libafl_qemu/src/modules/mod.rs index 73ce932ade..3f1e2e28d7 100644 --- a/libafl_qemu/src/modules/mod.rs +++ b/libafl_qemu/src/modules/mod.rs @@ -25,19 +25,19 @@ pub use edges::{ StdEdgeCoverageFullModuleBuilder, StdEdgeCoverageModule, StdEdgeCoverageModuleBuilder, }; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub mod calls; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub use calls::CallTracerModule; -#[cfg(not(any(cpu_target = "mips", cpu_target = "hexagon")))] +#[cfg(not(any(feature = "mips", feature = "hexagon")))] pub mod cmplog; -#[cfg(not(any(cpu_target = "mips", cpu_target = "hexagon")))] +#[cfg(not(any(feature = "mips", feature = "hexagon")))] pub use cmplog::CmpLogModule; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub mod drcov; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub use drcov::{DrCovMetadata, DrCovModule, DrCovModuleBuilder}; use crate::{emu::EmulatorModules, Qemu}; diff --git a/libafl_qemu/src/modules/usermode/asan_guest.rs b/libafl_qemu/src/modules/usermode/asan_guest.rs index 567d98048e..5b7c63cee6 100644 --- a/libafl_qemu/src/modules/usermode/asan_guest.rs +++ b/libafl_qemu/src/modules/usermode/asan_guest.rs @@ -124,9 +124,9 @@ pub struct AsanGuestModule { } #[cfg(any( - cpu_target = "aarch64", - cpu_target = "x86_64", - cpu_target = "riscv64", + feature = "aarch64", + feature = "x86_64", + feature = "riscv64", feature = "clippy" ))] impl AsanGuestModule { @@ -137,11 +137,11 @@ impl AsanGuestModule { } #[cfg(any( - cpu_target = "arm", - cpu_target = "i386", - cpu_target = "mips", - cpu_target = "ppc", - cpu_target = "riscv32", + feature = "arm", + feature = "i386", + feature = "mips", + feature = "ppc", + feature = "riscv32", ))] impl AsanGuestModule { const HIGH_SHADOW_START: GuestAddr = 0x28000000; diff --git a/libafl_qemu/src/modules/usermode/injections.rs b/libafl_qemu/src/modules/usermode/injections.rs index 56a3b22ce1..10e154b4d9 100644 --- a/libafl_qemu/src/modules/usermode/injections.rs +++ b/libafl_qemu/src/modules/usermode/injections.rs @@ -18,7 +18,7 @@ use libafl::{inputs::UsesInput, Error}; use libafl_qemu_sys::GuestAddr; use serde::{Deserialize, Serialize}; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] use crate::SYS_execve; use crate::{ elf::EasyElf, @@ -28,7 +28,7 @@ use crate::{ CallingConvention, Qemu, }; -#[cfg(cpu_target = "hexagon")] +#[cfg(feature = "hexagon")] /// Hexagon syscalls are not currently supported by the `syscalls` crate, so we just paste this here for now. /// const SYS_execve: u8 = 221; diff --git a/libafl_qemu/src/modules/usermode/mod.rs b/libafl_qemu/src/modules/usermode/mod.rs index 1d9cc503d2..c9f0e51ec8 100644 --- a/libafl_qemu/src/modules/usermode/mod.rs +++ b/libafl_qemu/src/modules/usermode/mod.rs @@ -3,17 +3,17 @@ pub mod injections; #[cfg(feature = "injections")] pub use injections::InjectionModule; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub mod snapshot; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub use snapshot::{IntervalSnapshotFilter, SnapshotModule}; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub mod asan; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub use asan::{init_qemu_with_asan, AsanModule}; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub mod asan_guest; -#[cfg(not(cpu_target = "hexagon"))] +#[cfg(not(feature = "hexagon"))] pub use asan_guest::{init_qemu_with_asan_guest, AsanGuestModule}; diff --git a/libafl_qemu/src/modules/usermode/snapshot.rs b/libafl_qemu/src/modules/usermode/snapshot.rs index d2447238ce..e83f3a7f8d 100644 --- a/libafl_qemu/src/modules/usermode/snapshot.rs +++ b/libafl_qemu/src/modules/usermode/snapshot.rs @@ -6,18 +6,18 @@ use libafl_qemu_sys::{GuestAddr, MmapPerms}; use meminterval::{Interval, IntervalTree}; use thread_local::ThreadLocal; -#[cfg(any(cpu_target = "arm", cpu_target = "i386", cpu_target = "mips"))] +#[cfg(any(feature = "arm", feature = "i386", feature = "mips"))] use crate::SYS_fstatat64; -#[cfg(not(any(cpu_target = "arm", cpu_target = "riscv32")))] +#[cfg(not(any(feature = "arm", feature = "riscv32")))] use crate::SYS_mmap; -#[cfg(any(cpu_target = "arm", cpu_target = "mips", cpu_target = "riscv32"))] +#[cfg(any(feature = "arm", feature = "mips", feature = "riscv32"))] use crate::SYS_mmap2; #[cfg(not(any( - cpu_target = "arm", - cpu_target = "mips", - cpu_target = "i386", - cpu_target = "ppc", - cpu_target = "riscv32", + feature = "arm", + feature = "mips", + feature = "i386", + feature = "ppc", + feature = "riscv32", )))] use crate::SYS_newfstatat; use crate::{ @@ -29,7 +29,7 @@ use crate::{ qemu::{Hook, SyscallHookResult}, Qemu, SYS_brk, SYS_mprotect, SYS_mremap, SYS_munmap, SYS_pread64, SYS_read, SYS_readlinkat, }; -#[cfg(not(cpu_target = "riscv32"))] +#[cfg(not(feature = "riscv32"))] use crate::{SYS_fstat, SYS_fstatfs, SYS_futex, SYS_getrandom, SYS_statfs}; // TODO use the functions provided by Qemu @@ -806,17 +806,17 @@ where let h = emulator_modules.get_mut::().unwrap(); h.access(a2, a3 as usize); } - #[cfg(not(cpu_target = "riscv32"))] + #[cfg(not(feature = "riscv32"))] SYS_futex => { let h = emulator_modules.get_mut::().unwrap(); h.access(a0, a3 as usize); } #[cfg(not(any( - cpu_target = "arm", - cpu_target = "i386", - cpu_target = "mips", - cpu_target = "ppc", - cpu_target = "riscv32" + feature = "arm", + feature = "i386", + feature = "mips", + feature = "ppc", + feature = "riscv32" )))] SYS_newfstatat => { if a2 != 0 { @@ -824,19 +824,19 @@ where h.access(a2, 4096); // stat is not greater than a page } } - #[cfg(any(cpu_target = "arm", cpu_target = "mips", cpu_target = "i386"))] + #[cfg(any(feature = "arm", feature = "mips", feature = "i386"))] SYS_fstatat64 => { if a2 != 0 { let h = emulator_modules.get_mut::().unwrap(); h.access(a2, 4096); // stat is not greater than a page } } - #[cfg(not(cpu_target = "riscv32"))] + #[cfg(not(feature = "riscv32"))] SYS_statfs | SYS_fstat | SYS_fstatfs => { let h = emulator_modules.get_mut::().unwrap(); h.access(a1, 4096); // stat is not greater than a page } - #[cfg(not(cpu_target = "riscv32"))] + #[cfg(not(feature = "riscv32"))] SYS_getrandom => { let h = emulator_modules.get_mut::().unwrap(); h.access(a0, a1 as usize); @@ -861,7 +861,7 @@ where // TODO handle huge pages - #[cfg(any(cpu_target = "arm", cpu_target = "mips", cpu_target = "riscv32"))] + #[cfg(any(feature = "arm", feature = "mips", feature = "riscv32"))] if sys_const == SYS_mmap2 { if let Ok(prot) = MmapPerms::try_from(a2 as i32) { let h = emulator_modules.get_mut::().unwrap(); @@ -869,7 +869,7 @@ where } } - #[cfg(not(any(cpu_target = "arm", cpu_target = "riscv32")))] + #[cfg(not(any(feature = "arm", feature = "riscv32")))] if sys_const == SYS_mmap { if let Ok(prot) = MmapPerms::try_from(a2 as i32) { let h = emulator_modules.get_mut::().unwrap(); diff --git a/libafl_sugar/Cargo.toml b/libafl_sugar/Cargo.toml index 998fb9cae6..9d5da25f55 100644 --- a/libafl_sugar/Cargo.toml +++ b/libafl_sugar/Cargo.toml @@ -22,7 +22,7 @@ categories = [ all-features = true [features] -default = [] +default = ["x86_64"] document-features = ["dep:document-features"] clippy = [ "libafl_qemu/clippy", @@ -37,7 +37,7 @@ python = ["pyo3", "libafl_qemu/python", "pyo3-build-config"] #! ## Features for `libafl_qemu` (Linux only) #! The following architecture features are mutually exclusive. -## build qemu for x86_64 (default) +## build qemu for x86_64 x86_64 = ["libafl_qemu/x86_64"] ## build qemu for i386 i386 = ["libafl_qemu/i386"] @@ -72,7 +72,14 @@ pyo3 = { version = "0.22.3", optional = true } log = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] -libafl_qemu = { workspace = true, default-features = true } +libafl_qemu = { workspace = true, features = [ + "usermode", + "fork", + "build_libgasan", + "build_libqasan", + "serdeany_autoreg", + "injections", +] } [lib] name = "libafl_sugar"