summaryrefslogtreecommitdiffstats
path: root/llvm/docs/LibFuzzer.rst
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-01-16 01:23:12 +0000
committerKostya Serebryany <kcc@google.com>2016-01-16 01:23:12 +0000
commitaca7696f4d73c820eb780f905a657945d1e48785 (patch)
tree9f54eb1f8b615a581e1b53967fbd832ae2493799 /llvm/docs/LibFuzzer.rst
parentbc0cb11eb206b2441611016d0e57f4fe80af8544 (diff)
downloadbcm5719-llvm-aca7696f4d73c820eb780f905a657945d1e48785.tar.gz
bcm5719-llvm-aca7696f4d73c820eb780f905a657945d1e48785.zip
[libFuzzer] introduce LLVMFuzzerInitialize
llvm-svn: 257980
Diffstat (limited to 'llvm/docs/LibFuzzer.rst')
-rw-r--r--llvm/docs/LibFuzzer.rst29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/docs/LibFuzzer.rst b/llvm/docs/LibFuzzer.rst
index 84adff3616f..8f4163bd895 100644
--- a/llvm/docs/LibFuzzer.rst
+++ b/llvm/docs/LibFuzzer.rst
@@ -336,6 +336,35 @@ User-supplied mutators
LibFuzzer allows to use custom (user-supplied) mutators,
see FuzzerInterface.h_
+Startup initialization
+----------------------
+If the library being tested needs to be initialized, there are several options.
+
+The simplest way is to have a statically initialized global object::
+
+ static bool Initialized = DoInitialization();
+
+Alternatively, you may define an optional init function and it will receive
+the program arguments that you can read and modify::
+
+ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+ ReadAndMaybeModify(argc, argv);
+ return 0;
+ }
+
+Finally, you may use your own ``main()`` and call ``FuzzerDriver``
+from there, see FuzzerInterface.h_.
+
+Try to avoid initialization inside the target function itself as
+it will skew the coverage data. Don't do this::
+
+ extern "C" int LLVMFuzzerTestOneInput(...) {
+ static bool initialized = false;
+ if (!initialized) {
+ ...
+ }
+ }
+
Fuzzing components of LLVM
==========================
OpenPOWER on IntegriCloud