diff options
author | Matt Morehouse <mascasa@google.com> | 2018-08-28 19:07:24 +0000 |
---|---|---|
committer | Matt Morehouse <mascasa@google.com> | 2018-08-28 19:07:24 +0000 |
commit | dfdafdfd47764a9728726abd45f99ac9faca81e5 (patch) | |
tree | d8ef880c63fe3dfa238ff16026da431328ac7e25 /lib/fuzzer | |
parent | 5ca960adad7c824b1ee5567271beb4b29abe9a3d (diff) | |
download | compiler-rt-dfdafdfd47764a9728726abd45f99ac9faca81e5.tar.gz |
Revert "[libFuzzer] Port to Windows"
This reverts commit r340860 due to failing tests.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@340867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/fuzzer')
-rw-r--r-- | lib/fuzzer/FuzzerDefs.h | 7 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerIO.cpp | 8 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerIO.h | 2 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerIOPosix.cpp | 7 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerIOWindows.cpp | 20 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerTracePC.cpp | 3 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerUtilWindows.cpp | 4 | ||||
-rw-r--r-- | lib/fuzzer/tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/fuzzer/tests/FuzzerUnittest.cpp | 7 |
9 files changed, 12 insertions, 48 deletions
diff --git a/lib/fuzzer/FuzzerDefs.h b/lib/fuzzer/FuzzerDefs.h index 31655d562..a35c7a181 100644 --- a/lib/fuzzer/FuzzerDefs.h +++ b/lib/fuzzer/FuzzerDefs.h @@ -129,15 +129,8 @@ #if LIBFUZZER_WINDOWS #define ATTRIBUTE_INTERFACE __declspec(dllexport) -// This is used for __sancov_lowest_stack which is needed for -// -fsanitize-coverage=stack-depth. That feature is not yet available on -// Windows, so make the symbol static to avoid linking errors. -#define ATTRIBUTES_INTERFACE_TLS_INITIAL_EXEC \ - __attribute__((tls_model("initial-exec"))) thread_local static #else #define ATTRIBUTE_INTERFACE __attribute__((visibility("default"))) -#define ATTRIBUTES_INTERFACE_TLS_INITIAL_EXEC \ - ATTRIBUTE_INTERFACE __attribute__((tls_model("initial-exec"))) thread_local #endif namespace fuzzer { diff --git a/lib/fuzzer/FuzzerIO.cpp b/lib/fuzzer/FuzzerIO.cpp index dac5ec658..f3ead0ec5 100644 --- a/lib/fuzzer/FuzzerIO.cpp +++ b/lib/fuzzer/FuzzerIO.cpp @@ -100,6 +100,14 @@ std::string DirPlusFile(const std::string &DirPath, return DirPath + GetSeparator() + FileName; } +std::string Basename(const std::string &Path, char Separator) { + size_t Pos = Path.rfind(Separator); + if (Pos == std::string::npos) + return Path; + assert(Pos < Path.size()); + return Path.substr(Pos + 1); +} + void DupAndCloseStderr() { int OutputFd = DuplicateFile(2); if (OutputFd > 0) { diff --git a/lib/fuzzer/FuzzerIO.h b/lib/fuzzer/FuzzerIO.h index b4a68190e..6d7757435 100644 --- a/lib/fuzzer/FuzzerIO.h +++ b/lib/fuzzer/FuzzerIO.h @@ -68,7 +68,7 @@ void GetSizedFilesFromDir(const std::string &Dir, Vector<SizedFile> *V); char GetSeparator(); // Similar to the basename utility: returns the file name w/o the dir prefix. -std::string Basename(const std::string &Path); +std::string Basename(const std::string &Path, char Separator = GetSeparator()); FILE* OpenFile(int Fd, const char *Mode); diff --git a/lib/fuzzer/FuzzerIOPosix.cpp b/lib/fuzzer/FuzzerIOPosix.cpp index 401b4cbbf..17e884d3c 100644 --- a/lib/fuzzer/FuzzerIOPosix.cpp +++ b/lib/fuzzer/FuzzerIOPosix.cpp @@ -46,13 +46,6 @@ size_t FileSize(const std::string &Path) { return St.st_size; } -std::string Basename(const std::string &Path) { - size_t Pos = Path.rfind(GetSeparator()); - if (Pos == std::string::npos) return Path; - assert(Pos < Path.size()); - return Path.substr(Pos + 1); -} - void ListFilesInDirRecursive(const std::string &Dir, long *Epoch, Vector<std::string> *V, bool TopDir) { auto E = GetEpoch(Dir); diff --git a/lib/fuzzer/FuzzerIOWindows.cpp b/lib/fuzzer/FuzzerIOWindows.cpp index 314b79d0f..74853646b 100644 --- a/lib/fuzzer/FuzzerIOWindows.cpp +++ b/lib/fuzzer/FuzzerIOWindows.cpp @@ -72,26 +72,6 @@ bool IsFile(const std::string &Path) { return IsFile(Path, Att); } -std::string Basename(const std::string &Path) { - size_t Pos = Path.find_last_of("/\\"); - if (Pos == std::string::npos) return Path; - assert(Pos < Path.size()); - return Path.substr(Pos + 1); -} - -size_t FileSize(const std::string &Path) { - WIN32_FILE_ATTRIBUTE_DATA attr; - if (!GetFileAttributesExA(Path.c_str(), GetFileExInfoStandard, &attr)) { - Printf("GetFileAttributesExA() failed for \"%s\" (Error code: %lu).\n", - Path.c_str(), GetLastError()); - return 0; - } - ULARGE_INTEGER size; - size.HighPart = attr.nFileSizeHigh; - size.LowPart = attr.nFileSizeLow; - return size.QuadPart; -} - void ListFilesInDirRecursive(const std::string &Dir, long *Epoch, Vector<std::string> *V, bool TopDir) { auto E = GetEpoch(Dir); diff --git a/lib/fuzzer/FuzzerTracePC.cpp b/lib/fuzzer/FuzzerTracePC.cpp index 75130840c..1aba816e8 100644 --- a/lib/fuzzer/FuzzerTracePC.cpp +++ b/lib/fuzzer/FuzzerTracePC.cpp @@ -32,7 +32,8 @@ ATTRIBUTE_INTERFACE uintptr_t __sancov_trace_pc_pcs[fuzzer::TracePC::kNumPCs]; // Used by -fsanitize-coverage=stack-depth to track stack depth -ATTRIBUTES_INTERFACE_TLS_INITIAL_EXEC uintptr_t __sancov_lowest_stack; +ATTRIBUTE_INTERFACE __attribute__((tls_model("initial-exec"))) +thread_local uintptr_t __sancov_lowest_stack; namespace fuzzer { diff --git a/lib/fuzzer/FuzzerUtilWindows.cpp b/lib/fuzzer/FuzzerUtilWindows.cpp index 257723b60..8227e778e 100644 --- a/lib/fuzzer/FuzzerUtilWindows.cpp +++ b/lib/fuzzer/FuzzerUtilWindows.cpp @@ -179,9 +179,7 @@ const void *SearchMemory(const void *Data, size_t DataLen, const void *Patt, } std::string DisassembleCmd(const std::string &FileName) { - Vector<std::string> command_vector; - command_vector.push_back("dumpbin /summary > nul"); - if (ExecuteCommand(Command(command_vector)) == 0) + if (ExecuteCommand("dumpbin /summary > nul") == 0) return "dumpbin /disasm " + FileName; Printf("libFuzzer: couldn't find tool to disassemble (dumpbin)\n"); exit(1); diff --git a/lib/fuzzer/tests/CMakeLists.txt b/lib/fuzzer/tests/CMakeLists.txt index 0b561c170..ed5807168 100644 --- a/lib/fuzzer/tests/CMakeLists.txt +++ b/lib/fuzzer/tests/CMakeLists.txt @@ -17,8 +17,6 @@ list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS --driver-mode=g++) if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lc++ -lpthread) -elseif(WIN32) - list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lstdc++) else() list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lstdc++ -lpthread) endif() diff --git a/lib/fuzzer/tests/FuzzerUnittest.cpp b/lib/fuzzer/tests/FuzzerUnittest.cpp index 7cdd44582..e3b067026 100644 --- a/lib/fuzzer/tests/FuzzerUnittest.cpp +++ b/lib/fuzzer/tests/FuzzerUnittest.cpp @@ -34,13 +34,6 @@ TEST(Fuzzer, Basename) { EXPECT_EQ(Basename("/bar"), "bar"); EXPECT_EQ(Basename("foo/x"), "x"); EXPECT_EQ(Basename("foo/"), ""); -#if LIBFUZZER_WINDOWS - EXPECT_EQ(Basename("foo\\bar"), "bar"); - EXPECT_EQ(Basename("foo\\bar/baz"), "baz"); - EXPECT_EQ(Basename("\\bar"), "bar"); - EXPECT_EQ(Basename("foo\\x"), "x"); - EXPECT_EQ(Basename("foo\\"), ""); -#endif } TEST(Fuzzer, CrossOver) { |