File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1212
1313const std::function<void (const std::string&)> G_TEST_LOG_FUN{};
1414
15- #if defined(__AFL_COMPILER)
15+ // Decide if main(...) should be provided:
16+ // * AFL needs main(...) regardless of platform.
17+ // * macOS handles __attribute__((weak)) main(...) poorly when linking
18+ // against libFuzzer. See https://github.com/bitcoin/bitcoin/pull/18008
19+ // for details.
20+ #if defined(__AFL_COMPILER) || !defined(MAC_OSX)
21+ #define PROVIDE_MAIN_FUNCTION
22+ #endif
23+
24+ #if defined(PROVIDE_MAIN_FUNCTION)
1625static bool read_stdin (std::vector<uint8_t >& data)
1726{
1827 uint8_t buffer[1024 ];
@@ -44,9 +53,8 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
4453 return 0 ;
4554}
4655
47- // Generally, the fuzzer will provide main(), except for AFL
48- #if defined(__AFL_COMPILER)
49- int main (int argc, char ** argv)
56+ #if defined(PROVIDE_MAIN_FUNCTION)
57+ __attribute__ ((weak)) int main(int argc, char ** argv)
5058{
5159 initialize ();
5260#ifdef __AFL_INIT
You can’t perform that action at this time.
0 commit comments