forked from OSchip/llvm-project
[fuzzer] Replace FuzzerExtFunctionsDlsymWin.cpp with FuzzerExtFunctionsWeakAlias.cpp
Summary: Replace FuzzerExtFunctionsDlsymWin.cpp with FuzzerExtFunctionsWeakAlias.cpp to get externally defined functions (eg: LLVMFuzzerInitialize, LLVMFuzzerCustomMutator, etc) working again. Also enable tests that depended on these functions (on windows) Reviewers: rnk, morehouse Reviewed By: rnk, morehouse Subscribers: rnk, morehouse, mgorny Differential Revision: https://reviews.llvm.org/D51700 llvm-svn: 342698
This commit is contained in:
parent
fec72d2a91
commit
0744d3c5a1
|
@ -3,7 +3,7 @@ set(LIBFUZZER_SOURCES
|
|||
FuzzerDataFlowTrace.cpp
|
||||
FuzzerDriver.cpp
|
||||
FuzzerExtFunctionsDlsym.cpp
|
||||
FuzzerExtFunctionsDlsymWin.cpp
|
||||
FuzzerExtFunctionsWeakAlias.cpp
|
||||
FuzzerExtFunctionsWeak.cpp
|
||||
FuzzerExtraCounters.cpp
|
||||
FuzzerIO.cpp
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
//===- FuzzerExtFunctionsDlsymWin.cpp - Interface to external functions ---===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Implementation using dynamic loading for Windows.
|
||||
//===----------------------------------------------------------------------===//
|
||||
#include "FuzzerDefs.h"
|
||||
#if LIBFUZZER_WINDOWS
|
||||
|
||||
#include "FuzzerExtFunctions.h"
|
||||
#include "FuzzerIO.h"
|
||||
#include <windows.h>
|
||||
|
||||
// This must be included after Windows.h.
|
||||
#include <psapi.h>
|
||||
|
||||
namespace fuzzer {
|
||||
|
||||
ExternalFunctions::ExternalFunctions() {
|
||||
HMODULE Modules[1024];
|
||||
DWORD BytesNeeded;
|
||||
HANDLE CurrentProcess = GetCurrentProcess();
|
||||
|
||||
if (!EnumProcessModules(CurrentProcess, Modules, sizeof(Modules),
|
||||
&BytesNeeded)) {
|
||||
Printf("EnumProcessModules failed (error: %d).\n", GetLastError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (sizeof(Modules) < BytesNeeded) {
|
||||
Printf("Error: the array is not big enough to hold all loaded modules.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < (BytesNeeded / sizeof(HMODULE)); i++)
|
||||
{
|
||||
FARPROC Fn;
|
||||
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
|
||||
if (this->NAME == nullptr) { \
|
||||
Fn = GetProcAddress(Modules[i], #NAME); \
|
||||
if (Fn == nullptr) \
|
||||
Fn = GetProcAddress(Modules[i], #NAME "__dll"); \
|
||||
this->NAME = (decltype(ExternalFunctions::NAME)) Fn; \
|
||||
}
|
||||
#include "FuzzerExtFunctions.def"
|
||||
#undef EXT_FUNC
|
||||
}
|
||||
|
||||
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
|
||||
if (this->NAME == nullptr && WARN) \
|
||||
Printf("WARNING: Failed to find function \"%s\".\n", #NAME);
|
||||
#include "FuzzerExtFunctions.def"
|
||||
#undef EXT_FUNC
|
||||
}
|
||||
|
||||
} // namespace fuzzer
|
||||
|
||||
#endif // LIBFUZZER_WINDOWS
|
|
@ -1,5 +1,3 @@
|
|||
# FIXME: Disabled on Windows since LLVMFuzzerInitialize does not yet work.
|
||||
UNSUPPORTED: windows
|
||||
RUN: %cpp_compiler %S/BogusInitializeTest.cpp -o %t-BogusInitializeTest
|
||||
|
||||
RUN: not %run %t-BogusInitializeTest 2>&1 | FileCheck %s --check-prefix=BOGUS_INITIALIZE
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# FIXME: Disabled on Windows since LLVMFuzzerCustomCrossOver does not yet work.
|
||||
UNSUPPORTED: windows
|
||||
RUN: %cpp_compiler %S/CustomCrossOverTest.cpp -o %t-CustomCrossOverTest
|
||||
|
||||
RUN: not %run %t-CustomCrossOverTest -seed=1 -runs=1000000 2>&1 | FileCheck %s --check-prefix=CHECK_CO
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# FIXME: Disabled on Windows since LLVMFuzzerCustomMutator does not yet work.
|
||||
UNSUPPORTED: windows
|
||||
RUN: %cpp_compiler %S/CustomMutatorTest.cpp -o %t-CustomMutatorTest
|
||||
RUN: not %run %t-CustomMutatorTest 2>&1 | FileCheck %s --check-prefix=LLVMFuzzerCustomMutator
|
||||
LLVMFuzzerCustomMutator: In LLVMFuzzerCustomMutator
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# FIXME: Disabled on Windows since LLVMFuzzerInitialize does not yet work.
|
||||
UNSUPPORTED: windows
|
||||
RUN: %cpp_compiler %S/FlagsTest.cpp -o %t-FlagsTest
|
||||
RUN: %run %t-FlagsTest -runs=10 -foo_bar=1 2>&1 | FileCheck %s --check-prefix=FOO_BAR
|
||||
FOO_BAR: WARNING: unrecognized flag '-foo_bar=1'; use -help=1 to list all flags
|
||||
FOO_BAR: BINGO
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# FIXME: Disabled on Windows since LLVMFuzzerInitialize does not yet work.
|
||||
UNSUPPORTED: windows
|
||||
CHECK: BINGO
|
||||
RUN: %cpp_compiler %S/InitializeTest.cpp -o %t-InitializeTest
|
||||
RUN: not %run %t-InitializeTest -use_value_profile=1 2>&1 | FileCheck %s
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# FIXME: Disabled on Windows because memmem is a GNU extension.
|
||||
UNSUPPORTED: windows
|
||||
RUN: %no_fuzzer_c_compiler %libfuzzer_src/standalone/StandaloneFuzzTargetMain.c -c -o %t_1.o
|
||||
RUN: %no_fuzzer_cpp_compiler %S/InitializeTest.cpp -c -o %t_2.o
|
||||
|
||||
|
|
Loading…
Reference in New Issue