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 <sys/time.h> 12 13 #include "llvm/Config/llvm-config.h" 14 #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5 15 typedef long double max_align_t; 16 #endif 17 18 #include "llvm/IR/IRBuilder.h" 19 #include "llvm/IR/LegacyPassManager.h" 20 #include "llvm/IR/BasicBlock.h" 21 #include "llvm/IR/Module.h" 22 #include "llvm/Support/Debug.h" 23 #include "llvm/Support/MathExtras.h" 24 #include "llvm/Transforms/IPO/PassManagerBuilder.h" 25 26 #if LLVM_VERSION_MAJOR > 3 || \ 27 (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4) 28 #include "llvm/IR/DebugInfo.h" 29 #include "llvm/IR/CFG.h" 30 #else 31 #include "llvm/DebugInfo.h" 32 #include "llvm/Support/CFG.h" 33 #endif 34 35 #if LLVM_VERSION_MAJOR >= 11 36 #define MNAME M.getSourceFileName() 37 #define FMNAME F.getParent()->getSourceFileName() 38 #else 39 #define MNAME std::string("") 40 #define FMNAME std::string("") 41 #endif 42 43 char *getBBName(const llvm::BasicBlock *BB); 44 bool isIgnoreFunction(const llvm::Function *F); 45 void initInstrumentList(); 46 bool isInInstrumentList(llvm::Function *F, std::string Filename); 47 unsigned long long int calculateCollisions(uint32_t edges); 48 void scanForDangerousFunctions(llvm::Module *M); 49 50 #ifndef IS_EXTERN 51 #define IS_EXTERN 52 #endif 53 54 IS_EXTERN int debug; 55 IS_EXTERN int be_quiet; 56 57 #undef IS_EXTERN 58 59 #endif 60 61