Commit 75234301 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1330533 - Use FuzzerDriver directly instead of wrapping it in a...

Bug 1330533 - Use FuzzerDriver directly instead of wrapping it in a libfuzzer_main function. r=decoder

Going further from the previous changes, all libfuzzer_main really does
is call the init function, and then proceed to call the fuzzer driver
with the testing function.

So instead of calling that function for it to do all that, the
LibFuzzerRunner can just call the init function itself, and then
call the fuzzer driver with the testing function.

--HG--
extra : rebase_source : 2eb1a2ae763ef21827471cd32addceacefc1ac5d
parent cc6c5d8f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ USE_LIBS += [

if CONFIG['LIBFUZZER']:
    USE_LIBS += [ 'fuzzer' ]
    LOCAL_INCLUDES += [
        '/tools/fuzzing/libfuzzer',
    ]

if CONFIG['_MSC_VER']:
    # Always enter a Windows program through wmain, whether or not we're
+5 −5
Original line number Diff line number Diff line
@@ -43,6 +43,10 @@
#include "mozilla/Telemetry.h"
#include "mozilla/WindowsDllBlocklist.h"

#ifdef LIBFUZZER
#include "FuzzerDefs.h"
#endif

#ifdef MOZ_LINUX_32_SSE2_STARTUP_ERROR
#include <cpuid.h>
#include "mozilla/Unused.h"
@@ -163,10 +167,6 @@ static bool IsArg(const char* arg, const char* s)

Bootstrap::UniquePtr gBootstrap;

#ifdef LIBFUZZER
int libfuzzer_main(int argc, char **argv, LibFuzzerInitFunc, LibFuzzerTestingFunc);
#endif

static int do_main(int argc, char* argv[], char* envp[])
{
  // Allow firefox.exe to launch XULRunner apps via -app <application.ini>
@@ -228,7 +228,7 @@ static int do_main(int argc, char* argv[], char* envp[])

#ifdef LIBFUZZER
  if (getenv("LIBFUZZER"))
    gBootstrap->XRE_LibFuzzerSetMain(libfuzzer_main);
    gBootstrap->XRE_LibFuzzerSetDriver(fuzzer::FuzzerDriver);
#endif

  return gBootstrap->XRE_main(argc, argv, config);
+2 −2
Original line number Diff line number Diff line
@@ -80,8 +80,8 @@ public:
#endif

#ifdef LIBFUZZER
  virtual void XRE_LibFuzzerSetMain(LibFuzzerMain aMain) override {
    ::XRE_LibFuzzerSetMain(aMain);
  virtual void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) override {
    ::XRE_LibFuzzerSetDriver(aDriver);
  }
#endif

+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public:
#endif

#ifdef LIBFUZZER
  virtual void XRE_LibFuzzerSetMain(LibFuzzerMain aMain) = 0;
  virtual void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) = 0;
#endif

#ifdef MOZ_IPDL_TESTS
+3 −3
Original line number Diff line number Diff line
@@ -272,8 +272,8 @@ namespace mozilla {
LibFuzzerRunner* libFuzzerRunner = 0;
} // namespace mozilla

void XRE_LibFuzzerSetMain(LibFuzzerMain main) {
  mozilla::libFuzzerRunner->setParams(main);
void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) {
  mozilla::libFuzzerRunner->setParams(aDriver);
}
#endif

@@ -3724,7 +3724,7 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
#ifdef LIBFUZZER
  if (PR_GetEnv("LIBFUZZER")) {
    *aExitFlag = true;
    return mozilla::libFuzzerRunner->Run(gArgc, gArgv);
    return mozilla::libFuzzerRunner->Run(&gArgc, &gArgv);
  }
#endif

Loading