Add --libafl arg in libafl_cc and enable it for fuzzbench (#466)
This commit is contained in:
parent
bca1f392a7
commit
9b3a435778
@ -12,7 +12,7 @@ target/release/libafl_cxx: src/* src/bin/*
|
||||
target/release/libafl_cc: target/release/libafl_cxx
|
||||
|
||||
fuzz.o: fuzz.c target/release/libafl_cc
|
||||
target/release/libafl_cc -O3 -c $^ -o $@
|
||||
target/release/libafl_cc --libafl-no-link -O3 -c $^ -o $@
|
||||
|
||||
fuzzer: target/release/libafl_cxx fuzz.o
|
||||
# Build the fuzzer compiler
|
||||
@ -20,6 +20,7 @@ fuzzer: target/release/libafl_cxx fuzz.o
|
||||
|
||||
# Build the harness
|
||||
target/release/libafl_cxx \
|
||||
--libafl \
|
||||
fuzz.o \
|
||||
-o $(FUZZER_NAME) \
|
||||
-lm -lz
|
||||
|
@ -20,6 +20,8 @@ pub fn main() {
|
||||
.cpp(is_cpp)
|
||||
// silence the compiler wrapper output, needed for some configure scripts.
|
||||
.silence(true)
|
||||
// add arguments only if --libafl or --libafl-no-link are present
|
||||
.need_libafl_arg(true)
|
||||
.from_args(&args)
|
||||
.expect("Failed to parse the command line")
|
||||
.link_staticlib(&dir, "fuzzbench")
|
||||
|
@ -60,6 +60,8 @@ pub struct ClangWrapper {
|
||||
linking: bool,
|
||||
x_set: bool,
|
||||
bit_mode: u32,
|
||||
need_libafl_arg: bool,
|
||||
has_libafl_arg: bool,
|
||||
|
||||
from_args_called: bool,
|
||||
base_args: Vec<String>,
|
||||
@ -112,6 +114,11 @@ impl CompilerWrapper for ClangWrapper {
|
||||
match arg.as_ref() {
|
||||
"--libafl-no-link" => {
|
||||
linking = false;
|
||||
self.has_libafl_arg = true;
|
||||
continue;
|
||||
}
|
||||
"--libafl" => {
|
||||
self.has_libafl_arg = true;
|
||||
continue;
|
||||
}
|
||||
"-x" => self.x_set = true,
|
||||
@ -207,6 +214,10 @@ impl CompilerWrapper for ClangWrapper {
|
||||
args.push(self.wrapped_cc.clone());
|
||||
}
|
||||
args.extend_from_slice(self.base_args.as_slice());
|
||||
if self.need_libafl_arg && !self.has_libafl_arg {
|
||||
return Ok(args);
|
||||
}
|
||||
|
||||
if !self.passes.is_empty() {
|
||||
args.push("-fno-experimental-new-pass-manager".into());
|
||||
}
|
||||
@ -270,6 +281,8 @@ impl ClangWrapper {
|
||||
linking: false,
|
||||
x_set: false,
|
||||
bit_mode: 0,
|
||||
need_libafl_arg: false,
|
||||
has_libafl_arg: false,
|
||||
from_args_called: false,
|
||||
base_args: vec![],
|
||||
cc_args: vec![],
|
||||
@ -308,6 +321,18 @@ impl ClangWrapper {
|
||||
self.passes.push(pass);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set if linking
|
||||
pub fn linking(&mut self, value: bool) -> &'_ mut Self {
|
||||
self.linking = value;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set if it needs the --libafl arg to add the custom arguments to clang
|
||||
pub fn need_libafl_arg(&mut self, value: bool) -> &'_ mut Self {
|
||||
self.need_libafl_arg = value;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user