2 /* based on http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerInterface.h r321218 (20 Dec 2017) */
4 /* http://llvm.org/svn/llvm-project/compiler-rt/trunk/LICENSE.TXT follows */
7 ==============================================================================
9 ==============================================================================
11 The compiler_rt library is dual licensed under both the University of Illinois
12 "BSD-Like" license and the MIT license. As a user of this code you may choose
13 to use it under either license. As a contributor, you agree to allow your code
14 to be used under both.
16 Full text of the relevant licenses is included below.
18 ==============================================================================
20 University of Illinois/NCSA
23 Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
31 University of Illinois at Urbana-Champaign
35 Permission is hereby granted, free of charge, to any person obtaining a copy of
36 this software and associated documentation files (the "Software"), to deal with
37 the Software without restriction, including without limitation the rights to
38 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
39 of the Software, and to permit persons to whom the Software is furnished to do
40 so, subject to the following conditions:
42 * Redistributions of source code must retain the above copyright notice,
43 this list of conditions and the following disclaimers.
45 * Redistributions in binary form must reproduce the above copyright notice,
46 this list of conditions and the following disclaimers in the
47 documentation and/or other materials provided with the distribution.
49 * Neither the names of the LLVM Team, University of Illinois at
50 Urbana-Champaign, nor the names of its contributors may be used to
51 endorse or promote products derived from this Software without specific
52 prior written permission.
54 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
56 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57 CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
62 ==============================================================================
64 Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
66 SPDX-License-Identifier: MIT
68 ==============================================================================
69 Copyrights and Licenses for Third Party Software Distributed with LLVM:
70 ==============================================================================
71 The LLVM software contains code written by third parties. Such software will
72 have its own individual LICENSE.TXT file in the directory in which it appears.
73 This file will describe the copyrights, license, and restrictions which apply
76 The disclaimer of warranty in the University of Illinois Open Source License
77 applies to all code in the LLVM Distribution, and nothing in any of the
78 other licenses gives permission to use the names of the LLVM Team or the
79 University of Illinois to endorse or promote products derived from this
82 //===- FuzzerInterface.h - Interface header for the Fuzzer ------*- C++ -* ===//
84 // The LLVM Compiler Infrastructure
86 // This file is distributed under the University of Illinois Open Source
87 // License. See LICENSE.TXT for details.
89 //===----------------------------------------------------------------------===//
90 // Define the interface between libFuzzer and the library being tested.
91 //===----------------------------------------------------------------------===//
93 // NOTE: the libFuzzer interface is thin and in the majority of cases
94 // you should not include this file into your target. In 95% of cases
95 // all you need is to define the following function in your file:
96 // extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
98 // WARNING: keep the interface in C.
100 #ifndef LLVM_FUZZER_INTERFACE_H
101 #define LLVM_FUZZER_INTERFACE_H
108 #endif // __cplusplus
110 // Mandatory user-provided target function.
111 // Executes the code under test with [Data, Data+Size) as the input.
112 // libFuzzer will invoke this function *many* times with different inputs.
114 int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
);
116 // Optional user-provided initialization function.
117 // If provided, this function will be called by libFuzzer once at startup.
118 // It may read and modify argc/argv.
120 int LLVMFuzzerInitialize(int *argc
, char ***argv
);
122 // Optional user-provided custom mutator.
123 // Mutates raw data in [Data, Data+Size) inplace.
124 // Returns the new size, which is not greater than MaxSize.
125 // Given the same Seed produces the same mutation.
126 size_t LLVMFuzzerCustomMutator(uint8_t *Data
, size_t Size
, size_t MaxSize
,
129 // Optional user-provided custom cross-over function.
130 // Combines pieces of Data1 & Data2 together into Out.
131 // Returns the new size, which is not greater than MaxOutSize.
132 // Should produce the same mutation given the same Seed.
133 size_t LLVMFuzzerCustomCrossOver(const uint8_t *Data1
, size_t Size1
,
134 const uint8_t *Data2
, size_t Size2
,
135 uint8_t *Out
, size_t MaxOutSize
,
138 // Experimental, may go away in future.
139 // libFuzzer-provided function to be used inside LLVMFuzzerCustomMutator.
140 // Mutates raw data in [Data, Data+Size) inplace.
141 // Returns the new size, which is not greater than MaxSize.
142 size_t LLVMFuzzerMutate(uint8_t *Data
, size_t Size
, size_t MaxSize
);
146 #endif // __cplusplus
148 #endif // LLVM_FUZZER_INTERFACE_H