1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 // Find "FUZZME", the target has 3 different functions.
7 // This test, and the accompanying lit tests
8 // (dataflow.test, only-some-bytes.test) assume that the compiler
9 // instruments functions in their lexical order.
10 // This assumption is not guaranteed, but it is likely to hold.
11 // It allows to simplify the test quite a bit: in the lit tests
12 // LLVMFuzzerTestOneInput is "F0", Func1 is "F1", Func2 is "F2".
19 extern "C" bool Func1(const uint8_t *Data
, size_t Size
);
20 extern "C" bool Func2(const uint8_t *Data
, size_t Size
);
22 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
29 && Func2(Data
, Size
)) {
30 fprintf(stderr
, "BINGO\n");
37 __attribute__((noinline
))
38 bool Func1(const uint8_t *Data
, size_t Size
) {
39 // assumes Size >= 5, doesn't check it.
40 return Data
[4] == 'M';
44 __attribute__((noinline
))
45 bool Func2(const uint8_t *Data
, size_t Size
) {
46 return Size
>= 6 && Data
[5] == 'E';