MSVC fixes
This commit is contained in:
parent
8e544c59c6
commit
4747a35936
@ -6,8 +6,12 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define posix_memalign(p, a, s) (((*(p)) = _aligned_malloc((s), (a))), *(p) ?0 :errno)
|
#define posix_memalign(p, a, s) (((*(p)) = _aligned_malloc((s), (a))), *(p) ?0 :errno)
|
||||||
|
#define RETADDR (uintptr_t)_ReturnAddress()
|
||||||
|
#else
|
||||||
|
#define RETADDR (uintptr_t)__builtin_return_address(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
#define MAX(a, b) \
|
#define MAX(a, b) \
|
||||||
({ \
|
({ \
|
||||||
\
|
\
|
||||||
@ -16,12 +20,15 @@
|
|||||||
_a > _b ? _a : _b; \
|
_a > _b ? _a : _b; \
|
||||||
\
|
\
|
||||||
})
|
})
|
||||||
|
#else
|
||||||
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t libafl_alloc_map[MAP_SIZE];
|
size_t libafl_alloc_map[MAP_SIZE];
|
||||||
|
|
||||||
void *malloc(size_t size) {
|
void *malloc(size_t size) {
|
||||||
|
|
||||||
uintptr_t k = (uintptr_t)__builtin_return_address(0);
|
uintptr_t k = RETADDR;
|
||||||
k = (k >> 4) ^ (k << 8);
|
k = (k >> 4) ^ (k << 8);
|
||||||
k &= MAP_SIZE - 1;
|
k &= MAP_SIZE - 1;
|
||||||
libafl_alloc_map[k] = MAX(libafl_alloc_map[k], size);
|
libafl_alloc_map[k] = MAX(libafl_alloc_map[k], size);
|
||||||
@ -39,7 +46,7 @@ void *calloc(size_t nmemb, size_t size) {
|
|||||||
|
|
||||||
size *= nmemb;
|
size *= nmemb;
|
||||||
|
|
||||||
uintptr_t k = (uintptr_t)__builtin_return_address(0);
|
uintptr_t k = RETADDR;
|
||||||
k = (k >> 4) ^ (k << 8);
|
k = (k >> 4) ^ (k << 8);
|
||||||
k &= MAP_SIZE - 1;
|
k &= MAP_SIZE - 1;
|
||||||
libafl_alloc_map[k] = MAX(libafl_alloc_map[k], size);
|
libafl_alloc_map[k] = MAX(libafl_alloc_map[k], size);
|
||||||
|
@ -100,8 +100,9 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
|
|||||||
let mutator = StdScheduledMutator::new(havoc_mutations());
|
let mutator = StdScheduledMutator::new(havoc_mutations());
|
||||||
let stage = StdMutationalStage::new(mutator);
|
let stage = StdMutationalStage::new(mutator);
|
||||||
|
|
||||||
|
// A random policy to get testcasess from the corpus
|
||||||
let scheduler = RandCorpusScheduler::new();
|
let scheduler = RandCorpusScheduler::new();
|
||||||
// A fuzzer with just one stage and a random policy to get testcasess from the corpus
|
// A fuzzer with just one stage
|
||||||
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));
|
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));
|
||||||
|
|
||||||
// The wrapped harness function, calling out to the LLVM-style harness
|
// The wrapped harness function, calling out to the LLVM-style harness
|
||||||
@ -110,7 +111,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
|
|||||||
ExitKind::Ok
|
ExitKind::Ok
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the executor for an in-process function with just one observer for edge coverage
|
// Create the executor for an in-process function with observers for edge coverage, value-profile and allocations sizes
|
||||||
let mut executor = InProcessExecutor::new(
|
let mut executor = InProcessExecutor::new(
|
||||||
"in-process(edges,cmp,alloc)",
|
"in-process(edges,cmp,alloc)",
|
||||||
&mut harness,
|
&mut harness,
|
||||||
|
@ -106,7 +106,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
|
|||||||
let mutator = StdScheduledMutator::new(havoc_mutations());
|
let mutator = StdScheduledMutator::new(havoc_mutations());
|
||||||
let stage = StdMutationalStage::new(mutator);
|
let stage = StdMutationalStage::new(mutator);
|
||||||
|
|
||||||
// A fuzzer with just one stage and a minimization+queue policy to get testcasess from the corpus
|
// A fuzzer with just one stage
|
||||||
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));
|
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));
|
||||||
|
|
||||||
// A minimization+queue policy to get testcasess from the corpus
|
// A minimization+queue policy to get testcasess from the corpus
|
||||||
@ -118,7 +118,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
|
|||||||
ExitKind::Ok
|
ExitKind::Ok
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the executor for an in-process function with just one observer for edge coverage
|
// Create the executor for an in-process function with one observer for edge coverage and one for the execution time
|
||||||
let mut executor = TimeoutExecutor::new(
|
let mut executor = TimeoutExecutor::new(
|
||||||
InProcessExecutor::new(
|
InProcessExecutor::new(
|
||||||
"in-process(edges,time)",
|
"in-process(edges,time)",
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
extern uint8_t libafl_cmp_map[MAP_SIZE];
|
extern uint8_t libafl_cmp_map[MAP_SIZE];
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
#define MAX(a, b) \
|
#define MAX(a, b) \
|
||||||
({ \
|
({ \
|
||||||
\
|
\
|
||||||
@ -15,12 +16,20 @@ extern uint8_t libafl_cmp_map[MAP_SIZE];
|
|||||||
_a > _b ? _a : _b; \
|
_a > _b ? _a : _b; \
|
||||||
\
|
\
|
||||||
})
|
})
|
||||||
|
#else
|
||||||
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#pragma weak __sanitizer_cov_trace_const_cmp1 = __sanitizer_cov_trace_cmp1
|
#pragma weak __sanitizer_cov_trace_const_cmp1 = __sanitizer_cov_trace_cmp1
|
||||||
#pragma weak __sanitizer_cov_trace_const_cmp2 = __sanitizer_cov_trace_cmp2
|
#pragma weak __sanitizer_cov_trace_const_cmp2 = __sanitizer_cov_trace_cmp2
|
||||||
#pragma weak __sanitizer_cov_trace_const_cmp4 = __sanitizer_cov_trace_cmp4
|
#pragma weak __sanitizer_cov_trace_const_cmp4 = __sanitizer_cov_trace_cmp4
|
||||||
#pragma weak __sanitizer_cov_trace_const_cmp8 = __sanitizer_cov_trace_cmp8
|
#pragma weak __sanitizer_cov_trace_const_cmp8 = __sanitizer_cov_trace_cmp8
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#pragma comment(linker, "/alternatename:__sanitizer_cov_trace_const_cmp1=__sanitizer_cov_trace_cmp1")
|
||||||
|
#pragma comment(linker, "/alternatename:__sanitizer_cov_trace_const_cmp2=__sanitizer_cov_trace_cmp2")
|
||||||
|
#pragma comment(linker, "/alternatename:__sanitizer_cov_trace_const_cmp4=__sanitizer_cov_trace_cmp4")
|
||||||
|
#pragma comment(linker, "/alternatename:__sanitizer_cov_trace_const_cmp8=__sanitizer_cov_trace_cmp8")
|
||||||
#else
|
#else
|
||||||
void __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) __attribute__((alias("__sanitizer_cov_trace_cmp1")));
|
void __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) __attribute__((alias("__sanitizer_cov_trace_cmp1")));
|
||||||
void __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2)
|
void __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user