From bc7dea2faca30ddf896f5e7a37ba10e3552eec9f Mon Sep 17 00:00:00 2001 From: Robert Swiecki Date: Wed, 15 May 2019 21:58:23 +0200 Subject: [PATCH] hfuzz-cc: mark HonggfuzzNetDriver_main as undefined but don't define it in the netdriver --- hfuzz_cc/hfuzz-cc.c | 2 ++ libhfnetdriver/netdriver.c | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/hfuzz_cc/hfuzz-cc.c b/hfuzz_cc/hfuzz-cc.c index f4cae56f8..288d04065 100644 --- a/hfuzz_cc/hfuzz-cc.c +++ b/hfuzz_cc/hfuzz-cc.c @@ -395,9 +395,11 @@ static int ldMode(int argc, char** argv) { /* Pull modules defining the following symbols (if they exist) */ #ifdef _HF_ARCH_DARWIN + args[j++] = "-Wl,-U,_HonggfuzzNetDriver_main"; args[j++] = "-Wl,-U,_LIBHFUZZ_module_instrument"; args[j++] = "-Wl,-U,_LIBHFUZZ_module_memorycmp"; #else /* _HF_ARCH_DARWIN */ + args[j++] = "-Wl,-u,HonggfuzzNetDriver_main"; args[j++] = "-Wl,-u,LIBHFUZZ_module_instrument"; args[j++] = "-Wl,-u,LIBHFUZZ_module_memorycmp"; #endif /* _HF_ARCH_DARWIN */ diff --git a/libhfnetdriver/netdriver.c b/libhfnetdriver/netdriver.c index d71f195b8..2b4f1ea8b 100644 --- a/libhfnetdriver/netdriver.c +++ b/libhfnetdriver/netdriver.c @@ -44,11 +44,7 @@ static struct { .sa_family = AF_UNSPEC, }; -__attribute__((weak)) int HonggfuzzNetDriver_main( - int argc HF_ATTR_UNUSED, char **argv HF_ATTR_UNUSED) { - LOG_F("The HonggfuzzNetDriver_main function was not defined in your code"); - return EXIT_FAILURE; -} +extern int HonggfuzzNetDriver_main(int argc, char **argv); static void *netDriver_mainProgram(void *unused HF_ATTR_UNUSED) { int ret = HonggfuzzNetDriver_main(hfnd_globals.argc_server, hfnd_globals.argv_server); @@ -288,11 +284,6 @@ __attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv) { LOG_I( "Honggfuzz Net Driver (pid=%d): '%s' is set, skipping fuzzing, calling main() directly", getpid(), HFND_SKIP_FUZZING_ENV); - if (!HonggfuzzNetDriver_main) { - LOG_F("Honggfuzz Net Driver (pid=%d): HonggfuzzNetDriver_main was not defined in your " - "code", - getpid()); - } exit(HonggfuzzNetDriver_main(*argc, *argv)); }