]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] modify the docs for startup/init
authorKostya Serebryany <kcc@google.com>
Fri, 6 May 2016 23:51:28 +0000 (23:51 +0000)
committerKostya Serebryany <kcc@google.com>
Fri, 6 May 2016 23:51:28 +0000 (23:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268824 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LibFuzzer.rst

index 4d6a0847bea4ff2eb96447edde2fe57faa118071..4047d104c842903dac599ae6027d24f78b6499ed 100644 (file)
@@ -624,14 +624,18 @@ 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:
+The simplest way is to have a statically initialized global object inside
+`LLVMFuzzerTestOneInput` (or in global scope if that works for you):
 
 .. code-block:: c++
 
-   static bool Initialized = DoInitialization();
+  extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+    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:
+the program arguments that you can read and modify. Do this **only** if you
+realy need to access ``argv``/``argc``.
 
 .. code-block:: c++