fixes for pcguard and value profile

This commit is contained in:
Andrea Fioraldi 2021-03-29 15:57:27 +02:00
parent 0c2a267075
commit b4e6115d4f
3 changed files with 8 additions and 12 deletions

View File

@ -10,15 +10,11 @@ members = [
"libafl_derive",
"libafl_cc",
"libafl_targets",
#example fuzzers
"fuzzers/libfuzzer_libmozjpeg",
"fuzzers/libfuzzer_libpng_cmpalloc",
"fuzzers/libfuzzer_windows",
]
exclude = [
"fuzzers/libfuzzer_libpng",
"fuzzers/libfuzzer_stb_image",
"fuzzers/libfuzzer_libmozjpeg",
"fuzzers/frida_libpng",
"fuzzers/qemu_user",
]

View File

@ -4,10 +4,10 @@ compile_error!(
);
// TODO compile time flag
pub const MAP_SIZE: usize = 65536;
pub const EDGES_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 EDGES_MAP: [u8; EDGES_MAP_SIZE] = [0; EDGES_MAP_SIZE];
//pub static mut CMP_MAP: [u8; EDGES_MAP_SIZE] = [0; EDGES_MAP_SIZE];
pub static mut MAX_EDGES_NUM: usize = 0;
#[no_mangle]
@ -32,7 +32,7 @@ pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard_init(mut start: *mut u32
while start < stop {
MAX_EDGES_NUM += 1;
*start = (MAX_EDGES_NUM & (MAP_SIZE - 1)) as u32;
*start = (MAX_EDGES_NUM & (EDGES_MAP_SIZE - 1)) as u32;
start = start.offset(1);
}
}

View File

@ -1,8 +1,8 @@
// TODO compile time flag
pub const MAP_SIZE: usize = 65536;
pub const CMP_MAP_SIZE: usize = 65536;
#[no_mangle]
pub static mut libafl_cmp_map: [u8; MAP_SIZE] = [0; MAP_SIZE];
pub static mut libafl_cmp_map: [u8; CMP_MAP_SIZE] = [0; CMP_MAP_SIZE];
pub use libafl_cmp_map as CMP_MAP;
@ -16,7 +16,7 @@ extern {
pub unsafe extern "C" fn __sanitizer_cov_trace_cmp1(arg1: u8, arg2: u8) {
let mut pos = return_address();
pos = (pos >> 4) ^ (pos << 8);
pos &= MAP_SIZE - 1;
pos &= CMP_MAP_SIZE - 1;
*CMP_MAP.get_unchecked_mut(pos) = core::cmp::max(*CMP_MAP.get_unchecked(pos), (!(arg1 ^ arg2)).count_ones() as u8);
}
*/