[PATCH] D40923: [libFuzzer] Add preprocessor flag to explicitly enable weak symbols on Mac.
Max Moroz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 15:16:52 PST 2017
Dor1s created this revision.
Herald added subscribers: Sanitizers, llvm-commits.
Default implementation for Mac (i.e. FuzzerExtFunctionsDlsym.cpp) does
not work when LLVMFuzzer* interface functions are defined in different
translation units and compiled with "-fvisibility=hidden" flag, as the linker
removes those as a dead code.
That is an alternative solution if we cannot adjust Chromium build config:
https://chromium-review.googlesource.com/c/chromium/src/+/812108
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D40923
Files:
lib/fuzzer/FuzzerExtFunctionsDlsym.cpp
lib/fuzzer/FuzzerExtFunctionsWeak.cpp
Index: lib/fuzzer/FuzzerExtFunctionsWeak.cpp
===================================================================
--- lib/fuzzer/FuzzerExtFunctionsWeak.cpp
+++ lib/fuzzer/FuzzerExtFunctionsWeak.cpp
@@ -10,10 +10,11 @@
// symbols. We don't use this approach on Apple platforms because it requires
// clients of LibFuzzer to pass ``-U _<symbol_name>`` to the linker to allow
// weak symbols to be undefined. That is a complication we don't want to expose
-// to clients right now.
+// to clients right now. However, if someone prefers that way, they need to
+// explicitly define LIBFUZZER_WITH_UNDEFINED_WEAK_SYMBOLS.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
-#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD
+#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_WITH_UNDEFINED_WEAK_SYMBOLS
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
Index: lib/fuzzer/FuzzerExtFunctionsDlsym.cpp
===================================================================
--- lib/fuzzer/FuzzerExtFunctionsDlsym.cpp
+++ lib/fuzzer/FuzzerExtFunctionsDlsym.cpp
@@ -12,7 +12,7 @@
// That is a complication we don't wish to expose to clients right now.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
-#if LIBFUZZER_APPLE
+#if LIBFUZZER_APPLE && !LIBFUZZER_WITH_UNDEFINED_WEAK_SYMBOLS
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40923.125824.patch
Type: text/x-patch
Size: 1447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171206/bd93265d/attachment.bin>
More information about the llvm-commits
mailing list