mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 04:18:06 +00:00
unify LLVM_VERSION_... usage
This commit is contained in:
@ -1325,7 +1325,7 @@ void ModuleSanitizerCoverage::instrumentFunction(
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 13
|
#if LLVM_VERSION_MAJOR >= 14
|
||||||
if (t->getTypeID() == llvm::Type::FixedVectorTyID) {
|
if (t->getTypeID() == llvm::Type::FixedVectorTyID) {
|
||||||
|
|
||||||
FixedVectorType *tt = dyn_cast<FixedVectorType>(t);
|
FixedVectorType *tt = dyn_cast<FixedVectorType>(t);
|
||||||
@ -1468,7 +1468,7 @@ GlobalVariable *ModuleSanitizerCoverage::CreateFunctionLocalArrayInSection(
|
|||||||
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
|
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
|
||||||
Constant::getNullValue(ArrayTy), "__sancov_gen_");
|
Constant::getNullValue(ArrayTy), "__sancov_gen_");
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 12
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
if (TargetTriple.supportsCOMDAT() &&
|
if (TargetTriple.supportsCOMDAT() &&
|
||||||
(TargetTriple.isOSBinFormatELF() || !F.isInterposable()))
|
(TargetTriple.isOSBinFormatELF() || !F.isInterposable()))
|
||||||
if (auto Comdat = getOrCreateFunctionComdat(F, TargetTriple))
|
if (auto Comdat = getOrCreateFunctionComdat(F, TargetTriple))
|
||||||
@ -1628,10 +1628,10 @@ void ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
|
|||||||
if (Options.TracePC) {
|
if (Options.TracePC) {
|
||||||
|
|
||||||
IRB.CreateCall(SanCovTracePC)
|
IRB.CreateCall(SanCovTracePC)
|
||||||
#if LLVM_VERSION_MAJOR < 12
|
#if LLVM_VERSION_MAJOR >= 12
|
||||||
->cannotMerge(); // gets the PC using GET_CALLER_PC.
|
|
||||||
#else
|
|
||||||
->setCannotMerge(); // gets the PC using GET_CALLER_PC.
|
->setCannotMerge(); // gets the PC using GET_CALLER_PC.
|
||||||
|
#else
|
||||||
|
->cannotMerge(); // gets the PC using GET_CALLER_PC.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/SpecialCaseList.h"
|
#include "llvm/Support/SpecialCaseList.h"
|
||||||
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
|
#if LLVM_VERSION_MAJOR >= 11 || \
|
||||||
|
(LLVM_VERSION_MAJOR == 10 && LLVM_VERSION_MINOR >= 1)
|
||||||
#include "llvm/Support/VirtualFileSystem.h"
|
#include "llvm/Support/VirtualFileSystem.h"
|
||||||
#endif
|
#endif
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -127,7 +128,7 @@ class ModuleSanitizerCoverage {
|
|||||||
public:
|
public:
|
||||||
ModuleSanitizerCoverage(
|
ModuleSanitizerCoverage(
|
||||||
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()
|
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()
|
||||||
#if LLVM_MAJOR > 10
|
#if (LLVM_VERSION_MAJOR >= 11)
|
||||||
,
|
,
|
||||||
const SpecialCaseList *Allowlist = nullptr,
|
const SpecialCaseList *Allowlist = nullptr,
|
||||||
const SpecialCaseList *Blocklist = nullptr
|
const SpecialCaseList *Blocklist = nullptr
|
||||||
@ -215,7 +216,7 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
public:
|
public:
|
||||||
ModuleSanitizerCoverageLegacyPass(
|
ModuleSanitizerCoverageLegacyPass(
|
||||||
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()
|
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()
|
||||||
#if LLVM_VERSION_MAJOR > 10
|
#if LLVM_VERSION_MAJOR >= 11
|
||||||
,
|
,
|
||||||
const std::vector<std::string> &AllowlistFiles =
|
const std::vector<std::string> &AllowlistFiles =
|
||||||
std::vector<std::string>(),
|
std::vector<std::string>(),
|
||||||
@ -233,7 +234,7 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
bool runOnModule(Module &M) override {
|
bool runOnModule(Module &M) override {
|
||||||
|
|
||||||
ModuleSanitizerCoverage ModuleSancov(Options
|
ModuleSanitizerCoverage ModuleSancov(Options
|
||||||
#if LLVM_MAJOR > 10
|
#if (LLVM_VERSION_MAJOR >= 11)
|
||||||
,
|
,
|
||||||
Allowlist.get(), Blocklist.get()
|
Allowlist.get(), Blocklist.get()
|
||||||
#endif
|
#endif
|
||||||
@ -283,7 +284,7 @@ PreservedAnalyses ModuleSanitizerCoveragePass::run(Module & M,
|
|||||||
ModuleAnalysisManager &MAM) {
|
ModuleAnalysisManager &MAM) {
|
||||||
|
|
||||||
ModuleSanitizerCoverage ModuleSancov(Options
|
ModuleSanitizerCoverage ModuleSancov(Options
|
||||||
#if LLVM_MAJOR > 10
|
#if (LLVM_VERSION_MAJOR >= 11)
|
||||||
,
|
,
|
||||||
Allowlist.get(), Blocklist.get()
|
Allowlist.get(), Blocklist.get()
|
||||||
#endif
|
#endif
|
||||||
@ -749,7 +750,7 @@ GlobalVariable *ModuleSanitizerCoverage::CreateFunctionLocalArrayInSection(
|
|||||||
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
|
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
|
||||||
Constant::getNullValue(ArrayTy), "__sancov_gen_");
|
Constant::getNullValue(ArrayTy), "__sancov_gen_");
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 12
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
if (TargetTriple.supportsCOMDAT() &&
|
if (TargetTriple.supportsCOMDAT() &&
|
||||||
(TargetTriple.isOSBinFormatELF() || !F.isInterposable()))
|
(TargetTriple.isOSBinFormatELF() || !F.isInterposable()))
|
||||||
if (auto Comdat = getOrCreateFunctionComdat(F, TargetTriple))
|
if (auto Comdat = getOrCreateFunctionComdat(F, TargetTriple))
|
||||||
@ -762,7 +763,8 @@ GlobalVariable *ModuleSanitizerCoverage::CreateFunctionLocalArrayInSection(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Array->setSection(getSectionName(Section));
|
Array->setSection(getSectionName(Section));
|
||||||
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
|
#if (LLVM_VERSION_MAJOR >= 11) || \
|
||||||
|
(LLVM_VERSION_MAJOR == 10 && LLVM_VERSION_MINOR >= 1)
|
||||||
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedSize()));
|
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedSize()));
|
||||||
#else
|
#else
|
||||||
Array->setAlignment(Align(4)); // cheating
|
Array->setAlignment(Align(4)); // cheating
|
||||||
@ -868,7 +870,7 @@ bool ModuleSanitizerCoverage::InjectCoverage(Function & F,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LLVM__MAJOR > 11
|
#if (LLVM_VERSION_MAJOR >= 12)
|
||||||
else if (t->getTypeID() == llvm::Type::FixedVectorTyID) {
|
else if (t->getTypeID() == llvm::Type::FixedVectorTyID) {
|
||||||
|
|
||||||
FixedVectorType *tt = dyn_cast<FixedVectorType>(t);
|
FixedVectorType *tt = dyn_cast<FixedVectorType>(t);
|
||||||
@ -962,7 +964,7 @@ bool ModuleSanitizerCoverage::InjectCoverage(Function & F,
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 13
|
#if LLVM_VERSION_MAJOR >= 14
|
||||||
if (t->getTypeID() == llvm::Type::FixedVectorTyID) {
|
if (t->getTypeID() == llvm::Type::FixedVectorTyID) {
|
||||||
|
|
||||||
FixedVectorType *tt = dyn_cast<FixedVectorType>(t);
|
FixedVectorType *tt = dyn_cast<FixedVectorType>(t);
|
||||||
@ -1484,7 +1486,7 @@ INITIALIZE_PASS_END(ModuleSanitizerCoverageLegacyPass, "sancov",
|
|||||||
|
|
||||||
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
||||||
const SanitizerCoverageOptions &Options
|
const SanitizerCoverageOptions &Options
|
||||||
#if LLVM_MAJOR > 10
|
#if (LLVM_VERSION_MAJOR >= 11)
|
||||||
,
|
,
|
||||||
const std::vector<std::string> &AllowlistFiles,
|
const std::vector<std::string> &AllowlistFiles,
|
||||||
const std::vector<std::string> &BlocklistFiles
|
const std::vector<std::string> &BlocklistFiles
|
||||||
@ -1492,7 +1494,7 @@ ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
return new ModuleSanitizerCoverageLegacyPass(Options
|
return new ModuleSanitizerCoverageLegacyPass(Options
|
||||||
#if LLVM_MAJOR > 10
|
#if (LLVM_VERSION_MAJOR >= 11)
|
||||||
,
|
,
|
||||||
AllowlistFiles, BlocklistFiles
|
AllowlistFiles, BlocklistFiles
|
||||||
#endif
|
#endif
|
||||||
|
@ -281,7 +281,7 @@ void scanForDangerousFunctions(llvm::Module *M) {
|
|||||||
|
|
||||||
if (!M) return;
|
if (!M) return;
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
|
||||||
|
|
||||||
for (GlobalIFunc &IF : M->ifuncs()) {
|
for (GlobalIFunc &IF : M->ifuncs()) {
|
||||||
|
@ -116,14 +116,14 @@ bool AFLcheckIfInstrument::runOnModule(Module &M) {
|
|||||||
|
|
||||||
auto & Ctx = F.getContext();
|
auto & Ctx = F.getContext();
|
||||||
AttributeList Attrs = F.getAttributes();
|
AttributeList Attrs = F.getAttributes();
|
||||||
#if LLVM_VERSION_MAJOR < 14
|
#if LLVM_VERSION_MAJOR >= 14
|
||||||
|
AttributeList NewAttrs = Attrs.addFnAttribute(Ctx, "skipinstrument");
|
||||||
|
F.setAttributes(NewAttrs);
|
||||||
|
#else
|
||||||
AttrBuilder NewAttrs;
|
AttrBuilder NewAttrs;
|
||||||
NewAttrs.addAttribute("skipinstrument");
|
NewAttrs.addAttribute("skipinstrument");
|
||||||
F.setAttributes(
|
F.setAttributes(
|
||||||
Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
|
Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
|
||||||
#else
|
|
||||||
AttributeList NewAttrs = Attrs.addFnAttribute(Ctx, "skipinstrument");
|
|
||||||
F.setAttributes(NewAttrs);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ typedef long double max_align_t;
|
|||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
#include "llvm/IR/CFG.h"
|
#include "llvm/IR/CFG.h"
|
||||||
@ -114,7 +114,7 @@ uint64_t PowerOf2Ceil(unsigned in) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #if LLVM_VERSION_STRING >= "4.0.1" */
|
/* #if LLVM_VERSION_STRING >= "4.0.1" */
|
||||||
#if LLVM_VERSION_MAJOR > 4 || \
|
#if LLVM_VERSION_MAJOR >= 5 || \
|
||||||
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
|
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
|
||||||
#define AFL_HAVE_VECTOR_INTRINSICS 1
|
#define AFL_HAVE_VECTOR_INTRINSICS 1
|
||||||
#endif
|
#endif
|
||||||
@ -662,22 +662,7 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
/* Update bitmap */
|
/* Update bitmap */
|
||||||
|
|
||||||
if (use_threadsafe_counters) { /* Atomic */
|
if (use_threadsafe_counters) { /* Atomic */
|
||||||
/*
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
|
||||||
if (neverZero_counters_str !=
|
|
||||||
NULL) { // with llvm 9 we make this the default as the bug
|
|
||||||
in llvm
|
|
||||||
// is then fixed
|
|
||||||
#else
|
|
||||||
if (!skip_nozero) {
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// register MapPtrIdx in a todo list
|
|
||||||
todo.push_back(MapPtrIdx);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
*/
|
|
||||||
IRB.CreateAtomicRMW(llvm::AtomicRMWInst::BinOp::Add, MapPtrIdx, One,
|
IRB.CreateAtomicRMW(llvm::AtomicRMWInst::BinOp::Add, MapPtrIdx, One,
|
||||||
#if LLVM_VERSION_MAJOR >= 13
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
llvm::MaybeAlign(1),
|
llvm::MaybeAlign(1),
|
||||||
@ -696,13 +681,12 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
|
|
||||||
Value *Incr = IRB.CreateAdd(Counter, One);
|
Value *Incr = IRB.CreateAdd(Counter, One);
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
if (neverZero_counters_str !=
|
|
||||||
NULL) { // with llvm 9 we make this the default as the bug in llvm
|
|
||||||
// is then fixed
|
|
||||||
#else
|
|
||||||
if (!skip_nozero) {
|
if (!skip_nozero) {
|
||||||
|
|
||||||
|
#else
|
||||||
|
if (neverZero_counters_str != NULL) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* hexcoder: Realize a counter that skips zero during overflow.
|
/* hexcoder: Realize a counter that skips zero during overflow.
|
||||||
* Once this counter reaches its maximum value, it next increments to
|
* Once this counter reaches its maximum value, it next increments to
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
@ -66,11 +66,11 @@ class CmpLogInstructions : public ModulePass {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 4
|
#if LLVM_VERSION_MAJOR >= 4
|
||||||
const char *getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
StringRef getPassName() const override {
|
const char *getPassName() const override {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return "cmplog instructions";
|
return "cmplog instructions";
|
||||||
@ -113,10 +113,10 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
|
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
|
||||||
IntegerType *Int128Ty = IntegerType::getInt128Ty(C);
|
IntegerType *Int128Ty = IntegerType::getInt128Ty(C);
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty,
|
c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -125,16 +125,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns1 = cast<Function>(c1);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns1 = c1;
|
FunctionCallee cmplogHookIns1 = c1;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns1 = cast<Function>(c1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty,
|
c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -143,16 +143,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns2 = cast<Function>(c2);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns2 = c2;
|
FunctionCallee cmplogHookIns2 = c2;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns2 = cast<Function>(c2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty,
|
c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -161,16 +161,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns4 = cast<Function>(c4);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns4 = c4;
|
FunctionCallee cmplogHookIns4 = c4;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns4 = cast<Function>(c4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty,
|
c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -179,16 +179,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns8 = cast<Function>(c8);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns8 = c8;
|
FunctionCallee cmplogHookIns8 = c8;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns8 = cast<Function>(c8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c16 = M.getOrInsertFunction("__cmplog_ins_hook16", VoidTy, Int128Ty,
|
c16 = M.getOrInsertFunction("__cmplog_ins_hook16", VoidTy, Int128Ty,
|
||||||
Int128Ty, Int8Ty
|
Int128Ty, Int8Ty
|
||||||
@ -203,10 +203,10 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
FunctionCallee cmplogHookIns16 = c16;
|
FunctionCallee cmplogHookIns16 = c16;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
cN = M.getOrInsertFunction("__cmplog_ins_hookN", VoidTy, Int128Ty,
|
cN = M.getOrInsertFunction("__cmplog_ins_hookN", VoidTy, Int128Ty,
|
||||||
Int128Ty, Int8Ty, Int8Ty
|
Int128Ty, Int8Ty, Int8Ty
|
||||||
@ -215,10 +215,10 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookInsN = cast<Function>(cN);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookInsN = cN;
|
FunctionCallee cmplogHookInsN = cN;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookInsN = cast<Function>(cN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GlobalVariable *AFLCmplogPtr = M.getNamedGlobal("__afl_cmp_map");
|
GlobalVariable *AFLCmplogPtr = M.getNamedGlobal("__afl_cmp_map");
|
||||||
@ -338,7 +338,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LLVM_MAJOR > 11
|
#if (LLVM_VERSION_MAJOR >= 12)
|
||||||
vector_cnt = tt->getElementCount().getKnownMinValue();
|
vector_cnt = tt->getElementCount().getKnownMinValue();
|
||||||
ty0 = tt->getElementType();
|
ty0 = tt->getElementType();
|
||||||
#endif
|
#endif
|
||||||
@ -359,7 +359,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
max_size = 80;
|
max_size = 80;
|
||||||
else if (ty0->isFP128Ty() || ty0->isPPC_FP128Ty())
|
else if (ty0->isFP128Ty() || ty0->isPPC_FP128Ty())
|
||||||
max_size = 128;
|
max_size = 128;
|
||||||
#if LLVM_MAJOR > 11
|
#if (LLVM_VERSION_MAJOR >= 12)
|
||||||
else if (ty0->getTypeID() != llvm::Type::PointerTyID && !be_quiet)
|
else if (ty0->getTypeID() != llvm::Type::PointerTyID && !be_quiet)
|
||||||
fprintf(stderr, "Warning: unsupported cmp type for cmplog: %u!\n",
|
fprintf(stderr, "Warning: unsupported cmp type for cmplog: %u!\n",
|
||||||
ty0->getTypeID());
|
ty0->getTypeID());
|
||||||
@ -371,7 +371,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
|
|
||||||
if (ty0->isVectorTy()) {
|
if (ty0->isVectorTy()) {
|
||||||
|
|
||||||
#if LLVM_MAJOR > 11
|
#if (LLVM_VERSION_MAJOR >= 12)
|
||||||
VectorType *tt = dyn_cast<VectorType>(ty0);
|
VectorType *tt = dyn_cast<VectorType>(ty0);
|
||||||
if (!tt) {
|
if (!tt) {
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
#if LLVM_MAJOR > 11
|
#if (LLVM_VERSION_MAJOR >= 12)
|
||||||
if (ty0->getTypeID() != llvm::Type::PointerTyID && !be_quiet) {
|
if (ty0->getTypeID() != llvm::Type::PointerTyID && !be_quiet) {
|
||||||
|
|
||||||
fprintf(stderr, "Warning: unsupported cmp type for cmplog: %u\n",
|
fprintf(stderr, "Warning: unsupported cmp type for cmplog: %u\n",
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
@ -65,11 +65,11 @@ class CmpLogRoutines : public ModulePass {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 4
|
#if LLVM_VERSION_MAJOR >= 4
|
||||||
const char *getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
StringRef getPassName() const override {
|
const char *getPassName() const override {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return "cmplog routines";
|
return "cmplog routines";
|
||||||
@ -97,10 +97,10 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
|
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
|
||||||
PointerType *i8PtrTy = PointerType::get(Int8Ty, 0);
|
PointerType *i8PtrTy = PointerType::get(Int8Ty, 0);
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c = M.getOrInsertFunction("__cmplog_rtn_hook", VoidTy, i8PtrTy, i8PtrTy
|
c = M.getOrInsertFunction("__cmplog_rtn_hook", VoidTy, i8PtrTy, i8PtrTy
|
||||||
#if LLVM_VERSION_MAJOR < 5
|
#if LLVM_VERSION_MAJOR < 5
|
||||||
@ -108,16 +108,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookFn = cast<Function>(c);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookFn = c;
|
FunctionCallee cmplogHookFn = c;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookFn = cast<Function>(c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c1 = M.getOrInsertFunction("__cmplog_rtn_llvm_stdstring_stdstring",
|
c1 = M.getOrInsertFunction("__cmplog_rtn_llvm_stdstring_stdstring",
|
||||||
VoidTy, i8PtrTy, i8PtrTy
|
VoidTy, i8PtrTy, i8PtrTy
|
||||||
@ -126,16 +126,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogLlvmStdStd = cast<Function>(c1);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogLlvmStdStd = c1;
|
FunctionCallee cmplogLlvmStdStd = c1;
|
||||||
|
#else
|
||||||
|
Function *cmplogLlvmStdStd = cast<Function>(c1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c2 = M.getOrInsertFunction("__cmplog_rtn_llvm_stdstring_cstring", VoidTy,
|
c2 = M.getOrInsertFunction("__cmplog_rtn_llvm_stdstring_cstring", VoidTy,
|
||||||
i8PtrTy, i8PtrTy
|
i8PtrTy, i8PtrTy
|
||||||
@ -144,16 +144,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogLlvmStdC = cast<Function>(c2);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogLlvmStdC = c2;
|
FunctionCallee cmplogLlvmStdC = c2;
|
||||||
|
#else
|
||||||
|
Function *cmplogLlvmStdC = cast<Function>(c2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c3 = M.getOrInsertFunction("__cmplog_rtn_gcc_stdstring_stdstring", VoidTy,
|
c3 = M.getOrInsertFunction("__cmplog_rtn_gcc_stdstring_stdstring", VoidTy,
|
||||||
i8PtrTy, i8PtrTy
|
i8PtrTy, i8PtrTy
|
||||||
@ -162,16 +162,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogGccStdStd = cast<Function>(c3);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogGccStdStd = c3;
|
FunctionCallee cmplogGccStdStd = c3;
|
||||||
|
#else
|
||||||
|
Function *cmplogGccStdStd = cast<Function>(c3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c4 = M.getOrInsertFunction("__cmplog_rtn_gcc_stdstring_cstring", VoidTy,
|
c4 = M.getOrInsertFunction("__cmplog_rtn_gcc_stdstring_cstring", VoidTy,
|
||||||
i8PtrTy, i8PtrTy
|
i8PtrTy, i8PtrTy
|
||||||
@ -180,16 +180,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogGccStdC = cast<Function>(c4);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogGccStdC = c4;
|
FunctionCallee cmplogGccStdC = c4;
|
||||||
|
#else
|
||||||
|
Function *cmplogGccStdC = cast<Function>(c4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c5 = M.getOrInsertFunction("__cmplog_rtn_hook_n", VoidTy, i8PtrTy,
|
c5 = M.getOrInsertFunction("__cmplog_rtn_hook_n", VoidTy, i8PtrTy,
|
||||||
i8PtrTy, Int64Ty
|
i8PtrTy, Int64Ty
|
||||||
@ -198,16 +198,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookFnN = cast<Function>(c5);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookFnN = c5;
|
FunctionCallee cmplogHookFnN = c5;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookFnN = cast<Function>(c5);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c6 = M.getOrInsertFunction("__cmplog_rtn_hook_strn", VoidTy, i8PtrTy,
|
c6 = M.getOrInsertFunction("__cmplog_rtn_hook_strn", VoidTy, i8PtrTy,
|
||||||
i8PtrTy, Int64Ty
|
i8PtrTy, Int64Ty
|
||||||
@ -216,16 +216,16 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookFnStrN = cast<Function>(c6);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookFnStrN = c6;
|
FunctionCallee cmplogHookFnStrN = c6;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookFnStrN = cast<Function>(c6);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c7 = M.getOrInsertFunction("__cmplog_rtn_hook_str", VoidTy, i8PtrTy,
|
c7 = M.getOrInsertFunction("__cmplog_rtn_hook_str", VoidTy, i8PtrTy,
|
||||||
i8PtrTy
|
i8PtrTy
|
||||||
@ -234,10 +234,10 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookFnStr = cast<Function>(c7);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookFnStr = c7;
|
FunctionCallee cmplogHookFnStr = c7;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookFnStr = cast<Function>(c7);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GlobalVariable *AFLCmplogPtr = M.getNamedGlobal("__afl_cmp_map");
|
GlobalVariable *AFLCmplogPtr = M.getNamedGlobal("__afl_cmp_map");
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
@ -112,10 +112,10 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
|
IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
|
||||||
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
|
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty,
|
c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -124,16 +124,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns1 = cast<Function>(c1);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns1 = c1;
|
FunctionCallee cmplogHookIns1 = c1;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns1 = cast<Function>(c1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty,
|
c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -142,16 +142,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns2 = cast<Function>(c2);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns2 = c2;
|
FunctionCallee cmplogHookIns2 = c2;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns2 = cast<Function>(c2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty,
|
c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -160,16 +160,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns4 = cast<Function>(c4);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns4 = c4;
|
FunctionCallee cmplogHookIns4 = c4;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns4 = cast<Function>(c4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty,
|
c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty,
|
||||||
Int8Ty
|
Int8Ty
|
||||||
@ -178,10 +178,10 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *cmplogHookIns8 = cast<Function>(c8);
|
|
||||||
#else
|
|
||||||
FunctionCallee cmplogHookIns8 = c8;
|
FunctionCallee cmplogHookIns8 = c8;
|
||||||
|
#else
|
||||||
|
Function *cmplogHookIns8 = cast<Function>(c8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GlobalVariable *AFLCmplogPtr = M.getNamedGlobal("__afl_cmp_map");
|
GlobalVariable *AFLCmplogPtr = M.getNamedGlobal("__afl_cmp_map");
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
@ -64,11 +64,11 @@ class CompareTransform : public ModulePass {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 4
|
#if LLVM_VERSION_MAJOR >= 4
|
||||||
const char *getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
StringRef getPassName() const override {
|
const char *getPassName() const override {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return "transforms compare functions";
|
return "transforms compare functions";
|
||||||
@ -100,17 +100,17 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
|||||||
IntegerType * Int32Ty = IntegerType::getInt32Ty(C);
|
IntegerType * Int32Ty = IntegerType::getInt32Ty(C);
|
||||||
IntegerType * Int64Ty = IntegerType::getInt64Ty(C);
|
IntegerType * Int64Ty = IntegerType::getInt64Ty(C);
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Function *tolowerFn;
|
|
||||||
#else
|
|
||||||
FunctionCallee tolowerFn;
|
FunctionCallee tolowerFn;
|
||||||
|
#else
|
||||||
|
Function * tolowerFn;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
Constant *
|
|
||||||
#else
|
|
||||||
FunctionCallee
|
FunctionCallee
|
||||||
|
#else
|
||||||
|
Constant *
|
||||||
#endif
|
#endif
|
||||||
c = M.getOrInsertFunction("tolower", Int32Ty, Int32Ty
|
c = M.getOrInsertFunction("tolower", Int32Ty, Int32Ty
|
||||||
#if LLVM_VERSION_MAJOR < 5
|
#if LLVM_VERSION_MAJOR < 5
|
||||||
@ -118,10 +118,10 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
|||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LLVM_VERSION_MAJOR < 9
|
#if LLVM_VERSION_MAJOR >= 9
|
||||||
tolowerFn = cast<Function>(c);
|
|
||||||
#else
|
|
||||||
tolowerFn = c;
|
tolowerFn = c;
|
||||||
|
#else
|
||||||
|
tolowerFn = cast<Function>(c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -496,10 +496,10 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
|||||||
PHINode *PN = PHINode::Create(
|
PHINode *PN = PHINode::Create(
|
||||||
Int32Ty, (next_lenchk_bb ? 2 : 1) * unrollLen + 1, "cmp_phi");
|
Int32Ty, (next_lenchk_bb ? 2 : 1) * unrollLen + 1, "cmp_phi");
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 8
|
#if LLVM_VERSION_MAJOR >= 8
|
||||||
TerminatorInst *term = bb->getTerminator();
|
|
||||||
#else
|
|
||||||
Instruction *term = bb->getTerminator();
|
Instruction *term = bb->getTerminator();
|
||||||
|
#else
|
||||||
|
TerminatorInst *term = bb->getTerminator();
|
||||||
#endif
|
#endif
|
||||||
BranchInst::Create(next_lenchk_bb ? next_lenchk_bb : next_cmp_bb, bb);
|
BranchInst::Create(next_lenchk_bb ? next_lenchk_bb : next_cmp_bb, bb);
|
||||||
term->eraseFromParent();
|
term->eraseFromParent();
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
|
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
@ -796,7 +796,7 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
|
|||||||
|
|
||||||
LLVMContext &C = M.getContext();
|
LLVMContext &C = M.getContext();
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7)
|
||||||
const DataLayout &dl = M.getDataLayout();
|
const DataLayout &dl = M.getDataLayout();
|
||||||
|
|
||||||
@ -1398,7 +1398,7 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
|||||||
|
|
||||||
bool brokenDebug = false;
|
bool brokenDebug = false;
|
||||||
if (verifyModule(M, &errs()
|
if (verifyModule(M, &errs()
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
|
||||||
,
|
,
|
||||||
&brokenDebug // 9th May 2016
|
&brokenDebug // 9th May 2016
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||||
#include "llvm/IR/Verifier.h"
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
@ -369,10 +369,10 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) {
|
|||||||
CaseVector Cases;
|
CaseVector Cases;
|
||||||
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e;
|
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e;
|
||||||
++i)
|
++i)
|
||||||
#if LLVM_VERSION_MAJOR < 5
|
#if LLVM_VERSION_MAJOR >= 5
|
||||||
Cases.push_back(CaseExpr(i.getCaseValue(), i.getCaseSuccessor()));
|
|
||||||
#else
|
|
||||||
Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
|
Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
|
||||||
|
#else
|
||||||
|
Cases.push_back(CaseExpr(i.getCaseValue(), i.getCaseSuccessor()));
|
||||||
#endif
|
#endif
|
||||||
/* bugfix thanks to pbst
|
/* bugfix thanks to pbst
|
||||||
* round up bytesChecked (in case getBitWidth() % 8 != 0) */
|
* round up bytesChecked (in case getBitWidth() % 8 != 0) */
|
||||||
|
26
src/afl-cc.c
26
src/afl-cc.c
@ -574,7 +574,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
if (instrument_mode == INSTRUMENT_PCGUARD) {
|
if (instrument_mode == INSTRUMENT_PCGUARD) {
|
||||||
|
|
||||||
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
|
#if LLVM_MAJOR >= 11 || (LLVM_MAJOR == 10 && LLVM_MINOR >= 1)
|
||||||
#if defined __ANDROID__ || ANDROID
|
#if defined __ANDROID__ || ANDROID
|
||||||
cc_params[cc_par_cnt++] = "-fsanitize-coverage=trace-pc-guard";
|
cc_params[cc_par_cnt++] = "-fsanitize-coverage=trace-pc-guard";
|
||||||
instrument_mode = INSTRUMENT_LLVMNATIVE;
|
instrument_mode = INSTRUMENT_LLVMNATIVE;
|
||||||
@ -1167,7 +1167,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LLVM_MAJOR > 2)
|
#if (LLVM_MAJOR >= 3)
|
||||||
|
|
||||||
if ((ptr = find_object("SanitizerCoverageLTO.so", argv[0])) != NULL) {
|
if ((ptr = find_object("SanitizerCoverageLTO.so", argv[0])) != NULL) {
|
||||||
|
|
||||||
@ -1196,7 +1196,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LLVM_MAJOR > 2)
|
#if (LLVM_MAJOR >= 3)
|
||||||
|
|
||||||
if (strncmp(callname, "afl-clang-fast", 14) == 0) {
|
if (strncmp(callname, "afl-clang-fast", 14) == 0) {
|
||||||
|
|
||||||
@ -1724,8 +1724,8 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
compiler_mode == LTO ? " [SELECTED]" : "",
|
compiler_mode == LTO ? " [SELECTED]" : "",
|
||||||
have_llvm ? "AVAILABLE" : "unavailable!",
|
have_llvm ? "AVAILABLE" : "unavailable!",
|
||||||
compiler_mode == LLVM ? " [SELECTED]" : "",
|
compiler_mode == LLVM ? " [SELECTED]" : "",
|
||||||
LLVM_MAJOR > 6 ? "DEFAULT" : " ",
|
LLVM_MAJOR >= 7 ? "DEFAULT" : " ",
|
||||||
LLVM_MAJOR > 6 ? " " : "DEFAULT",
|
LLVM_MAJOR >= 7 ? " " : "DEFAULT",
|
||||||
have_gcc_plugin ? "AVAILABLE" : "unavailable!",
|
have_gcc_plugin ? "AVAILABLE" : "unavailable!",
|
||||||
compiler_mode == GCC_PLUGIN ? " [SELECTED]" : "",
|
compiler_mode == GCC_PLUGIN ? " [SELECTED]" : "",
|
||||||
have_gcc ? "AVAILABLE" : "unavailable!",
|
have_gcc ? "AVAILABLE" : "unavailable!",
|
||||||
@ -1826,12 +1826,12 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
" AFL_GCC_INSTRUMENT_FILE: enable selective instrumentation by "
|
" AFL_GCC_INSTRUMENT_FILE: enable selective instrumentation by "
|
||||||
"filename\n");
|
"filename\n");
|
||||||
|
|
||||||
#if LLVM_MAJOR < 9
|
#if LLVM_MAJOR >= 9
|
||||||
#define COUNTER_BEHAVIOUR \
|
|
||||||
" AFL_LLVM_NOT_ZERO: use cycling trace counters that skip zero\n"
|
|
||||||
#else
|
|
||||||
#define COUNTER_BEHAVIOUR \
|
#define COUNTER_BEHAVIOUR \
|
||||||
" AFL_LLVM_SKIP_NEVERZERO: do not skip zero on trace counters\n"
|
" AFL_LLVM_SKIP_NEVERZERO: do not skip zero on trace counters\n"
|
||||||
|
#else
|
||||||
|
#define COUNTER_BEHAVIOUR \
|
||||||
|
" AFL_LLVM_NOT_ZERO: use cycling trace counters that skip zero\n"
|
||||||
#endif
|
#endif
|
||||||
if (have_llvm)
|
if (have_llvm)
|
||||||
SAYF(
|
SAYF(
|
||||||
@ -1905,7 +1905,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
"consult the README.md, especially section 3.1 about instrumenting "
|
"consult the README.md, especially section 3.1 about instrumenting "
|
||||||
"targets.\n\n");
|
"targets.\n\n");
|
||||||
|
|
||||||
#if (LLVM_MAJOR > 2)
|
#if (LLVM_MAJOR >= 3)
|
||||||
if (have_lto)
|
if (have_lto)
|
||||||
SAYF("afl-cc LTO with ld=%s %s\n", AFL_REAL_LD, AFL_CLANG_FLTO);
|
SAYF("afl-cc LTO with ld=%s %s\n", AFL_REAL_LD, AFL_CLANG_FLTO);
|
||||||
if (have_llvm)
|
if (have_llvm)
|
||||||
@ -1967,9 +1967,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
if (instrument_mode == 0 && compiler_mode < GCC_PLUGIN) {
|
if (instrument_mode == 0 && compiler_mode < GCC_PLUGIN) {
|
||||||
|
|
||||||
#if LLVM_MAJOR <= 6
|
#if LLVM_MAJOR >= 7
|
||||||
instrument_mode = INSTRUMENT_AFL;
|
|
||||||
#else
|
|
||||||
#if LLVM_MAJOR < 11 && (LLVM_MAJOR < 10 || LLVM_MINOR < 1)
|
#if LLVM_MAJOR < 11 && (LLVM_MAJOR < 10 || LLVM_MINOR < 1)
|
||||||
if (have_instr_env) {
|
if (have_instr_env) {
|
||||||
|
|
||||||
@ -1984,6 +1982,8 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
#endif
|
#endif
|
||||||
instrument_mode = INSTRUMENT_PCGUARD;
|
instrument_mode = INSTRUMENT_PCGUARD;
|
||||||
|
|
||||||
|
#else
|
||||||
|
instrument_mode = INSTRUMENT_AFL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user