[llvm] r268824 - [libFuzzer] modify the docs for startup/init

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 16:51:29 PDT 2016


Author: kcc
Date: Fri May  6 18:51:28 2016
New Revision: 268824

URL: http://llvm.org/viewvc/llvm-project?rev=268824&view=rev
Log:
[libFuzzer] modify the docs for startup/init

Modified:
    llvm/trunk/docs/LibFuzzer.rst

Modified: llvm/trunk/docs/LibFuzzer.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LibFuzzer.rst?rev=268824&r1=268823&r2=268824&view=diff
==============================================================================
--- llvm/trunk/docs/LibFuzzer.rst (original)
+++ llvm/trunk/docs/LibFuzzer.rst Fri May  6 18:51:28 2016
@@ -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++
 




More information about the llvm-commits mailing list