-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from AFLplusplus/upd_and_stub
MOpt
- Loading branch information
Showing
10 changed files
with
416 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "mopt" | ||
version = "0.0.1" | ||
authors = ["Andrea Fioraldi <[email protected]>", "Dominik Maier <[email protected]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
libafl = { path = "../LibAFL/libafl/" } | ||
libafl_targets = { path = "../LibAFL/libafl_targets/", features = ["sancov_pcguard_hitcounts", "libfuzzer"] } | ||
# TODO Include it only when building cc | ||
libafl_cc = { path = "../LibAFL/libafl_cc/" } | ||
clap = { version = "4.0", features = ["default"] } | ||
nix = "0.26" | ||
mimalloc = { version = "*", default-features = false } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses}; | ||
use std::env; | ||
|
||
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(); | ||
|
||
#[cfg(target_os = "linux")] | ||
cc.add_pass(LLVMPasses::AutoTokens); | ||
|
||
if let Some(code) = cc | ||
.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) | ||
.parse_args(&args) | ||
.expect("Failed to parse the command line") | ||
.link_staticlib(&dir, env!("CARGO_PKG_NAME")) | ||
.add_arg("-fsanitize-coverage=trace-pc-guard") | ||
.run() | ||
.expect("Failed to run the wrapped compiler") | ||
{ | ||
std::process::exit(code); | ||
} | ||
} else { | ||
panic!("LibAFL CC: No Arguments given"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub mod mopt_cc; | ||
|
||
fn main() { | ||
mopt_cc::main() | ||
} |
Oops, something went wrong.