mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 09:41:35 +00:00
fix our PCGUARD for llvm 10.0.1
This commit is contained in:
parent
e1d37a802b
commit
28f1e94ab9
@ -15,6 +15,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
|
|||||||
- fix map detection, AFL_MAP_SIZE not needed anymore for most cases
|
- fix map detection, AFL_MAP_SIZE not needed anymore for most cases
|
||||||
- afl-cc:
|
- afl-cc:
|
||||||
- fix cmplog rtn (rare crash and not being able to gather ptr data)
|
- fix cmplog rtn (rare crash and not being able to gather ptr data)
|
||||||
|
- fix our own PCGUARD implementation to compile with llvm 10.0.1
|
||||||
- link runtime not to shared libs
|
- link runtime not to shared libs
|
||||||
- ensure shared libraries are properly built and instrumented
|
- ensure shared libraries are properly built and instrumented
|
||||||
- AFL_LLVM_INSTRUMENT_ALLOW/DENY were not implemented for LTO, added
|
- AFL_LLVM_INSTRUMENT_ALLOW/DENY were not implemented for LTO, added
|
||||||
|
@ -135,12 +135,14 @@ class ModuleSanitizerCoverage {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleSanitizerCoverage(
|
ModuleSanitizerCoverage(
|
||||||
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
|
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()
|
||||||
const SpecialCaseList * Allowlist = nullptr,
|
#if LLVM_MAJOR > 10
|
||||||
const SpecialCaseList * Blocklist = nullptr)
|
,
|
||||||
: Options(OverrideFromCL(Options)),
|
const SpecialCaseList *Allowlist = nullptr,
|
||||||
Allowlist(Allowlist),
|
const SpecialCaseList *Blocklist = nullptr
|
||||||
Blocklist(Blocklist) {
|
#endif
|
||||||
|
)
|
||||||
|
: Options(OverrideFromCL(Options)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,9 +212,6 @@ class ModuleSanitizerCoverage {
|
|||||||
|
|
||||||
SanitizerCoverageOptions Options;
|
SanitizerCoverageOptions Options;
|
||||||
|
|
||||||
const SpecialCaseList *Allowlist;
|
|
||||||
const SpecialCaseList *Blocklist;
|
|
||||||
|
|
||||||
uint32_t instr = 0;
|
uint32_t instr = 0;
|
||||||
GlobalVariable *AFLMapPtr = NULL;
|
GlobalVariable *AFLMapPtr = NULL;
|
||||||
ConstantInt * One = NULL;
|
ConstantInt * One = NULL;
|
||||||
@ -224,27 +223,17 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleSanitizerCoverageLegacyPass(
|
ModuleSanitizerCoverageLegacyPass(
|
||||||
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
|
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()
|
||||||
|
#if LLVM_VERSION_MAJOR > 10
|
||||||
|
,
|
||||||
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>()
|
||||||
|
#endif
|
||||||
|
)
|
||||||
: ModulePass(ID), Options(Options) {
|
: ModulePass(ID), Options(Options) {
|
||||||
|
|
||||||
if (AllowlistFiles.size() > 0)
|
|
||||||
Allowlist = SpecialCaseList::createOrDie(AllowlistFiles
|
|
||||||
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
|
|
||||||
,
|
|
||||||
*vfs::getRealFileSystem()
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
if (BlocklistFiles.size() > 0)
|
|
||||||
Blocklist = SpecialCaseList::createOrDie(BlocklistFiles
|
|
||||||
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
|
|
||||||
,
|
|
||||||
*vfs::getRealFileSystem()
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
initializeModuleSanitizerCoverageLegacyPassPass(
|
initializeModuleSanitizerCoverageLegacyPassPass(
|
||||||
*PassRegistry::getPassRegistry());
|
*PassRegistry::getPassRegistry());
|
||||||
|
|
||||||
@ -252,8 +241,12 @@ class ModuleSanitizerCoverageLegacyPass : public ModulePass {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override {
|
bool runOnModule(Module &M) override {
|
||||||
|
|
||||||
ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
|
ModuleSanitizerCoverage ModuleSancov(Options
|
||||||
Blocklist.get());
|
#if LLVM_MAJOR > 10
|
||||||
|
,
|
||||||
|
Allowlist.get(), Blocklist.get()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
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();
|
||||||
@ -298,8 +291,12 @@ 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());
|
#if LLVM_MAJOR > 10
|
||||||
|
,
|
||||||
|
Allowlist.get(), Blocklist.get()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
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 * {
|
||||||
|
|
||||||
@ -418,12 +415,6 @@ bool ModuleSanitizerCoverage::instrumentModule(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Options.CoverageType == SanitizerCoverageOptions::SCK_None) return false;
|
if (Options.CoverageType == SanitizerCoverageOptions::SCK_None) return false;
|
||||||
if (Allowlist &&
|
|
||||||
!Allowlist->inSection("coverage", "src", M.getSourceFileName()))
|
|
||||||
return false;
|
|
||||||
if (Blocklist &&
|
|
||||||
Blocklist->inSection("coverage", "src", M.getSourceFileName()))
|
|
||||||
return false;
|
|
||||||
C = &(M.getContext());
|
C = &(M.getContext());
|
||||||
DL = &M.getDataLayout();
|
DL = &M.getDataLayout();
|
||||||
CurModule = &M;
|
CurModule = &M;
|
||||||
@ -696,9 +687,6 @@ 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()))
|
|
||||||
return;
|
|
||||||
if (Blocklist && Blocklist->inSection("coverage", "fun", F.getName())) return;
|
|
||||||
if (Options.CoverageType >= SanitizerCoverageOptions::SCK_Edge)
|
if (Options.CoverageType >= SanitizerCoverageOptions::SCK_Edge)
|
||||||
SplitAllCriticalEdges(
|
SplitAllCriticalEdges(
|
||||||
F, CriticalEdgeSplittingOptions().setIgnoreUnreachableDests());
|
F, CriticalEdgeSplittingOptions().setIgnoreUnreachableDests());
|
||||||
@ -1216,12 +1204,20 @@ INITIALIZE_PASS_END(ModuleSanitizerCoverageLegacyPass, "sancov",
|
|||||||
false)
|
false)
|
||||||
|
|
||||||
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
|
||||||
const SanitizerCoverageOptions &Options,
|
const SanitizerCoverageOptions &Options
|
||||||
|
#if LLVM_MAJOR > 10
|
||||||
|
,
|
||||||
const std::vector<std::string> &AllowlistFiles,
|
const std::vector<std::string> &AllowlistFiles,
|
||||||
const std::vector<std::string> &BlocklistFiles) {
|
const std::vector<std::string> &BlocklistFiles
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
|
||||||
return new ModuleSanitizerCoverageLegacyPass(Options, AllowlistFiles,
|
return new ModuleSanitizerCoverageLegacyPass(Options
|
||||||
BlocklistFiles);
|
#if LLVM_MAJOR > 10
|
||||||
|
,
|
||||||
|
AllowlistFiles, BlocklistFiles
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user