1//===- FuzzerDFSan.h - Internal header for the Fuzzer -----------*- C++ -* ===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// DFSan interface. 10//===----------------------------------------------------------------------===// 11 12#ifndef LLVM_FUZZER_DFSAN_H 13#define LLVM_FUZZER_DFSAN_H 14 15#define LLVM_FUZZER_SUPPORTS_DFSAN 0 16#if defined(__has_include) 17# if __has_include(<sanitizer/dfsan_interface.h>) 18# if defined (__linux__) 19# undef LLVM_FUZZER_SUPPORTS_DFSAN 20# define LLVM_FUZZER_SUPPORTS_DFSAN 1 21# include <sanitizer/dfsan_interface.h> 22# endif // __linux__ 23# endif 24#endif // defined(__has_include) 25 26#if LLVM_FUZZER_SUPPORTS_DFSAN 27 28extern "C" { 29__attribute__((weak)) 30dfsan_label dfsan_create_label(const char *desc, void *userdata); 31__attribute__((weak)) 32void dfsan_set_label(dfsan_label label, void *addr, size_t size); 33__attribute__((weak)) 34void dfsan_add_label(dfsan_label label, void *addr, size_t size); 35__attribute__((weak)) 36const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label); 37__attribute__((weak)) 38dfsan_label dfsan_read_label(const void *addr, size_t size); 39} // extern "C" 40 41namespace fuzzer { 42static bool ReallyHaveDFSan() { 43 return &dfsan_create_label != nullptr; 44} 45} // namespace fuzzer 46#else 47// When compiling with a compiler which does not support dfsan, 48// this code is still expected to build (but not necessary work). 49typedef unsigned short dfsan_label; 50struct dfsan_label_info { 51 dfsan_label l1, l2; 52 const char *desc; 53 void *userdata; 54}; 55namespace fuzzer { 56static bool ReallyHaveDFSan() { return false; } 57} // namespace fuzzer 58 59#endif 60 61#endif // LLVM_FUZZER_DFSAN_H 62