blob: f131a8d8cb733427b86fb3a8fe19307cdda493e1 [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:091// Copyright 2017 The Chromium Authors
Robert Sesekd88ebf82017-10-17 21:54:412// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_
6#define TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_
7
8#include "build/build_config.h"
9
10// On macOS, the linker may strip symbols for functions that are not reachable
11// by the program entrypoint. Several libFuzzer functions are resolved via
12// dlsym at runtime and therefore may be dead-stripped as a result. Including
13// this header in the fuzzer's implementation file will ensure that all the
14// symbols are kept and exported.
15
Xiaohan Wang83bdf142022-01-21 19:23:1116#if BUILDFLAG(IS_MAC)
Robert Sesekd88ebf82017-10-17 21:54:4117#define EXPORT_FUZZER_FUNCTION \
18 __attribute__((used)) __attribute__((visibility("default")))
19#else
20#define EXPORT_FUZZER_FUNCTION
21#endif
22
23extern "C" {
24
25EXPORT_FUZZER_FUNCTION int LLVMFuzzerInitialize(int* argc, char*** argv);
26EXPORT_FUZZER_FUNCTION int LLVMFuzzerTestOneInput(const uint8_t* data,
27 size_t size);
28EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerCustomMutator(uint8_t* data,
29 size_t size,
30 size_t max_size,
31 unsigned int seed);
32EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerCustomCrossOver(const uint8_t* data1,
33 size_t size1,
34 const uint8_t* data2,
35 size_t size2,
36 uint8_t* out,
37 size_t max_out_size,
38 unsigned int seed);
39EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerMutate(uint8_t* data,
40 size_t size,
41 size_t max_size);
42
43} // extern "C"
44
45#undef EXPORT_FUZZER_FUNCTION
46
47#endif // TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_