skeleton for libafl_cc
This commit is contained in:
parent
5f74a08316
commit
61a89f4aa6
@ -8,6 +8,7 @@ debug = true
|
|||||||
members = [
|
members = [
|
||||||
"libafl",
|
"libafl",
|
||||||
"libafl_derive",
|
"libafl_derive",
|
||||||
|
"libafl_cc",
|
||||||
|
|
||||||
#example fuzzers
|
#example fuzzers
|
||||||
"fuzzers/libfuzzer_libpng",
|
"fuzzers/libfuzzer_libpng",
|
||||||
|
9
libafl_cc/Cargo.toml
Normal file
9
libafl_cc/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "libafl_cc"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
3
libafl_cc/src/bin/libafl-cc.rs
Normal file
3
libafl_cc/src/bin/libafl-cc.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
todo!("libafl-cc");
|
||||||
|
}
|
9
libafl_cc/src/lib.rs
Normal file
9
libafl_cc/src/lib.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pub mod runtime;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
assert_eq!(2 + 2, 4);
|
||||||
|
}
|
||||||
|
}
|
23
libafl_cc/src/runtime.rs
Normal file
23
libafl_cc/src/runtime.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
pub const MAP_SIZE: usize = 65536;
|
||||||
|
|
||||||
|
pub static mut EDGES_MAP: [u8; MAP_SIZE] = [0; MAP_SIZE];
|
||||||
|
pub static mut CMP_MAP: [u8; MAP_SIZE] = [0; MAP_SIZE];
|
||||||
|
pub static mut MAX_EDGES_NUM: usize = 0;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard(guard: *mut u32) {
|
||||||
|
let pos = *guard as usize;
|
||||||
|
let val = (EDGES_MAP[pos] as u8).wrapping_add(1);
|
||||||
|
EDGES_MAP[pos] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard_init(mut start: *mut u32, stop: *mut u32) {
|
||||||
|
if start == stop || *start != 0 { return }
|
||||||
|
|
||||||
|
while start < stop {
|
||||||
|
MAX_EDGES_NUM += 1;
|
||||||
|
*start = (MAX_EDGES_NUM & (MAP_SIZE -1)) as u32;
|
||||||
|
start = start.offset(1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user