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 12
12
13
13
const std::function<void (const std::string&)> G_TEST_LOG_FUN{};
14
14
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)
16
25
static bool read_stdin (std::vector<uint8_t >& data)
17
26
{
18
27
uint8_t buffer[1024 ];
@@ -44,9 +53,8 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
44
53
return 0 ;
45
54
}
46
55
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)
50
58
{
51
59
initialize ();
52
60
#ifdef __AFL_INIT
You can’t perform that action at this time.
0 commit comments