libfuzzer_exports.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 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. #ifndef TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_
  5. #define TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_
  6. #include "build/build_config.h"
  7. // On macOS, the linker may strip symbols for functions that are not reachable
  8. // by the program entrypoint. Several libFuzzer functions are resolved via
  9. // dlsym at runtime and therefore may be dead-stripped as a result. Including
  10. // this header in the fuzzer's implementation file will ensure that all the
  11. // symbols are kept and exported.
  12. #if defined(OS_MAC)
  13. #define EXPORT_FUZZER_FUNCTION \
  14. __attribute__((used)) __attribute__((visibility("default")))
  15. #else
  16. #define EXPORT_FUZZER_FUNCTION
  17. #endif
  18. extern "C" {
  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. } // extern "C"
  37. #undef EXPORT_FUZZER_FUNCTION
  38. #endif // TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_