37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
use std::env;
|
|
|
|
use libafl_cc::{ClangWrapper, CompilerWrapper};
|
|
|
|
pub fn main() {
|
|
let args: Vec<String> = env::args().collect();
|
|
if args.len() > 1 {
|
|
let mut dir = env::current_exe().unwrap();
|
|
let wrapper_name = dir.file_name().unwrap().to_str().unwrap();
|
|
|
|
let is_cpp = match wrapper_name[wrapper_name.len()-2..].to_lowercase().as_str() {
|
|
"cc" => false,
|
|
"++" | "pp" | "xx" => true,
|
|
_ => panic!("Could not figure out if c or c++ warpper was called. Expected {:?} to end with c or cxx", dir),
|
|
};
|
|
|
|
dir.pop();
|
|
|
|
let mut cc = ClangWrapper::new();
|
|
if let Some(code) = cc
|
|
.cpp(is_cpp)
|
|
// silence the compiler wrapper output, needed for some configure scripts.
|
|
.silence(true)
|
|
.parse_args(&args)
|
|
.expect("Failed to parse the command line")
|
|
.link_staticlib(&dir, "libfuzzer_libmozjpeg")
|
|
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
|
|
.run()
|
|
.expect("Failed to run the wrapped compiler")
|
|
{
|
|
std::process::exit(code);
|
|
}
|
|
} else {
|
|
panic!("LibAFL CC: No Arguments given");
|
|
}
|
|
}
|