[llvm-dev] lib Fuzzer

David CARLIER via llvm-dev llvm-dev at lists.llvm.org
Fri Dec 22 07:14:33 PST 2017


Hi dear list,

It s my first message and maybe it has already be done by someone else and
under review but in case here a patch proposal for the lib fuzzer for
FreeBSD.

Hope it s good.

Kind regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171222/345c893b/attachment.html>
-------------- next part --------------
Index: lib/fuzzer/FuzzerDefs.h
===================================================================
--- lib/fuzzer/FuzzerDefs.h	(revision 321358)
+++ lib/fuzzer/FuzzerDefs.h	(working copy)
@@ -27,6 +27,7 @@
 #define LIBFUZZER_FUCHSIA 0
 #define LIBFUZZER_LINUX 1
 #define LIBFUZZER_NETBSD 0
+#define LIBFUZZER_FREEBSD 0
 #define LIBFUZZER_WINDOWS 0
 #elif __APPLE__
 #define LIBFUZZER_APPLE 1
@@ -33,6 +34,7 @@
 #define LIBFUZZER_FUCHSIA 0
 #define LIBFUZZER_LINUX 0
 #define LIBFUZZER_NETBSD 0
+#define LIBFUZZER_FREEBSD 0
 #define LIBFUZZER_WINDOWS 0
 #elif __NetBSD__
 #define LIBFUZZER_APPLE 0
@@ -39,12 +41,21 @@
 #define LIBFUZZER_FUCHSIA 0
 #define LIBFUZZER_LINUX 0
 #define LIBFUZZER_NETBSD 1
+#define LIBFUZZER_FREEBSD 0
 #define LIBFUZZER_WINDOWS 0
+#elif __FreeBSD__
+#define LIBFUZZER_APPLE 0
+#define LIBFUZZER_FUCHSIA 0
+#define LIBFUZZER_LINUX 0
+#define LIBFUZZER_NETBSD 0
+#define LIBFUZZER_FREEBSD 1
+#define LIBFUZZER_WINDOWS 0
 #elif _WIN32
 #define LIBFUZZER_APPLE 0
 #define LIBFUZZER_FUCHSIA 0
 #define LIBFUZZER_LINUX 0
 #define LIBFUZZER_NETBSD 0
+#define LIBFUZZER_FREEBSD 0
 #define LIBFUZZER_WINDOWS 1
 #elif __Fuchsia__
 #define LIBFUZZER_APPLE 0
Index: lib/fuzzer/FuzzerExtFunctionsWeak.cpp
===================================================================
--- lib/fuzzer/FuzzerExtFunctionsWeak.cpp	(revision 321358)
+++ lib/fuzzer/FuzzerExtFunctionsWeak.cpp	(working copy)
@@ -13,7 +13,7 @@
 // to clients right now.
 //===----------------------------------------------------------------------===//
 #include "FuzzerDefs.h"
-#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUCHSIA
+#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUCHSIA || LIBFUZZER_FREEBSD
 
 #include "FuzzerExtFunctions.h"
 #include "FuzzerIO.h"
@@ -51,4 +51,4 @@
 
 } // namespace fuzzer
 
-#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD
+#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUSCHIA || LIBFUZZER_FREEBSD
Index: lib/fuzzer/FuzzerUtilLinux.cpp
===================================================================
--- lib/fuzzer/FuzzerUtilLinux.cpp	(revision 321358)
+++ lib/fuzzer/FuzzerUtilLinux.cpp	(working copy)
@@ -9,7 +9,7 @@
 // Misc utils for Linux.
 //===----------------------------------------------------------------------===//
 #include "FuzzerDefs.h"
-#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD
+#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD
 #include "FuzzerCommand.h"
 
 #include <stdlib.h>
@@ -23,4 +23,4 @@
 
 } // namespace fuzzer
 
-#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD
+#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD
Index: lib/fuzzer/FuzzerUtilPosix.cpp
===================================================================
--- lib/fuzzer/FuzzerUtilPosix.cpp	(revision 321358)
+++ lib/fuzzer/FuzzerUtilPosix.cpp	(working copy)
@@ -118,7 +118,7 @@
   struct rusage usage;
   if (getrusage(RUSAGE_SELF, &usage))
     return 0;
-  if (LIBFUZZER_LINUX) {
+  if (LIBFUZZER_LINUX || LIBFUZZER_FREEBSD) {
     // ru_maxrss is in KiB
     return usage.ru_maxrss >> 10;
   } else if (LIBFUZZER_APPLE) {
Index: lib/fuzzer/build.sh
===================================================================
--- lib/fuzzer/build.sh	(revision 321358)
+++ lib/fuzzer/build.sh	(working copy)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 LIBFUZZER_SRC_DIR=$(dirname $0)
 CXX="${CXX:-clang}"
 for f in $LIBFUZZER_SRC_DIR/*.cpp; do


More information about the llvm-dev mailing list