1 // Copyright 2017 The Chromium Authors 2 // 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 16 #if BUILDFLAG(IS_MAC) 17 #define EXPORT_FUZZER_FUNCTION \ 18 __attribute__((used)) __attribute__((visibility("default"))) 19 #else 20 #define EXPORT_FUZZER_FUNCTION 21 #endif 22 23 extern "C" { 24 25 EXPORT_FUZZER_FUNCTION int LLVMFuzzerInitialize(int* argc, char*** argv); 26 EXPORT_FUZZER_FUNCTION int LLVMFuzzerTestOneInput(const uint8_t* data, 27 size_t size); 28 EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerCustomMutator(uint8_t* data, 29 size_t size, 30 size_t max_size, 31 unsigned int seed); 32 EXPORT_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); 39 EXPORT_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_ 48