<div dir="ltr"><div>I'd like to discuss the following change: <a href="https://reviews.llvm.org/D37526">https://reviews.llvm.org/D37526</a></div><div><br></div><div>For the context, there is a comment in compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp:</div><div><br></div><div><div><font face="monospace, monospace" size="1">// Implementation for Linux. This relies on the linker's support for weak</font></div><div><font face="monospace, monospace" size="1">// symbols. We don't use this approach on Apple platforms because it requires</font></div><div><font face="monospace, monospace" size="1">// clients of LibFuzzer to pass ``-U _<symbol_name>`` to the linker to allow</font></div><div><font face="monospace, monospace" size="1">// weak symbols to be undefined. That is a complication we don't want to expose</font></div><div><font face="monospace, monospace" size="1">// to clients right now.</font></div></div><div><br></div><div>That makes sense, but with current implementation, you cannot use libFuzzer's interface functions other than LLVMFuzzerTestOneInput. Below is a small example to verify that LLVMFuzzerInitialize is not being called on Mac:</div><div><br></div><div><pre class="gmail-issue_text" style="font-size:11.726px;white-space:pre-wrap;max-width:80em;padding:0px 0px 3px 0.7em;color:rgb(0,0,0)">#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
  printf("Hello from LLVMFuzzerInitialize, argc: %i\n", *argc);
  return *argc;
}

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  printf("Hello from LLVMFuzzerTestOneInput, size: %zu\n", size);
  if (size) {
        return data[0];
  }
  return size;
}</pre></div><div><br></div><div>Assuming that there are libFuzzer customers who don't mind to specify "-U,_%function_name%" explicitly (e.g. <a href="https://chromium-review.googlesource.com/c/chromium/src/+/653846/1/testing/libfuzzer/BUILD.gn">https://chromium-review.googlesource.com/c/chromium/src/+/653846/1/testing/libfuzzer/BUILD.gn</a>), we need to have a way to use FuzzerExtFunctionsWeak.cpp instead of FuzzerExtFunctionsDlsym.cpp on Mac.</div><div><br></div><div>The CL I've uploaded feels a bit hacky to me, but I don't see any less intrusive solution that would still comply with existing implementation and would also support weak symbols to be explicitly allowed if needed.</div><div><br></div><div>Thanks!</div><div><br></div><div>--</div><div>Max</div><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><span><div dir="ltr" style="margin-left:0pt"></div></span></div></div></div></div></div></div></div></div>
</div>