mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-16 03:48:08 +00:00
fixed for LTO llvm 11
This commit is contained in:
@ -165,12 +165,16 @@ class ModuleSanitizerCoverage {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleSanitizerCoverage(
|
ModuleSanitizerCoverage(
|
||||||
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
|
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions())
|
||||||
|
: Options(OverrideFromCL(Options)) {
|
||||||
|
|
||||||
|
/* ,
|
||||||
const SpecialCaseList * Allowlist = nullptr,
|
const SpecialCaseList * Allowlist = nullptr,
|
||||||
const SpecialCaseList * Blocklist = nullptr)
|
const SpecialCaseList * Blocklist = nullptr)
|
||||||
: Options(OverrideFromCL(Options)),
|
,
|
||||||
Allowlist(Allowlist),
|
Allowlist(Allowlist),
|
||||||
Blocklist(Blocklist) {
|
Blocklist(Blocklist) {
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,26 +228,26 @@ class ModuleSanitizerCoverage {
|
|||||||
SanitizerCoverageOptions Options;
|
SanitizerCoverageOptions Options;
|
||||||
|
|
||||||
// afl++ START
|
// afl++ START
|
||||||
const SpecialCaseList * Allowlist;
|
//const SpecialCaseList * Allowlist;
|
||||||
const SpecialCaseList * Blocklist;
|
//const SpecialCaseList * Blocklist;
|
||||||
uint32_t autodictionary = 1;
|
uint32_t autodictionary = 1;
|
||||||
uint32_t inst = 0;
|
uint32_t inst = 0;
|
||||||
uint32_t afl_global_id = 0;
|
uint32_t afl_global_id = 0;
|
||||||
uint64_t map_addr = 0;
|
uint64_t map_addr = 0;
|
||||||
char * skip_nozero;
|
char * skip_nozero = NULL;
|
||||||
std::vector<BasicBlock *> BlockList;
|
std::vector<BasicBlock *> BlockList;
|
||||||
DenseMap<Value *, std::string *> valueMap;
|
DenseMap<Value *, std::string *> valueMap;
|
||||||
std::vector<std::string> dictionary;
|
std::vector<std::string> dictionary;
|
||||||
IntegerType * Int8Tyi;
|
IntegerType * Int8Tyi = NULL;
|
||||||
IntegerType * Int32Tyi;
|
IntegerType * Int32Tyi = NULL;
|
||||||
IntegerType * Int64Tyi;
|
IntegerType * Int64Tyi = NULL;
|
||||||
ConstantInt * Zero;
|
ConstantInt * Zero = NULL;
|
||||||
ConstantInt * One;
|
ConstantInt * One = NULL;
|
||||||
LLVMContext * Ct;
|
LLVMContext * Ct = NULL;
|
||||||
Module * Mo;
|
Module * Mo = NULL;
|
||||||
GlobalVariable * AFLMapPtr;
|
GlobalVariable * AFLMapPtr = NULL;
|
||||||
Value * MapPtrFixed;
|
Value * MapPtrFixed = NULL;
|
||||||
FILE * documentFile;
|
FILE * documentFile = NULL;
|
||||||
// afl++ END
|
// afl++ END
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -266,19 +270,20 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModuleSanitizerCoverageLegacyPass(
|
ModuleSanitizerCoverageLegacyPass(
|
||||||
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
|
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions())
|
||||||
|
: ModulePass(ID), Options(Options) {
|
||||||
|
/* ,
|
||||||
const std::vector<std::string> &AllowlistFiles =
|
const std::vector<std::string> &AllowlistFiles =
|
||||||
std::vector<std::string>(),
|
std::vector<std::string>(),
|
||||||
const std::vector<std::string> &BlocklistFiles =
|
const std::vector<std::string> &BlocklistFiles =
|
||||||
std::vector<std::string>())
|
std::vector<std::string>())
|
||||||
: ModulePass(ID), Options(Options) {
|
|
||||||
|
|
||||||
if (AllowlistFiles.size() > 0)
|
if (AllowlistFiles.size() > 0)
|
||||||
Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
|
Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
|
||||||
*vfs::getRealFileSystem());
|
*vfs::getRealFileSystem());
|
||||||
if (BlocklistFiles.size() > 0)
|
if (BlocklistFiles.size() > 0)
|
||||||
Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
|
Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
|
||||||
*vfs::getRealFileSystem());
|
*vfs::getRealFileSystem());
|
||||||
|
*/
|
||||||
initializeModuleSanitizerCoverageLegacyPassPass(
|
initializeModuleSanitizerCoverageLegacyPassPass(
|
||||||
*PassRegistry::getPassRegistry());
|
*PassRegistry::getPassRegistry());
|
||||||
|
|
||||||
@ -286,8 +291,8 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override {
|
bool runOnModule(Module &M) override {
|
||||||
|
|
||||||
ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
|
ModuleSanitizerCoverage ModuleSancov(Options);
|
||||||
Blocklist.get());
|
// , Allowlist.get(), Blocklist.get());
|
||||||
auto DTCallback = [this](Function &F) -> const DominatorTree * {
|
auto DTCallback = [this](Function &F) -> const DominatorTree * {
|
||||||
|
|
||||||
return &this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
|
return &this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
|
||||||
@ -308,8 +313,8 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
private:
|
private:
|
||||||
SanitizerCoverageOptions Options;
|
SanitizerCoverageOptions Options;
|
||||||
|
|
||||||
std::unique_ptr<SpecialCaseList> Allowlist;
|
//std::unique_ptr<SpecialCaseList> Allowlist;
|
||||||
std::unique_ptr<SpecialCaseList> Blocklist;
|
//std::unique_ptr<SpecialCaseList> Blocklist;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -318,8 +323,8 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
PreservedAnalyses ModuleSanitizerCoveragePass::run(Module & M,
|
PreservedAnalyses ModuleSanitizerCoveragePass::run(Module & M,
|
||||||
ModuleAnalysisManager &MAM) {
|
ModuleAnalysisManager &MAM) {
|
||||||
|
|
||||||
ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
|
ModuleSanitizerCoverage ModuleSancov(Options);
|
||||||
Blocklist.get());
|
//Allowlist.get(), Blocklist.get());
|
||||||
auto &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
|
auto &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
|
||||||
auto DTCallback = [&FAM](Function &F) -> const DominatorTree * {
|
auto DTCallback = [&FAM](Function &F) -> const DominatorTree * {
|
||||||
|
|
||||||
@ -369,12 +374,17 @@ bool ModuleSanitizerCoverage::instrumentModule(
|
|||||||
Module &M, DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
|
Module &M, DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
|
||||||
|
|
||||||
if (Options.CoverageType == SanitizerCoverageOptions::SCK_None) return false;
|
if (Options.CoverageType == SanitizerCoverageOptions::SCK_None) return false;
|
||||||
|
/*
|
||||||
if (Allowlist &&
|
if (Allowlist &&
|
||||||
!Allowlist->inSection("coverage", "src", M.getSourceFileName()))
|
!Allowlist->inSection("coverage", "src", M.getSourceFileName()))
|
||||||
return false;
|
return false;
|
||||||
if (Blocklist &&
|
if (Blocklist &&
|
||||||
Blocklist->inSection("coverage", "src", M.getSourceFileName()))
|
Blocklist->inSection("coverage", "src", M.getSourceFileName()))
|
||||||
return false;
|
return false;
|
||||||
|
*/
|
||||||
|
BlockList.clear();
|
||||||
|
valueMap.clear();
|
||||||
|
dictionary.clear();
|
||||||
C = &(M.getContext());
|
C = &(M.getContext());
|
||||||
DL = &M.getDataLayout();
|
DL = &M.getDataLayout();
|
||||||
CurModule = &M;
|
CurModule = &M;
|
||||||
@ -1098,9 +1108,9 @@ void ModuleSanitizerCoverage::instrumentFunction(
|
|||||||
if (F.hasPersonalityFn() &&
|
if (F.hasPersonalityFn() &&
|
||||||
isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
|
isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
|
||||||
return;
|
return;
|
||||||
if (Allowlist && !Allowlist->inSection("coverage", "fun", F.getName()))
|
//if (Allowlist && !Allowlist->inSection("coverage", "fun", F.getName()))
|
||||||
return;
|
// return;
|
||||||
if (Blocklist && Blocklist->inSection("coverage", "fun", F.getName())) return;
|
// if (Blocklist && Blocklist->inSection("coverage", "fun", F.getName())) return;
|
||||||
|
|
||||||
// afl++ START
|
// afl++ START
|
||||||
if (!F.size()) return;
|
if (!F.size()) return;
|
||||||
@ -1306,7 +1316,11 @@ void ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
|
|||||||
if (Options.TracePC) {
|
if (Options.TracePC) {
|
||||||
|
|
||||||
IRB.CreateCall(SanCovTracePC)
|
IRB.CreateCall(SanCovTracePC)
|
||||||
|
#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.
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1457,12 +1471,11 @@ INITIALIZE_PASS_END(ModuleSanitizerCoverageLegacyPass, "sancov",
|
|||||||
false)
|
false)
|
||||||
|
|
||||||
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
||||||
const SanitizerCoverageOptions &Options,
|
const SanitizerCoverageOptions &Options, const std::vector<std::string> &AllowlistFiles,
|
||||||
const std::vector<std::string> &AllowlistFiles,
|
|
||||||
const std::vector<std::string> &BlocklistFiles) {
|
const std::vector<std::string> &BlocklistFiles) {
|
||||||
|
|
||||||
return new ModuleSanitizerCoverageLegacyPass(Options, AllowlistFiles,
|
return new ModuleSanitizerCoverageLegacyPass(Options);
|
||||||
BlocklistFiles);
|
//, AllowlistFiles, BlocklistFiles);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,6 +851,12 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (instrument_mode == INSTRUMENT_LTO ||
|
||||||
|
instrument_mode == INSTRUMENT_CLASSIC) {
|
||||||
|
|
||||||
|
lto_mode = 1;
|
||||||
|
callname = "afl-clang-lto";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!be_quiet)
|
if (!be_quiet)
|
||||||
|
Reference in New Issue
Block a user