[compiler-rt] r323828 - [fuzzer] Update and enable libFuzzer on Fuchsia

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 14:59:48 PST 2018


Author: phosek
Date: Tue Jan 30 14:59:48 2018
New Revision: 323828

URL: http://llvm.org/viewvc/llvm-project?rev=323828&view=rev
Log:
[fuzzer] Update and enable libFuzzer on Fuchsia

This change updates the Fuchsia-specific code to use the C++ friendly
duration expressions and flips on the building of
libclang_rt.fuzzer-x86_64.a and similar for Fuchsia. Given that
compiler-rt doesn't build on Fuchsia, test have been run by explicitly
building the library and linking it against
lib/fuzzer/tests/FuzzerUnittest.cpp.

Differential Revision: https://reviews.llvm.org/D42670

Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/fuzzer/FuzzerUtilFuchsia.cpp

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=323828&r1=323827&r2=323828&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue Jan 30 14:59:48 2018
@@ -604,7 +604,7 @@ else()
 endif()
 
 if (COMPILER_RT_HAS_SANITIZER_COMMON AND FUZZER_SUPPORTED_ARCH AND
-    OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD")
+    OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD|Fuchsia")
   set(COMPILER_RT_HAS_FUZZER TRUE)
 else()
   set(COMPILER_RT_HAS_FUZZER FALSE)

Modified: compiler-rt/trunk/lib/fuzzer/FuzzerUtilFuchsia.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerUtilFuchsia.cpp?rev=323828&r1=323827&r2=323828&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerUtilFuchsia.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerUtilFuchsia.cpp Tue Jan 30 14:59:48 2018
@@ -56,7 +56,7 @@ void InterruptHandler() {
 void CrashHandler(zx::port *Port) {
   std::unique_ptr<zx::port> ExceptionPort(Port);
   zx_port_packet_t Packet;
-  ExceptionPort->wait(ZX_TIME_INFINITE, &Packet, 0);
+  ExceptionPort->wait(zx::time::infinite(), &Packet, 0);
   // Unbind as soon as possible so we don't receive exceptions from this thread.
   if (zx_task_bind_exception_port(ZX_HANDLE_INVALID, ZX_HANDLE_INVALID,
                                   kFuzzingCrash, 0) != ZX_OK) {
@@ -117,7 +117,7 @@ void SetSignalHandler(const FuzzingOptio
 }
 
 void SleepSeconds(int Seconds) {
-  zx::nanosleep(zx::deadline_after(ZX_SEC(Seconds)));
+  zx::nanosleep(zx::deadline_after(zx::sec(Seconds)));
 }
 
 unsigned long GetPid() {
@@ -200,7 +200,7 @@ int ExecuteCommand(const Command &Cmd) {
   zx::process Process(ProcessHandle);
 
   // Now join the process and return the exit status.
-  if ((rc = Process.wait_one(ZX_PROCESS_TERMINATED, ZX_TIME_INFINITE,
+  if ((rc = Process.wait_one(ZX_PROCESS_TERMINATED, zx::time::infinite(),
                              nullptr)) != ZX_OK) {
     Printf("libFuzzer: failed to join '%s': %s\n", Argv[0],
            zx_status_get_string(rc));




More information about the llvm-commits mailing list