aboutsummaryrefslogtreecommitdiff
path: root/llvm_mode
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2019-12-03 01:40:41 +0100
committerGitHub <noreply@github.com>2019-12-03 01:40:41 +0100
commit4231c498392484fd2187b9ed1dedb1ba7bc0958b (patch)
tree366586c4ceef17998670a8c2d978869bdac64d56 /llvm_mode
parentb0d590fef4acb4b002429e4aec195e5740122494 (diff)
parentef2dc98773c55eb09e4c1a588fb74df58570f868 (diff)
downloadafl++-4231c498392484fd2187b9ed1dedb1ba7bc0958b.tar.gz
Merge branch 'master' into llvm_mode_build_fix
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/LLVMInsTrim.so.cc21
-rw-r--r--llvm_mode/Makefile3
-rw-r--r--llvm_mode/afl-clang-fast.c12
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc12
-rw-r--r--llvm_mode/split-compares-pass.so.cc12
5 files changed, 36 insertions, 24 deletions
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc
index 1d4e6f2f..552cf580 100644
--- a/llvm_mode/LLVMInsTrim.so.cc
+++ b/llvm_mode/LLVMInsTrim.so.cc
@@ -159,9 +159,9 @@ struct InsTrim : public ModulePass {
if (!myWhitelist.empty()) {
- bool instrumentBlock = false;
- DebugLoc Loc;
- StringRef instFilename;
+ bool instrumentBlock = false;
+ DebugLoc Loc;
+ StringRef instFilename;
unsigned int instLine = 0;
for (auto &BB : F) {
@@ -223,12 +223,17 @@ struct InsTrim : public ModulePass {
if (!instrumentBlock) {
if (!be_quiet) {
- if (!instFilename.str().empty())
- SAYF(cYEL "[!] " cBRI "Not in whitelist, skipping %s line %u...\n",
- instFilename.str().c_str(), instLine);
- else
- SAYF(cYEL "[!] " cBRI "No filename information found, skipping it");
+
+ if (!instFilename.str().empty())
+ SAYF(cYEL "[!] " cBRI
+ "Not in whitelist, skipping %s line %u...\n",
+ instFilename.str().c_str(), instLine);
+ else
+ SAYF(cYEL "[!] " cBRI
+ "No filename information found, skipping it");
+
}
+
continue;
}
diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile
index 1f68e517..6c1ff176 100644
--- a/llvm_mode/Makefile
+++ b/llvm_mode/Makefile
@@ -41,6 +41,7 @@ LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]'
LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//')
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
LLVM_STDCXX = gnu++11
+LLVM_APPLE = $(shell clang -v 2>&1 | grep -iq apple && echo 1 || echo 0)
ifeq "$(LLVM_UNSUPPORTED)" "1"
$(warn llvm_mode only supports versions 3.8.0 up to 9)
@@ -151,7 +152,9 @@ endif
test_deps:
ifndef AFL_TRACE_PC
@echo "[*] Checking for working 'llvm-config'..."
+ ifneq "$(LLVM_APPLE)" "1"
@which $(LLVM_CONFIG) >/dev/null 2>&1 || ( echo "[-] Oops, can't find 'llvm-config'. Install clang or set \$$LLVM_CONFIG or \$$PATH beforehand."; echo " (Sometimes, the binary will be named llvm-config-3.5 or something like that.)"; exit 1 )
+ endif
else
@echo "[!] Note: using -fsanitize=trace-pc mode (this will fail with older LLVM)."
endif
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c
index b245cefa..e89b6183 100644
--- a/llvm_mode/afl-clang-fast.c
+++ b/llvm_mode/afl-clang-fast.c
@@ -122,15 +122,19 @@ static void edit_params(u32 argc, char** argv) {
if (!strcmp(name, "afl-clang-fast++")) {
u8* alt_cxx = getenv("AFL_CXX");
- if (has_llvm_config) snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang++", LLVM_BINDIR);
- else sprintf(llvm_fullpath, "clang++");
+ if (has_llvm_config)
+ snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang++", LLVM_BINDIR);
+ else
+ sprintf(llvm_fullpath, "clang++");
cc_params[0] = alt_cxx ? alt_cxx : (u8*)llvm_fullpath;
} else {
u8* alt_cc = getenv("AFL_CC");
- if (has_llvm_config) snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang", LLVM_BINDIR);
- else sprintf(llvm_fullpath, "clang");
+ if (has_llvm_config)
+ snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang", LLVM_BINDIR);
+ else
+ sprintf(llvm_fullpath, "clang");
cc_params[0] = alt_cc ? alt_cc : (u8*)llvm_fullpath;
}
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 4ce073a5..1601a4f8 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -94,12 +94,12 @@ bool AFLCoverage::runOnModule(Module &M) {
LLVMContext &C = M.getContext();
- IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
- IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
- struct timeval tv;
- struct timezone tz;
- u32 rand_seed;
- unsigned int cur_loc = 0;
+ IntegerType * Int8Ty = IntegerType::getInt8Ty(C);
+ IntegerType * Int32Ty = IntegerType::getInt32Ty(C);
+ struct timeval tv;
+ struct timezone tz;
+ u32 rand_seed;
+ unsigned int cur_loc = 0;
/* Setup random() so we get Actually Random(TM) outputs from AFL_R() */
gettimeofday(&tv, &tz);
diff --git a/llvm_mode/split-compares-pass.so.cc b/llvm_mode/split-compares-pass.so.cc
index 60420f77..db884cde 100644
--- a/llvm_mode/split-compares-pass.so.cc
+++ b/llvm_mode/split-compares-pass.so.cc
@@ -103,11 +103,11 @@ bool SplitComparesTransform::simplifyCompares(Module &M) {
}
- if (enableFPSplit && (
- selectcmpInst->getPredicate() == CmpInst::FCMP_OGE ||
- selectcmpInst->getPredicate() == CmpInst::FCMP_UGE ||
- selectcmpInst->getPredicate() == CmpInst::FCMP_OLE ||
- selectcmpInst->getPredicate() == CmpInst::FCMP_ULE)) {
+ if (enableFPSplit &&
+ (selectcmpInst->getPredicate() == CmpInst::FCMP_OGE ||
+ selectcmpInst->getPredicate() == CmpInst::FCMP_UGE ||
+ selectcmpInst->getPredicate() == CmpInst::FCMP_OLE ||
+ selectcmpInst->getPredicate() == CmpInst::FCMP_ULE)) {
auto op0 = selectcmpInst->getOperand(0);
auto op1 = selectcmpInst->getOperand(1);
@@ -1046,7 +1046,7 @@ bool SplitComparesTransform::runOnModule(Module &M) {
char *bitw_env = getenv("LAF_SPLIT_COMPARES_BITW");
if (!bitw_env) bitw_env = getenv("AFL_LLVM_LAF_SPLIT_COMPARES_BITW");
if (bitw_env) { bitw = atoi(bitw_env); }
-
+
enableFPSplit = getenv("AFL_LLVM_LAF_SPLIT_FLOATS") != NULL;
simplifyCompares(M);