blacklist function support for llvm_mode

This commit is contained in:
van Hauser 2020-01-15 10:10:25 +01:00
parent d0ea8f8433
commit d1d5e7c02a
6 changed files with 62 additions and 12 deletions

3
TODO
View File

@ -2,6 +2,9 @@
Roadmap 2.61+:
==============
Makefile:
- -march=native -Ofast -flto=full
afl-fuzz:
- sync_fuzzers(): only masters sync from all, slaves only sync from master

View File

@ -20,7 +20,8 @@ Version ++2.60d (develop):
- afl-fuzz:
- now prints the real python version support compiled in
- afl-clang-fast now shows in the help output for which llvm version it
was compiled for.
was compiled for
- added blacklisted function check in llvm_mode
- added fix from Debian project to compile libdislocator and libtokencap

View File

@ -94,6 +94,28 @@ struct InsTrim : public ModulePass {
}
// ripped from aflgo
static bool isBlacklisted(const Function *F) {
static const SmallVector<std::string, 4> Blacklist = {
"asan.",
"llvm.",
"sancov.",
"__ubsan_handle_",
};
for (auto const &BlacklistFunc : Blacklist) {
if (F->getName().startswith(BlacklistFunc)) { return true; }
}
return false;
}
bool runOnModule(Module &M) override {
char be_quiet = 0;
@ -240,6 +262,8 @@ struct InsTrim : public ModulePass {
}
if (isBlacklisted(&F)) continue;
std::unordered_set<BasicBlock *> MS;
if (!MarkSetOpt) {

View File

@ -444,7 +444,8 @@ int main(int argc, char** argv) {
"You can specify custom next-stage toolchain via AFL_CC and AFL_CXX. "
"Setting\n"
"AFL_HARDEN enables hardening optimizations in the compiled code.\n\n"
"afl-clang-fast was built for llvm %s with the llvm binary path of \"%s\".\n\n",
"afl-clang-fast was built for llvm %s with the llvm binary path of "
"\"%s\".\n\n",
BIN_PATH, BIN_PATH, LLVM_VERSION, LLVM_BINDIR);
exit(1);

View File

@ -75,6 +75,28 @@ class AFLCoverage : public ModulePass {
}
// ripped from aflgo
static bool isBlacklisted(const Function *F) {
static const SmallVector<std::string, 4> Blacklist = {
"asan.",
"llvm.",
"sancov.",
"__ubsan_handle_",
};
for (auto const &BlacklistFunc : Blacklist) {
if (F->getName().startswith(BlacklistFunc)) { return true; }
}
return false;
}
bool runOnModule(Module &M) override;
// StringRef getPassName() const override {
@ -156,13 +178,11 @@ bool AFLCoverage::runOnModule(Module &M) {
/* Instrument all the things! */
const char *IntrinsicPrefix = "llvm.";
int inst_blocks = 0;
for (auto &F : M) {
auto Fname = F.getName();
if (Fname.startswith(IntrinsicPrefix)) continue;
if (isBlacklisted(&F)) continue;
for (auto &BB : F) {
@ -377,6 +397,7 @@ bool AFLCoverage::runOnModule(Module &M) {
inst_blocks++;
}
}
/* Say something nice. */