1 // Copyright 2021 The Chromium Authors. All rights reserved. 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_MAC_H_ 6 #define TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_MAC_H_ 7 8 // On macOS, the linker may strip symbols for functions that are not reachable 9 // by the program entrypoint. Several libFuzzer functions are resolved via 10 // dlsym at runtime and therefore may be dead-stripped as a result. Including 11 // this header in the fuzzer's implementation file will ensure that all the 12 // symbols are kept and exported. 13 14 #define EXPORT_FUZZER_FUNCTION \ 15 __attribute__((used)) __attribute__((visibility("default"))) 16 17 extern "C" { 18 19 EXPORT_FUZZER_FUNCTION int LLVMFuzzerInitialize(int* argc, char*** argv); 20 EXPORT_FUZZER_FUNCTION int LLVMFuzzerTestOneInput(const uint8_t* data, 21 size_t size); 22 EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerCustomMutator(uint8_t* data, 23 size_t size, 24 size_t max_size, 25 unsigned int seed); 26 EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerCustomCrossOver(const uint8_t* data1, 27 size_t size1, 28 const uint8_t* data2, 29 size_t size2, 30 uint8_t* out, 31 size_t max_out_size, 32 unsigned int seed); 33 EXPORT_FUZZER_FUNCTION size_t LLVMFuzzerMutate(uint8_t* data, 34 size_t size, 35 size_t max_size); 36 37 } // extern "C" 38 39 #undef EXPORT_FUZZER_FUNCTION 40 41 #endif // TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_MAC_H_ 42