macos fixes

This commit is contained in:
Dominik Maier 2021-06-28 16:18:17 +02:00
parent 8056cbe5cb
commit e479b4fa24
8 changed files with 27 additions and 17 deletions

View File

@ -21,12 +21,12 @@ pub fn main() {
// silence the compiler wrapper output, needed for some configure scripts. // silence the compiler wrapper output, needed for some configure scripts.
.silence(true) .silence(true)
.from_args(&args) .from_args(&args)
.expect("Failed to parse the command line".into()) .expect("Failed to parse the command line")
.link_staticlib(&dir, "fuzzbench") .link_staticlib(&dir, "fuzzbench")
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp") .add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
.add_pass(LLVMPasses::CmpLogRtn) .add_pass(LLVMPasses::CmpLogRtn)
.run() .run()
.expect("Failed to run the wrapped compiler".into()) .expect("Failed to run the wrapped compiler")
{ {
std::process::exit(code); std::process::exit(code);
} }

View File

@ -21,12 +21,12 @@ pub fn main() {
// silence the compiler wrapper output, needed for some configure scripts. // silence the compiler wrapper output, needed for some configure scripts.
.silence(true) .silence(true)
.from_args(&args) .from_args(&args)
.expect("Failed to parse the command line".into()) .expect("Failed to parse the command line")
.link_staticlib(&dir, "generic_inmemory") .link_staticlib(&dir, "generic_inmemory")
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp") .add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
.add_pass(LLVMPasses::CmpLogRtn) .add_pass(LLVMPasses::CmpLogRtn)
.run() .run()
.expect("Failed to run the wrapped compiler".into()) .expect("Failed to run the wrapped compiler")
{ {
std::process::exit(code); std::process::exit(code);
} }

View File

@ -21,11 +21,11 @@ pub fn main() {
// silence the compiler wrapper output, needed for some configure scripts. // silence the compiler wrapper output, needed for some configure scripts.
.silence(true) .silence(true)
.from_args(&args) .from_args(&args)
.expect("Failed to parse the command line".into()) .expect("Failed to parse the command line")
.link_staticlib(&dir, "libfuzzer_libmozjpeg") .link_staticlib(&dir, "libfuzzer_libmozjpeg")
.add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp") .add_arg("-fsanitize-coverage=trace-pc-guard,trace-cmp")
.run() .run()
.expect("Failed to run the wrapped compiler".into()) .expect("Failed to run the wrapped compiler")
{ {
std::process::exit(code); std::process::exit(code);
} }

View File

@ -21,11 +21,11 @@ pub fn main() {
// silence the compiler wrapper output, needed for some configure scripts. // silence the compiler wrapper output, needed for some configure scripts.
.silence(true) .silence(true)
.from_args(&args) .from_args(&args)
.expect("Failed to parse the command line".into()) .expect("Failed to parse the command line")
.link_staticlib(&dir, "libfuzzer_libpng") .link_staticlib(&dir, "libfuzzer_libpng")
.add_arg("-fsanitize-coverage=trace-pc-guard") .add_arg("-fsanitize-coverage=trace-pc-guard")
.run() .run()
.expect("Failed to run the wrapped compiler".into()) .expect("Failed to run the wrapped compiler")
{ {
std::process::exit(code); std::process::exit(code);
} }

View File

@ -21,11 +21,11 @@ pub fn main() {
// silence the compiler wrapper output, needed for some configure scripts. // silence the compiler wrapper output, needed for some configure scripts.
.silence(true) .silence(true)
.from_args(&args) .from_args(&args)
.expect("Failed to parse the command line".into()) .expect("Failed to parse the command line")
.link_staticlib(&dir, "libfuzzer_libpng") .link_staticlib(&dir, "libfuzzer_libpng")
.add_arg("-fsanitize-coverage=trace-pc-guard") .add_arg("-fsanitize-coverage=trace-pc-guard")
.run() .run()
.expect("Failed to run the wrapped compiler".into()) .expect("Failed to run the wrapped compiler")
{ {
std::process::exit(code); std::process::exit(code);
} }

View File

@ -21,11 +21,11 @@ pub fn main() {
// silence the compiler wrapper output, needed for some configure scripts. // silence the compiler wrapper output, needed for some configure scripts.
.silence(true) .silence(true)
.from_args(&args) .from_args(&args)
.expect("Failed to parse the command line".into()) .expect("Failed to parse the command line")
.link_staticlib(&dir, "libfuzzer_libpng") .link_staticlib(&dir, "libfuzzer_libpng")
.add_arg("-fsanitize-coverage=trace-pc-guard") .add_arg("-fsanitize-coverage=trace-pc-guard")
.run() .run()
.expect("Failed to run the wrapped compiler".into()) .expect("Failed to run the wrapped compiler")
{ {
std::process::exit(code); std::process::exit(code);
} }

View File

@ -73,6 +73,9 @@
#define CHECK_WEAK_FN(Name) (Name != NULL) #define CHECK_WEAK_FN(Name) (Name != NULL)
#endif // _MSC_VER #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) \ #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
RETURN_TYPE (*NAME##Def) FUNC_SIG = NULL; \ RETURN_TYPE (*NAME##Def) FUNC_SIG = NULL; \
EXTERNAL_FUNC(NAME, NAME##Def) RETURN_TYPE NAME FUNC_SIG EXTERNAL_FUNC(NAME, NAME##Def) RETURN_TYPE NAME FUNC_SIG
@ -80,9 +83,16 @@
#if defined(__APPLE__) #if defined(__APPLE__)
// TODO: Find a proper way to deal with weak fns on 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) \ #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 #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. // Declare these symbols as weak to allow them to be optionally defined.
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
__attribute__((weak, visibility("default"))) RETURN_TYPE NAME FUNC_SIG __attribute__((weak, visibility("default"))) RETURN_TYPE NAME FUNC_SIG

View File

@ -3,16 +3,16 @@
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
EXT_FUNC(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false); EXT_FUNC_DEF(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false);
EXT_FUNC(LLVMFuzzerCustomMutator, size_t, EXT_FUNC_DEF(LLVMFuzzerCustomMutator, size_t,
(uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed), (uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed),
false); false);
EXT_FUNC(LLVMFuzzerCustomCrossOver, size_t, EXT_FUNC_DEF(LLVMFuzzerCustomCrossOver, size_t,
(const uint8_t *Data1, size_t Size1, (const uint8_t *Data1, size_t Size1,
const uint8_t *Data2, size_t Size2, const uint8_t *Data2, size_t Size2,
uint8_t *Out, size_t MaxOutSize, unsigned int Seed), uint8_t *Out, size_t MaxOutSize, unsigned int Seed),
false); 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(); void libafl_main();
EXT_FUNC(main, int, (int argc, char** argv), false) { EXT_FUNC(main, int, (int argc, char** argv), false) {