diff --git a/fuzzers/fuzzbench/src/bin/libafl_cc.rs b/fuzzers/fuzzbench/src/bin/libafl_cc.rs index 29ed3e3757..c84bfceddd 100644 --- a/fuzzers/fuzzbench/src/bin/libafl_cc.rs +++ b/fuzzers/fuzzbench/src/bin/libafl_cc.rs @@ -21,12 +21,12 @@ pub fn main() { // silence the compiler wrapper output, needed for some configure scripts. .silence(true) .from_args(&args) - .expect("Failed to parse the command line".into()) + .expect("Failed to parse the command line") .link_staticlib(&dir, "fuzzbench") .add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp") .add_pass(LLVMPasses::CmpLogRtn) .run() - .expect("Failed to run the wrapped compiler".into()) + .expect("Failed to run the wrapped compiler") { std::process::exit(code); } diff --git a/fuzzers/generic_inmemory/src/bin/libafl_cc.rs b/fuzzers/generic_inmemory/src/bin/libafl_cc.rs index 2bee42e73d..a45c3fea9a 100644 --- a/fuzzers/generic_inmemory/src/bin/libafl_cc.rs +++ b/fuzzers/generic_inmemory/src/bin/libafl_cc.rs @@ -21,12 +21,12 @@ pub fn main() { // silence the compiler wrapper output, needed for some configure scripts. .silence(true) .from_args(&args) - .expect("Failed to parse the command line".into()) + .expect("Failed to parse the command line") .link_staticlib(&dir, "generic_inmemory") .add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp") .add_pass(LLVMPasses::CmpLogRtn) .run() - .expect("Failed to run the wrapped compiler".into()) + .expect("Failed to run the wrapped compiler") { std::process::exit(code); } diff --git a/fuzzers/libfuzzer_libmozjpeg/src/bin/libafl_cc.rs b/fuzzers/libfuzzer_libmozjpeg/src/bin/libafl_cc.rs index 1e5cd6d3dc..f4ebb8a4b9 100644 --- a/fuzzers/libfuzzer_libmozjpeg/src/bin/libafl_cc.rs +++ b/fuzzers/libfuzzer_libmozjpeg/src/bin/libafl_cc.rs @@ -21,11 +21,11 @@ pub fn main() { // silence the compiler wrapper output, needed for some configure scripts. .silence(true) .from_args(&args) - .expect("Failed to parse the command line".into()) + .expect("Failed to parse the command line") .link_staticlib(&dir, "libfuzzer_libmozjpeg") .add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp") .run() - .expect("Failed to run the wrapped compiler".into()) + .expect("Failed to run the wrapped compiler") { std::process::exit(code); } diff --git a/fuzzers/libfuzzer_libpng/src/bin/libafl_cc.rs b/fuzzers/libfuzzer_libpng/src/bin/libafl_cc.rs index 1c5dcd51a5..a860154614 100644 --- a/fuzzers/libfuzzer_libpng/src/bin/libafl_cc.rs +++ b/fuzzers/libfuzzer_libpng/src/bin/libafl_cc.rs @@ -21,11 +21,11 @@ pub fn main() { // silence the compiler wrapper output, needed for some configure scripts. .silence(true) .from_args(&args) - .expect("Failed to parse the command line".into()) + .expect("Failed to parse the command line") .link_staticlib(&dir, "libfuzzer_libpng") .add_arg("-fsanitize-coverage=trace-pc-guard") .run() - .expect("Failed to run the wrapped compiler".into()) + .expect("Failed to run the wrapped compiler") { std::process::exit(code); } diff --git a/fuzzers/libfuzzer_libpng_launcher/src/bin/libafl_cc.rs b/fuzzers/libfuzzer_libpng_launcher/src/bin/libafl_cc.rs index 1c5dcd51a5..a860154614 100644 --- a/fuzzers/libfuzzer_libpng_launcher/src/bin/libafl_cc.rs +++ b/fuzzers/libfuzzer_libpng_launcher/src/bin/libafl_cc.rs @@ -21,11 +21,11 @@ pub fn main() { // silence the compiler wrapper output, needed for some configure scripts. .silence(true) .from_args(&args) - .expect("Failed to parse the command line".into()) + .expect("Failed to parse the command line") .link_staticlib(&dir, "libfuzzer_libpng") .add_arg("-fsanitize-coverage=trace-pc-guard") .run() - .expect("Failed to run the wrapped compiler".into()) + .expect("Failed to run the wrapped compiler") { std::process::exit(code); } diff --git a/fuzzers/libfuzzer_reachability/src/bin/libafl_cc.rs b/fuzzers/libfuzzer_reachability/src/bin/libafl_cc.rs index 1c5dcd51a5..a860154614 100644 --- a/fuzzers/libfuzzer_reachability/src/bin/libafl_cc.rs +++ b/fuzzers/libfuzzer_reachability/src/bin/libafl_cc.rs @@ -21,11 +21,11 @@ pub fn main() { // silence the compiler wrapper output, needed for some configure scripts. .silence(true) .from_args(&args) - .expect("Failed to parse the command line".into()) + .expect("Failed to parse the command line") .link_staticlib(&dir, "libfuzzer_libpng") .add_arg("-fsanitize-coverage=trace-pc-guard") .run() - .expect("Failed to run the wrapped compiler".into()) + .expect("Failed to run the wrapped compiler") { std::process::exit(code); } diff --git a/libafl_targets/src/common.h b/libafl_targets/src/common.h index 2a62db6b57..90d56e930e 100644 --- a/libafl_targets/src/common.h +++ b/libafl_targets/src/common.h @@ -73,6 +73,9 @@ #define CHECK_WEAK_FN(Name) (Name != NULL) #endif // _MSC_VER +#define EXT_FUNC_DEF(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ + EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) + #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ RETURN_TYPE (*NAME##Def) FUNC_SIG = NULL; \ EXTERNAL_FUNC(NAME, NAME##Def) RETURN_TYPE NAME FUNC_SIG @@ -80,9 +83,16 @@ #if defined(__APPLE__) // TODO: Find a proper way to deal with weak fns on Apple! + #define EXT_FUNC_DEF(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ + EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) { return 0; } + #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ - RETURN_TYPE NAME FUNC_SIG __attribute__((weak_import)) { return 0; } + RETURN_TYPE NAME FUNC_SIG __attribute__((weak_import)) #else + +#define EXT_FUNC_DEF(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ + EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) + // Declare these symbols as weak to allow them to be optionally defined. #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ __attribute__((weak, visibility("default"))) RETURN_TYPE NAME FUNC_SIG diff --git a/libafl_targets/src/libfuzzer_compatibility.c b/libafl_targets/src/libfuzzer_compatibility.c index dee0bfdac1..7cf68d2955 100644 --- a/libafl_targets/src/libfuzzer_compatibility.c +++ b/libafl_targets/src/libfuzzer_compatibility.c @@ -3,16 +3,16 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" -EXT_FUNC(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false); -EXT_FUNC(LLVMFuzzerCustomMutator, size_t, +EXT_FUNC_DEF(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false); +EXT_FUNC_DEF(LLVMFuzzerCustomMutator, size_t, (uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed), false); -EXT_FUNC(LLVMFuzzerCustomCrossOver, size_t, +EXT_FUNC_DEF(LLVMFuzzerCustomCrossOver, size_t, (const uint8_t *Data1, size_t Size1, const uint8_t *Data2, size_t Size2, uint8_t *Out, size_t MaxOutSize, unsigned int Seed), false); -EXT_FUNC(LLVMFuzzerTestOneInput, int, (uint8_t *Data, size_t Size), false); +EXT_FUNC_DEF(LLVMFuzzerTestOneInput, int, (uint8_t *Data, size_t Size), false); void libafl_main(); EXT_FUNC(main, int, (int argc, char** argv), false) {