mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 02:28:09 +00:00
rename whitelist -> instrumentlist
This commit is contained in:
@ -253,7 +253,7 @@ ifeq "$(TEST_MMAP)" "1"
|
||||
LDFLAGS += -Wno-deprecated-declarations
|
||||
endif
|
||||
|
||||
PROGS = ../afl-clang-fast ../afl-llvm-pass.so ../afl-ld-lto ../afl-llvm-lto-whitelist.so ../afl-llvm-lto-instrumentation.so ../afl-llvm-lto-instrim.so ../libLLVMInsTrim.so ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o ../compare-transform-pass.so ../split-compares-pass.so ../split-switches-pass.so ../cmplog-routines-pass.so ../cmplog-instructions-pass.so
|
||||
PROGS = ../afl-clang-fast ../afl-llvm-pass.so ../afl-ld-lto ../afl-llvm-lto-instrumentlist.so ../afl-llvm-lto-instrumentation.so ../afl-llvm-lto-instrim.so ../libLLVMInsTrim.so ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o ../compare-transform-pass.so ../split-compares-pass.so ../split-switches-pass.so ../cmplog-routines-pass.so ../cmplog-instructions-pass.so
|
||||
|
||||
# If prerequisites are not given, warn, do not build anything, and exit with code 0
|
||||
ifeq "$(LLVMVER)" ""
|
||||
@ -332,7 +332,7 @@ ifeq "$(LLVM_MIN_4_0_1)" "0"
|
||||
endif
|
||||
$(CXX) $(CLANG_CPPFL) -DLLVMInsTrim_EXPORTS -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< -o $@ $(CLANG_LFL) afl-llvm-common.o
|
||||
|
||||
../afl-llvm-lto-whitelist.so: afl-llvm-lto-whitelist.so.cc afl-llvm-common.o
|
||||
../afl-llvm-lto-instrumentlist.so: afl-llvm-lto-instrumentlist.so.cc afl-llvm-common.o
|
||||
ifeq "$(LLVM_LTO)" "1"
|
||||
$(CXX) $(CLANG_CPPFL) -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< -o $@ $(CLANG_LFL) afl-llvm-common.o
|
||||
endif
|
||||
@ -403,7 +403,7 @@ all_done: test_build
|
||||
install: all
|
||||
install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
|
||||
if [ -f ../afl-clang-fast -a -f ../libLLVMInsTrim.so -a -f ../afl-llvm-rt.o ]; then set -e; install -m 755 ../afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 ../libLLVMInsTrim.so ../afl-llvm-pass.so ../afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
||||
if [ -f ../afl-clang-lto ]; then set -e; ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-lto; ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-lto++; install -m 755 ../afl-llvm-lto-instrumentation.so ../afl-llvm-lto-instrim.so ../afl-llvm-rt-lto*.o ../afl-llvm-lto-whitelist.so $${DESTDIR}$(HELPER_PATH); fi
|
||||
if [ -f ../afl-clang-lto ]; then set -e; ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-lto; ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-lto++; install -m 755 ../afl-llvm-lto-instrumentation.so ../afl-llvm-lto-instrim.so ../afl-llvm-rt-lto*.o ../afl-llvm-lto-instrumentlist.so $${DESTDIR}$(HELPER_PATH); fi
|
||||
if [ -f ../afl-ld-lto ]; then set -e; install -m 755 ../afl-ld-lto $${DESTDIR}$(BIN_PATH); fi
|
||||
if [ -f ../afl-llvm-rt-32.o ]; then set -e; install -m 755 ../afl-llvm-rt-32.o $${DESTDIR}$(HELPER_PATH); fi
|
||||
if [ -f ../afl-llvm-rt-64.o ]; then set -e; install -m 755 ../afl-llvm-rt-64.o $${DESTDIR}$(HELPER_PATH); fi
|
||||
|
@ -74,7 +74,7 @@ struct InsTrim : public ModulePass {
|
||||
|
||||
InsTrim() : ModulePass(ID), generator(0) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ struct InsTrim : public ModulePass {
|
||||
|
||||
}
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
// if the function below our minimum size skip it (1 or 2)
|
||||
if (F.size() < function_minimum_size) { continue; }
|
||||
|
@ -29,12 +29,12 @@ subdirectory. There is nothing specifically to do :)
|
||||
|
||||
In order to build with partial instrumentation, you need to build with
|
||||
afl-clang-fast and afl-clang-fast++ respectively. The only required change is
|
||||
that you need to set the environment variable AFL_LLVM_WHITELIST when calling
|
||||
that you need to set the environment variable AFL_LLVM_INSTRUMENT_FILE when calling
|
||||
the compiler.
|
||||
|
||||
The environment variable must point to a file containing all the filenames
|
||||
that should be instrumented. For matching, the filename that is being compiled
|
||||
must end in the filename entry contained in this whitelist (to avoid breaking
|
||||
must end in the filename entry contained in this the instrument file list (to avoid breaking
|
||||
the matching when absolute paths are used during compilation).
|
||||
|
||||
For example if your source tree looks like this:
|
||||
@ -47,14 +47,14 @@ project/feature_b/b1.cpp
|
||||
project/feature_b/b2.cpp
|
||||
```
|
||||
|
||||
and you only want to test feature_a, then create a whitelist file containing:
|
||||
and you only want to test feature_a, then create a the instrument file list file containing:
|
||||
|
||||
```
|
||||
feature_a/a1.cpp
|
||||
feature_a/a2.cpp
|
||||
```
|
||||
|
||||
However if the whitelist file contains only this, it works as well:
|
||||
However if the the instrument file list file contains only this, it works as well:
|
||||
|
||||
```
|
||||
a1.cpp
|
||||
@ -64,8 +64,8 @@ a2.cpp
|
||||
but it might lead to files being unwantedly instrumented if the same filename
|
||||
exists somewhere else in the project directories.
|
||||
|
||||
The created whitelist file is then set to AFL_LLVM_WHITELIST when you compile
|
||||
your program. For each file that didn't match the whitelist, the compiler will
|
||||
The created the instrument file list file is then set to AFL_LLVM_INSTRUMENT_FILE when you compile
|
||||
your program. For each file that didn't match the the instrument file list, the compiler will
|
||||
issue a warning at the end stating that no blocks were instrumented. If you
|
||||
didn't intend to instrument that file, then you can safely ignore that warning.
|
||||
|
||||
@ -75,5 +75,5 @@ required anymore (and might hurt performance and crash detection, so better not
|
||||
use -g).
|
||||
|
||||
## 4) UNIX-style filename pattern matching
|
||||
You can add UNIX-style pattern matching in the whitelist entries. See `man
|
||||
You can add UNIX-style pattern matching in the the instrument file list entries. See `man
|
||||
fnmatch` for the syntax. We do not set any of the `fnmatch` flags.
|
@ -7,7 +7,7 @@ This version requires a current llvm 11 compiled from the github master.
|
||||
1. Use afl-clang-lto/afl-clang-lto++ because it is faster and gives better
|
||||
coverage than anything else that is out there in the AFL world
|
||||
|
||||
2. You can use it together with llvm_mode: laf-intel and whitelisting
|
||||
2. You can use it together with llvm_mode: laf-intel and the instrument file listing
|
||||
features and can be combined with cmplog/Redqueen
|
||||
|
||||
3. It only works with llvm 11 (current github master state)
|
||||
@ -108,7 +108,7 @@ make install
|
||||
|
||||
Just use afl-clang-lto like you did with afl-clang-fast or afl-gcc.
|
||||
|
||||
Also whitelisting (AFL_LLVM_WHITELIST -> [README.whitelist.md](README.whitelist.md)) and
|
||||
Also the instrument file listing (AFL_LLVM_INSTRUMENT_FILE -> [README.instrument_file.md](README.instrument_file.md)) and
|
||||
laf-intel/compcov (AFL_LLVM_LAF_* -> [README.laf-intel.md](README.laf-intel.md)) work.
|
||||
InsTrim (control flow graph instrumentation) is supported and recommended!
|
||||
(set `AFL_LLVM_INSTRUMENT=CFG`)
|
||||
|
@ -108,8 +108,8 @@ directory.
|
||||
Several options are present to make llvm_mode faster or help it rearrange
|
||||
the code to make afl-fuzz path discovery easier.
|
||||
|
||||
If you need just to instrument specific parts of the code, you can whitelist
|
||||
which C/C++ files to actually instrument. See [README.whitelist](README.whitelist.md)
|
||||
If you need just to instrument specific parts of the code, you can the instrument file list
|
||||
which C/C++ files to actually instrument. See [README.instrument_file](README.instrument_file.md)
|
||||
|
||||
For splitting memcmp, strncmp, etc. please see [README.laf-intel](README.laf-intel.md)
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
TODO for afl-ld:
|
||||
* handle libfoo.a object archives
|
||||
|
||||
TODO for afl-llvm-lto-instrumentation:
|
||||
* better algo for putting stuff in the map?
|
||||
* try to predict how long the instrumentation process will take
|
||||
|
||||
TODO for afl-llvm-lto-whitelist
|
||||
* different solution then renaming?
|
||||
|
@ -227,13 +227,14 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
if (lto_mode) {
|
||||
|
||||
if (getenv("AFL_LLVM_WHITELIST") != NULL) {
|
||||
if (getenv("AFL_LLVM_INSTRUMENT_FILE") != NULL ||
|
||||
getenv("AFL_LLVM_WHITELIST")) {
|
||||
|
||||
cc_params[cc_par_cnt++] = "-Xclang";
|
||||
cc_params[cc_par_cnt++] = "-load";
|
||||
cc_params[cc_par_cnt++] = "-Xclang";
|
||||
cc_params[cc_par_cnt++] =
|
||||
alloc_printf("%s/afl-llvm-lto-whitelist.so", obj_path);
|
||||
alloc_printf("%s/afl-llvm-lto-instrumentlist.so", obj_path);
|
||||
|
||||
}
|
||||
|
||||
@ -762,7 +763,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
#if LLVM_VERSION_MAJOR <= 6
|
||||
instrument_mode = INSTRUMENT_AFL;
|
||||
#else
|
||||
if (getenv("AFL_LLVM_WHITELIST"))
|
||||
if (getenv("AFL_LLVM_INSTRUMENT_FILE") || getenv("AFL_LLVM_WHITELIST"))
|
||||
instrument_mode = INSTRUMENT_AFL;
|
||||
else
|
||||
instrument_mode = INSTRUMENT_PCGUARD;
|
||||
@ -810,8 +811,11 @@ int main(int argc, char **argv, char **envp) {
|
||||
"AFL_LLVM_NOT_ZERO and AFL_LLVM_SKIP_NEVERZERO can not be set "
|
||||
"together");
|
||||
|
||||
if (instrument_mode == INSTRUMENT_PCGUARD && getenv("AFL_LLVM_WHITELIST"))
|
||||
WARNF("Instrumentation type PCGUARD does not support AFL_LLVM_WHITELIST!");
|
||||
if (instrument_mode == INSTRUMENT_PCGUARD &&
|
||||
(getenv("AFL_LLVM_INSTRUMENT_FILE") || getenv("AFL_LLVM_WHITELIST")))
|
||||
WARNF(
|
||||
"Instrumentation type PCGUARD does not support "
|
||||
"AFL_LLVM_INSTRUMENT_FILE!");
|
||||
|
||||
if (argc < 2 || strcmp(argv[1], "-h") == 0) {
|
||||
|
||||
@ -861,7 +865,8 @@ int main(int argc, char **argv, char **envp) {
|
||||
"AFL_LLVM_LAF_TRANSFORM_COMPARES: transform library comparison "
|
||||
"function calls\n"
|
||||
"AFL_LLVM_LAF_ALL: enables all LAF splits/transforms\n"
|
||||
"AFL_LLVM_WHITELIST: enable whitelisting (selective "
|
||||
"AFL_LLVM_INSTRUMENT_FILE: enable the instrument file listing "
|
||||
"(selective "
|
||||
"instrumentation)\n"
|
||||
"AFL_NO_BUILTIN: compile for use with libtokencap.so\n"
|
||||
"AFL_PATH: path to instrumenting pass and runtime "
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static std::list<std::string> myWhitelist;
|
||||
static std::list<std::string> myInstrumentList;
|
||||
|
||||
char *getBBName(const llvm::BasicBlock *BB) {
|
||||
|
||||
@ -44,7 +44,7 @@ char *getBBName(const llvm::BasicBlock *BB) {
|
||||
}
|
||||
|
||||
/* Function that we never instrument or analyze */
|
||||
/* Note: this ignore check is also called in isInWhitelist() */
|
||||
/* Note: this ignore check is also called in isInInstrumentList() */
|
||||
bool isIgnoreFunction(const llvm::Function *F) {
|
||||
|
||||
// Starting from "LLVMFuzzer" these are functions used in libfuzzer based
|
||||
@ -83,19 +83,22 @@ bool isIgnoreFunction(const llvm::Function *F) {
|
||||
|
||||
}
|
||||
|
||||
void initWhitelist() {
|
||||
void initInstrumentList() {
|
||||
|
||||
char *instWhiteListFilename = getenv("AFL_LLVM_WHITELIST");
|
||||
if (instWhiteListFilename) {
|
||||
char *instrumentListFilename = getenv("AFL_LLVM_INSTRUMENT_FILE");
|
||||
if (!instrumentListFilename)
|
||||
instrumentListFilename = getenv("AFL_LLVM_WHITELIST");
|
||||
if (instrumentListFilename) {
|
||||
|
||||
std::string line;
|
||||
std::ifstream fileStream;
|
||||
fileStream.open(instWhiteListFilename);
|
||||
if (!fileStream) report_fatal_error("Unable to open AFL_LLVM_WHITELIST");
|
||||
fileStream.open(instrumentListFilename);
|
||||
if (!fileStream)
|
||||
report_fatal_error("Unable to open AFL_LLVM_INSTRUMENT_FILE");
|
||||
getline(fileStream, line);
|
||||
while (fileStream) {
|
||||
|
||||
myWhitelist.push_back(line);
|
||||
myInstrumentList.push_back(line);
|
||||
getline(fileStream, line);
|
||||
|
||||
}
|
||||
@ -104,14 +107,14 @@ void initWhitelist() {
|
||||
|
||||
}
|
||||
|
||||
bool isInWhitelist(llvm::Function *F) {
|
||||
bool isInInstrumentList(llvm::Function *F) {
|
||||
|
||||
// is this a function with code? If it is external we dont instrument it
|
||||
// anyway and cant be in the whitelist. Or if it is ignored.
|
||||
// anyway and cant be in the the instrument file list. Or if it is ignored.
|
||||
if (!F->size() || isIgnoreFunction(F)) return false;
|
||||
|
||||
// if we do not have a whitelist return true
|
||||
if (myWhitelist.empty()) return true;
|
||||
// if we do not have a the instrument file list return true
|
||||
if (myInstrumentList.empty()) return true;
|
||||
|
||||
// let's try to get the filename for the function
|
||||
auto bb = &F->getEntryBlock();
|
||||
@ -147,8 +150,8 @@ bool isInWhitelist(llvm::Function *F) {
|
||||
/* Continue only if we know where we actually are */
|
||||
if (!instFilename.str().empty()) {
|
||||
|
||||
for (std::list<std::string>::iterator it = myWhitelist.begin();
|
||||
it != myWhitelist.end(); ++it) {
|
||||
for (std::list<std::string>::iterator it = myInstrumentList.begin();
|
||||
it != myInstrumentList.end(); ++it) {
|
||||
|
||||
/* We don't check for filename equality here because
|
||||
* filenames might actually be full paths. Instead we
|
||||
@ -185,8 +188,8 @@ bool isInWhitelist(llvm::Function *F) {
|
||||
/* Continue only if we know where we actually are */
|
||||
if (!instFilename.str().empty()) {
|
||||
|
||||
for (std::list<std::string>::iterator it = myWhitelist.begin();
|
||||
it != myWhitelist.end(); ++it) {
|
||||
for (std::list<std::string>::iterator it = myInstrumentList.begin();
|
||||
it != myInstrumentList.end(); ++it) {
|
||||
|
||||
/* We don't check for filename equality here because
|
||||
* filenames might actually be full paths. Instead we
|
||||
@ -215,7 +218,7 @@ bool isInWhitelist(llvm::Function *F) {
|
||||
else {
|
||||
|
||||
// we could not find out the location. in this case we say it is not
|
||||
// in the whitelist
|
||||
// in the the instrument file list
|
||||
|
||||
return false;
|
||||
|
||||
|
@ -34,8 +34,8 @@ typedef long double max_align_t;
|
||||
|
||||
char * getBBName(const llvm::BasicBlock *BB);
|
||||
bool isIgnoreFunction(const llvm::Function *F);
|
||||
void initWhitelist();
|
||||
bool isInWhitelist(llvm::Function *F);
|
||||
void initInstrumentList();
|
||||
bool isInInstrumentList(llvm::Function *F);
|
||||
unsigned long long int calculateCollisions(uint32_t edges);
|
||||
|
||||
#endif
|
||||
|
@ -566,12 +566,13 @@ struct InsTrimLTO : public ModulePass {
|
||||
|
||||
functions++;
|
||||
|
||||
// whitelist check
|
||||
// the instrument file list check
|
||||
AttributeList Attrs = F.getAttributes();
|
||||
if (Attrs.hasAttribute(-1, StringRef("skipinstrument"))) {
|
||||
|
||||
if (debug)
|
||||
fprintf(stderr, "DEBUG: Function %s is not whitelisted\n",
|
||||
fprintf(stderr,
|
||||
"DEBUG: Function %s is not the instrument file listed\n",
|
||||
F.getName().str().c_str());
|
||||
continue;
|
||||
|
||||
|
@ -198,12 +198,13 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
||||
if (F.size() < function_minimum_size) continue;
|
||||
if (isIgnoreFunction(&F)) continue;
|
||||
|
||||
// whitelist check
|
||||
// the instrument file list check
|
||||
AttributeList Attrs = F.getAttributes();
|
||||
if (Attrs.hasAttribute(-1, StringRef("skipinstrument"))) {
|
||||
|
||||
if (debug)
|
||||
fprintf(stderr, "DEBUG: Function %s is not whitelisted\n",
|
||||
fprintf(stderr,
|
||||
"DEBUG: Function %s is not the instrument file listed\n",
|
||||
F.getName().str().c_str());
|
||||
continue;
|
||||
|
||||
|
@ -53,27 +53,30 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
class AFLwhitelist : public ModulePass {
|
||||
class AFLcheckIfInstrument : public ModulePass {
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
AFLwhitelist() : ModulePass(ID) {
|
||||
AFLcheckIfInstrument() : ModulePass(ID) {
|
||||
|
||||
int entries = 0;
|
||||
|
||||
if (getenv("AFL_DEBUG")) debug = 1;
|
||||
|
||||
char *instWhiteListFilename = getenv("AFL_LLVM_WHITELIST");
|
||||
if (instWhiteListFilename) {
|
||||
char *instrumentListFilename = getenv("AFL_LLVM_INSTRUMENT_FILE");
|
||||
if (!instrumentListFilename)
|
||||
instrumentListFilename = getenv("AFL_LLVM_WHITELIST");
|
||||
if (instrumentListFilename) {
|
||||
|
||||
std::string line;
|
||||
std::ifstream fileStream;
|
||||
fileStream.open(instWhiteListFilename);
|
||||
if (!fileStream) report_fatal_error("Unable to open AFL_LLVM_WHITELIST");
|
||||
fileStream.open(instrumentListFilename);
|
||||
if (!fileStream)
|
||||
report_fatal_error("Unable to open AFL_LLVM_INSTRUMENT_FILE");
|
||||
getline(fileStream, line);
|
||||
while (fileStream) {
|
||||
|
||||
myWhitelist.push_back(line);
|
||||
myInstrumentList.push_back(line);
|
||||
getline(fileStream, line);
|
||||
entries++;
|
||||
|
||||
@ -81,11 +84,14 @@ class AFLwhitelist : public ModulePass {
|
||||
|
||||
} else
|
||||
|
||||
PFATAL("afl-llvm-lto-whitelist.so loaded without AFL_LLVM_WHITELIST?!");
|
||||
PFATAL(
|
||||
"afl-llvm-lto-instrumentlist.so loaded without "
|
||||
"AFL_LLVM_INSTRUMENT_FILE?!");
|
||||
|
||||
if (debug)
|
||||
SAYF(cMGN "[D] " cRST "loaded whitelist %s with %d entries\n",
|
||||
instWhiteListFilename, entries);
|
||||
SAYF(cMGN "[D] " cRST
|
||||
"loaded the instrument file list %s with %d entries\n",
|
||||
instrumentListFilename, entries);
|
||||
|
||||
}
|
||||
|
||||
@ -97,16 +103,16 @@ class AFLwhitelist : public ModulePass {
|
||||
// }
|
||||
|
||||
protected:
|
||||
std::list<std::string> myWhitelist;
|
||||
std::list<std::string> myInstrumentList;
|
||||
int debug = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
char AFLwhitelist::ID = 0;
|
||||
char AFLcheckIfInstrument::ID = 0;
|
||||
|
||||
bool AFLwhitelist::runOnModule(Module &M) {
|
||||
bool AFLcheckIfInstrument::runOnModule(Module &M) {
|
||||
|
||||
/* Show a banner */
|
||||
|
||||
@ -115,7 +121,7 @@ bool AFLwhitelist::runOnModule(Module &M) {
|
||||
|
||||
if ((isatty(2) && !getenv("AFL_QUIET")) || getenv("AFL_DEBUG") != NULL) {
|
||||
|
||||
SAYF(cCYA "afl-llvm-lto-whitelist" VERSION cRST
|
||||
SAYF(cCYA "afl-llvm-lto-instrumentlist" VERSION cRST
|
||||
" by Marc \"vanHauser\" Heuse <mh@mh-sec.de>\n");
|
||||
|
||||
} else if (getenv("AFL_QUIET"))
|
||||
@ -131,7 +137,7 @@ bool AFLwhitelist::runOnModule(Module &M) {
|
||||
BasicBlock::iterator IP = F.getEntryBlock().getFirstInsertionPt();
|
||||
IRBuilder<> IRB(&(*IP));
|
||||
|
||||
if (!myWhitelist.empty()) {
|
||||
if (!myInstrumentList.empty()) {
|
||||
|
||||
bool instrumentFunction = false;
|
||||
|
||||
@ -168,8 +174,8 @@ bool AFLwhitelist::runOnModule(Module &M) {
|
||||
/* Continue only if we know where we actually are */
|
||||
if (!instFilename.str().empty()) {
|
||||
|
||||
for (std::list<std::string>::iterator it = myWhitelist.begin();
|
||||
it != myWhitelist.end(); ++it) {
|
||||
for (std::list<std::string>::iterator it = myInstrumentList.begin();
|
||||
it != myInstrumentList.end(); ++it) {
|
||||
|
||||
/* We don't check for filename equality here because
|
||||
* filenames might actually be full paths. Instead we
|
||||
@ -194,18 +200,19 @@ bool AFLwhitelist::runOnModule(Module &M) {
|
||||
}
|
||||
|
||||
/* Either we couldn't figure out our location or the location is
|
||||
* not whitelisted, so we skip instrumentation.
|
||||
* not the instrument file listed, so we skip instrumentation.
|
||||
* We do this by renaming the function. */
|
||||
if (instrumentFunction == true) {
|
||||
|
||||
if (debug)
|
||||
SAYF(cMGN "[D] " cRST "function %s is in whitelist\n",
|
||||
SAYF(cMGN "[D] " cRST "function %s is in the instrument file list\n",
|
||||
F.getName().str().c_str());
|
||||
|
||||
} else {
|
||||
|
||||
if (debug)
|
||||
SAYF(cMGN "[D] " cRST "function %s is NOT in whitelist\n",
|
||||
SAYF(cMGN "[D] " cRST
|
||||
"function %s is NOT in the instrument file list\n",
|
||||
F.getName().str().c_str());
|
||||
|
||||
auto & Ctx = F.getContext();
|
||||
@ -219,7 +226,7 @@ bool AFLwhitelist::runOnModule(Module &M) {
|
||||
|
||||
} else {
|
||||
|
||||
PFATAL("Whitelist is empty");
|
||||
PFATAL("InstrumentList is empty");
|
||||
|
||||
}
|
||||
|
||||
@ -229,16 +236,18 @@ bool AFLwhitelist::runOnModule(Module &M) {
|
||||
|
||||
}
|
||||
|
||||
static void registerAFLwhitelistpass(const PassManagerBuilder &,
|
||||
legacy::PassManagerBase &PM) {
|
||||
static void registerAFLcheckIfInstrumentpass(const PassManagerBuilder &,
|
||||
legacy::PassManagerBase &PM) {
|
||||
|
||||
PM.add(new AFLwhitelist());
|
||||
PM.add(new AFLcheckIfInstrument());
|
||||
|
||||
}
|
||||
|
||||
static RegisterStandardPasses RegisterAFLwhitelistpass(
|
||||
PassManagerBuilder::EP_ModuleOptimizerEarly, registerAFLwhitelistpass);
|
||||
static RegisterStandardPasses RegisterAFLcheckIfInstrumentpass(
|
||||
PassManagerBuilder::EP_ModuleOptimizerEarly,
|
||||
registerAFLcheckIfInstrumentpass);
|
||||
|
||||
static RegisterStandardPasses RegisterAFLwhitelistpass0(
|
||||
PassManagerBuilder::EP_EnabledOnOptLevel0, registerAFLwhitelistpass);
|
||||
static RegisterStandardPasses RegisterAFLcheckIfInstrumentpass0(
|
||||
PassManagerBuilder::EP_EnabledOnOptLevel0,
|
||||
registerAFLcheckIfInstrumentpass);
|
||||
|
@ -74,7 +74,7 @@ class AFLCoverage : public ModulePass {
|
||||
static char ID;
|
||||
AFLCoverage() : ModulePass(ID) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ bool AFLCoverage::runOnModule(Module &M) {
|
||||
fprintf(stderr, "FUNCTION: %s (%zu)\n", F.getName().str().c_str(),
|
||||
F.size());
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
if (F.size() < function_minimum_size) continue;
|
||||
|
||||
|
@ -59,7 +59,7 @@ class CmpLogInstructions : public ModulePass {
|
||||
static char ID;
|
||||
CmpLogInstructions() : ModulePass(ID) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
||||
/* iterate over all functions, bbs and instruction and add suitable calls */
|
||||
for (auto &F : M) {
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
|
@ -59,7 +59,7 @@ class CmpLogRoutines : public ModulePass {
|
||||
static char ID;
|
||||
CmpLogRoutines() : ModulePass(ID) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
||||
/* iterate over all functions, bbs and instruction and add suitable calls */
|
||||
for (auto &F : M) {
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
|
@ -58,7 +58,7 @@ class CompareTransform : public ModulePass {
|
||||
static char ID;
|
||||
CompareTransform() : ModulePass(ID) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
||||
* strcmp/memcmp/strncmp/strcasecmp/strncasecmp */
|
||||
for (auto &F : M) {
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
|
@ -55,7 +55,7 @@ class SplitComparesTransform : public ModulePass {
|
||||
static char ID;
|
||||
SplitComparesTransform() : ModulePass(ID) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ bool SplitComparesTransform::simplifyCompares(Module &M) {
|
||||
* all integer comparisons with >= and <= predicates to the icomps vector */
|
||||
for (auto &F : M) {
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SplitSwitchesTransform : public ModulePass {
|
||||
static char ID;
|
||||
SplitSwitchesTransform() : ModulePass(ID) {
|
||||
|
||||
initWhitelist();
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) {
|
||||
* all switches to switches vector for later processing */
|
||||
for (auto &F : M) {
|
||||
|
||||
if (!isInWhitelist(&F)) continue;
|
||||
if (!isInInstrumentList(&F)) continue;
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
|
Reference in New Issue
Block a user