FuzzerExtFunctions.def 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //===- FuzzerExtFunctions.def - External functions --------------*- C++ -* ===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // This defines the external function pointers that
  9. // ``fuzzer::ExternalFunctions`` should contain and try to initialize. The
  10. // EXT_FUNC macro must be defined at the point of inclusion. The signature of
  11. // the macro is:
  12. //
  13. // EXT_FUNC(<name>, <return_type>, <function_signature>, <warn_if_missing>)
  14. //===----------------------------------------------------------------------===//
  15. // Optional user functions
  16. EXT_FUNC(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false);
  17. EXT_FUNC(LLVMFuzzerCleanup, void, (), false);
  18. EXT_FUNC(LLVMFuzzerCustomMutator, size_t,
  19. (uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed),
  20. false);
  21. EXT_FUNC(LLVMFuzzerCustomCrossOver, size_t,
  22. (const uint8_t *Data1, size_t Size1,
  23. const uint8_t *Data2, size_t Size2,
  24. uint8_t *Out, size_t MaxOutSize, unsigned int Seed),
  25. false);
  26. // Sanitizer functions
  27. EXT_FUNC(__lsan_enable, void, (), false);
  28. EXT_FUNC(__lsan_disable, void, (), false);
  29. EXT_FUNC(__lsan_do_recoverable_leak_check, int, (), false);
  30. EXT_FUNC(__sanitizer_acquire_crash_state, int, (), true);
  31. EXT_FUNC(__sanitizer_install_malloc_and_free_hooks, int,
  32. (void (*malloc_hook)(const volatile void *, size_t),
  33. void (*free_hook)(const volatile void *)),
  34. false);
  35. EXT_FUNC(__sanitizer_log_write, void, (const char *buf, size_t len), false);
  36. EXT_FUNC(__sanitizer_purge_allocator, void, (), false);
  37. EXT_FUNC(__sanitizer_print_memory_profile, void, (size_t, size_t), false);
  38. EXT_FUNC(__sanitizer_print_stack_trace, void, (), true);
  39. EXT_FUNC(__sanitizer_symbolize_pc, void,
  40. (void *, const char *fmt, char *out_buf, size_t out_buf_size), false);
  41. EXT_FUNC(__sanitizer_get_module_and_offset_for_pc, int,
  42. (void *pc, char *module_path,
  43. size_t module_path_len,void **pc_offset), false);
  44. EXT_FUNC(__sanitizer_set_death_callback, void, (void (*)(void)), true);
  45. EXT_FUNC(__sanitizer_set_report_fd, void, (void*), false);
  46. EXT_FUNC(__msan_scoped_disable_interceptor_checks, void, (), false);
  47. EXT_FUNC(__msan_scoped_enable_interceptor_checks, void, (), false);
  48. EXT_FUNC(__msan_unpoison, void, (const volatile void *, size_t size), false);
  49. EXT_FUNC(__msan_unpoison_param, void, (size_t n), false);