From 3345727c94795a24b4bea4e09bcedad63f054892 Mon Sep 17 00:00:00 2001 From: biazo Date: Mon, 9 Jan 2023 04:10:14 -0500 Subject: [PATCH] fixing linking issue on qemu build (#990) * fixing linking issue * insteading of linking lib we dont use. just disable them * fixing the keyutils problem Co-authored-by: Andrea Fioraldi --- libafl_qemu/libafl_qemu_build/Cargo.toml | 9 ++++++++- libafl_qemu/libafl_qemu_build/src/build.rs | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libafl_qemu/libafl_qemu_build/Cargo.toml b/libafl_qemu/libafl_qemu_build/Cargo.toml index 07cdcc8b18..95491b61f2 100644 --- a/libafl_qemu/libafl_qemu_build/Cargo.toml +++ b/libafl_qemu/libafl_qemu_build/Cargo.toml @@ -9,7 +9,13 @@ readme = "./README.md" license = "MIT OR Apache-2.0" keywords = ["fuzzing", "qemu", "instrumentation"] edition = "2021" -categories = ["development-tools::testing", "emulators", "embedded", "os", "no-std"] +categories = [ + "development-tools::testing", + "emulators", + "embedded", + "os", + "no-std", +] [features] slirp = [] # build qemu with host libslirp (for user networking) @@ -22,3 +28,4 @@ cc = "1.0" which = "4.2" json = "0.12" shell-words = "1.1" +pkg-config = "0.3.26" diff --git a/libafl_qemu/libafl_qemu_build/src/build.rs b/libafl_qemu/libafl_qemu_build/src/build.rs index 4e28b0198c..813297d47a 100644 --- a/libafl_qemu/libafl_qemu_build/src/build.rs +++ b/libafl_qemu/libafl_qemu_build/src/build.rs @@ -266,7 +266,9 @@ pub fn build( .arg("--disable-xen") .arg("--disable-xen-pci-passthrough") .arg("--disable-xkbcommon") - .arg("--disable-zstd"); + .arg("--disable-zstd") + .arg("--disable-capstone") + .arg("--disable-sndio"); if cfg!(feature = "debug_assertions") { cmd.arg("--enable-debug"); } @@ -400,6 +402,9 @@ pub fn build( println!("cargo:rustc-link-lib=glib-2.0"); println!("cargo:rustc-link-lib=stdc++"); println!("cargo:rustc-link-lib=z"); + // if keyutils is available, qemu meson script will compile code with keyutils. + // therefore, we need to link with keyutils if our system have libkeyutils. + let _ = pkg_config::Config::new().probe("libkeyutils"); if !is_usermode { println!("cargo:rustc-link-lib=pixman-1");