1 #ifndef __AFLLLVMCOMMON_H 2 #define __AFLLLVMCOMMON_H 3 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include <unistd.h> 7 8 #include <list> 9 #include <string> 10 #include <fstream> 11 #include <optional> 12 #include <sys/time.h> 13 14 #include "llvm/Config/llvm-config.h" 15 #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5 16 typedef long double max_align_t; 17 #endif 18 19 #include "llvm/IR/IRBuilder.h" 20 #include "llvm/IR/LegacyPassManager.h" 21 #include "llvm/IR/BasicBlock.h" 22 #include "llvm/IR/Module.h" 23 #include "llvm/Support/Debug.h" 24 #include "llvm/Support/MathExtras.h" 25 #if LLVM_VERSION_MAJOR < 17 26 #include "llvm/Transforms/IPO/PassManagerBuilder.h" 27 #endif 28 29 #if LLVM_VERSION_MAJOR > 3 || \ 30 (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4) 31 #include "llvm/IR/DebugInfo.h" 32 #include "llvm/IR/CFG.h" 33 #else 34 #include "llvm/DebugInfo.h" 35 #include "llvm/Support/CFG.h" 36 #endif 37 38 #if LLVM_VERSION_MAJOR >= 11 39 #define MNAME M.getSourceFileName() 40 #define FMNAME F.getParent()->getSourceFileName() 41 #if LLVM_VERSION_MAJOR >= 16 42 // None becomes deprecated 43 // the standard std::nullopt_t is recommended instead 44 // from C++17 and onwards. 45 constexpr std::nullopt_t None = std::nullopt; 46 #endif 47 #else 48 #define MNAME std::string("") 49 #define FMNAME std::string("") 50 #endif 51 52 char *getBBName(const llvm::BasicBlock *BB); 53 bool isIgnoreFunction(const llvm::Function *F); 54 void initInstrumentList(); 55 bool isInInstrumentList(llvm::Function *F, std::string Filename); 56 unsigned long long int calculateCollisions(uint32_t edges); 57 void scanForDangerousFunctions(llvm::Module *M); 58 59 #ifndef IS_EXTERN 60 #define IS_EXTERN 61 #endif 62 63 IS_EXTERN int debug; 64 IS_EXTERN int be_quiet; 65 66 #undef IS_EXTERN 67 68 #endif 69 70