Skip to content

Commit a0b23b8

Browse files
author
Marcos Pividori
committedFeb 10, 2017
[libFuzzer] Export external functions on tests.
We need to export external functions so they are found when calling GetProcAddress() on Windows. But we can't use `__declspec(dllexport)` because we want the targets to be completely independent from the fuzz engines and don't depend on other header files. Also, we don't want to include platform specific code managed with conditional macros. So, the solution is to add the exported symbols with linker flags in cmake. Differential revision: https://reviews.llvm.org/D29752 llvm-svn: 294688
1 parent 0ae27e8 commit a0b23b8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎llvm/lib/Fuzzer/test/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ foreach(Test ${Tests})
142142
add_libfuzzer_test(${Test} SOURCES ${Test}.cpp)
143143
endforeach()
144144

145+
function(test_export_symbol target symbol)
146+
if(MSVC)
147+
set_target_properties(LLVMFuzzer-${target} PROPERTIES LINK_FLAGS
148+
"-export:${symbol}")
149+
endif()
150+
endfunction()
151+
152+
test_export_symbol(InitializeTest "LLVMFuzzerInitialize")
153+
test_export_symbol(BogusInitializeTest "LLVMFuzzerInitialize")
154+
test_export_symbol(CustomCrossOverTest "LLVMFuzzerCustomCrossOver")
155+
test_export_symbol(CustomMutatorTest "LLVMFuzzerCustomMutator")
156+
145157
###############################################################################
146158
# Unit tests
147159
###############################################################################

0 commit comments

Comments
 (0)
Please sign in to comment.