mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-15 19:38:09 +00:00
support LLVMFuzzerTestOneInput archive targets
This commit is contained in:
@ -7,6 +7,8 @@
|
|||||||
### Version ++4.31a (dev)
|
### Version ++4.31a (dev)
|
||||||
- loose file and shared memory permissions on Android and iPhone
|
- loose file and shared memory permissions on Android and iPhone
|
||||||
- afl-cc:
|
- afl-cc:
|
||||||
|
- -fsanitize=fuzzer now inserts libAFLDriver.a addtionally early to help
|
||||||
|
compiling if LLVMFuzzerTestOneOnput is in an .a archive
|
||||||
- added __sanitizer_weak_hook_* functions (in case that is helpful in
|
- added __sanitizer_weak_hook_* functions (in case that is helpful in
|
||||||
weird setups)
|
weird setups)
|
||||||
|
|
||||||
|
78
src/afl-cc.c
78
src/afl-cc.c
@ -1764,6 +1764,41 @@ static u8 fsanitize_fuzzer_comma(char *string) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add params to link with libAFLDriver.a on request */
|
||||||
|
static void add_aflpplib(aflcc_state_t *aflcc) {
|
||||||
|
|
||||||
|
if (!aflcc->need_aflpplib) return;
|
||||||
|
|
||||||
|
u8 *afllib = find_object(aflcc, "libAFLDriver.a");
|
||||||
|
|
||||||
|
if (!be_quiet) {
|
||||||
|
|
||||||
|
OKF("Found '-fsanitize=fuzzer', replacing with libAFLDriver.a");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!afllib) {
|
||||||
|
|
||||||
|
if (!be_quiet) {
|
||||||
|
|
||||||
|
WARNF(
|
||||||
|
"Cannot find 'libAFLDriver.a' to replace '-fsanitize=fuzzer' in "
|
||||||
|
"the flags - this will fail!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
insert_param(aflcc, afllib);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
insert_param(aflcc, "-Wl,-undefined,dynamic_lookup");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Parse and process possible -fsanitize related args, return PARAM_MISS
|
Parse and process possible -fsanitize related args, return PARAM_MISS
|
||||||
if nothing matched. We have 3 main tasks here for these args:
|
if nothing matched. We have 3 main tasks here for these args:
|
||||||
@ -1777,6 +1812,7 @@ static u8 fsanitize_fuzzer_comma(char *string) {
|
|||||||
param_st parse_fsanitize(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
|
param_st parse_fsanitize(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
|
||||||
|
|
||||||
param_st final_ = PARAM_MISS;
|
param_st final_ = PARAM_MISS;
|
||||||
|
u8 insert = 0;
|
||||||
|
|
||||||
// MACRO START
|
// MACRO START
|
||||||
#define HAVE_SANITIZER_SCAN_KEEP(v, k) \
|
#define HAVE_SANITIZER_SCAN_KEEP(v, k) \
|
||||||
@ -1822,6 +1858,7 @@ param_st parse_fsanitize(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
|
|||||||
if (scan) {
|
if (scan) {
|
||||||
|
|
||||||
aflcc->need_aflpplib = 1;
|
aflcc->need_aflpplib = 1;
|
||||||
|
insert = 1;
|
||||||
final_ = PARAM_SCAN;
|
final_ = PARAM_SCAN;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1842,6 +1879,7 @@ param_st parse_fsanitize(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
|
|||||||
if (fsanitize_fuzzer_comma(cur_argv_)) {
|
if (fsanitize_fuzzer_comma(cur_argv_)) {
|
||||||
|
|
||||||
aflcc->need_aflpplib = 1;
|
aflcc->need_aflpplib = 1;
|
||||||
|
insert = 1;
|
||||||
final_ = PARAM_SCAN;
|
final_ = PARAM_SCAN;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1882,7 +1920,8 @@ param_st parse_fsanitize(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (final_ == PARAM_KEEP) insert_param(aflcc, cur_argv);
|
if (final_ == PARAM_KEEP) { insert_param(aflcc, cur_argv); }
|
||||||
|
if (insert) { add_aflpplib(aflcc); }
|
||||||
|
|
||||||
return final_;
|
return final_;
|
||||||
|
|
||||||
@ -2352,41 +2391,6 @@ void add_lto_passes(aflcc_state_t *aflcc) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add params to link with libAFLDriver.a on request */
|
|
||||||
static void add_aflpplib(aflcc_state_t *aflcc) {
|
|
||||||
|
|
||||||
if (!aflcc->need_aflpplib) return;
|
|
||||||
|
|
||||||
u8 *afllib = find_object(aflcc, "libAFLDriver.a");
|
|
||||||
|
|
||||||
if (!be_quiet) {
|
|
||||||
|
|
||||||
OKF("Found '-fsanitize=fuzzer', replacing with libAFLDriver.a");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!afllib) {
|
|
||||||
|
|
||||||
if (!be_quiet) {
|
|
||||||
|
|
||||||
WARNF(
|
|
||||||
"Cannot find 'libAFLDriver.a' to replace '-fsanitize=fuzzer' in "
|
|
||||||
"the flags - this will fail!");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
insert_param(aflcc, afllib);
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
insert_param(aflcc, "-Wl,-undefined,dynamic_lookup");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add params to link with runtimes depended by our instrumentation */
|
/* Add params to link with runtimes depended by our instrumentation */
|
||||||
void add_runtime(aflcc_state_t *aflcc) {
|
void add_runtime(aflcc_state_t *aflcc) {
|
||||||
|
|
||||||
@ -2479,7 +2483,7 @@ void add_runtime(aflcc_state_t *aflcc) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
add_aflpplib(aflcc);
|
add_aflpplib(aflcc); // double insertion helps compiling
|
||||||
|
|
||||||
#if defined(USEMMAP) && !defined(__HAIKU__) && !__APPLE__
|
#if defined(USEMMAP) && !defined(__HAIKU__) && !__APPLE__
|
||||||
insert_param(aflcc, "-Wl,-lrt");
|
insert_param(aflcc, "-Wl,-lrt");
|
||||||
|
Reference in New Issue
Block a user