aboutsummaryrefslogtreecommitdiff
path: root/llvm_mode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/GNUmakefile2
-rw-r--r--llvm_mode/LLVMInsTrim.so.cc32
-rw-r--r--llvm_mode/MarkNodes.cc4
-rw-r--r--llvm_mode/afl-clang-fast.c8
-rw-r--r--llvm_mode/afl-llvm-common.cc5
-rw-r--r--llvm_mode/afl-llvm-common.h8
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc27
-rw-r--r--llvm_mode/afl-llvm-rt.o.c24
-rw-r--r--llvm_mode/cmplog-instructions-pass.cc10
-rw-r--r--llvm_mode/cmplog-routines-pass.cc10
-rw-r--r--llvm_mode/compare-transform-pass.so.cc11
-rw-r--r--llvm_mode/split-compares-pass.so.cc11
-rw-r--r--llvm_mode/split-switches-pass.so.cc11
13 files changed, 91 insertions, 72 deletions
diff --git a/llvm_mode/GNUmakefile b/llvm_mode/GNUmakefile
index ab14e545..01c83787 100644
--- a/llvm_mode/GNUmakefile
+++ b/llvm_mode/GNUmakefile
@@ -39,7 +39,7 @@ else
endif
LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/git//' )
-LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-7]|^1[2-9]' && echo 1 || echo 0 )
+LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-3]|^1[2-9]' && echo 1 || echo 0 )
LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]' && echo 1 || echo 0 )
LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//')
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc
index 837b093a..7dc96bc3 100644
--- a/llvm_mode/LLVMInsTrim.so.cc
+++ b/llvm_mode/LLVMInsTrim.so.cc
@@ -12,13 +12,13 @@ typedef long double max_align_t;
#include "llvm/ADT/DenseSet.h"
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/CFG.h"
-#include "llvm/IR/Dominators.h"
-#include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/CFG.h"
+ #include "llvm/IR/Dominators.h"
+ #include "llvm/IR/DebugInfo.h"
#else
-#include "llvm/Support/CFG.h"
-#include "llvm/Analysis/Dominators.h"
-#include "llvm/DebugInfo.h"
+ #include "llvm/Support/CFG.h"
+ #include "llvm/Analysis/Dominators.h"
+ #include "llvm/DebugInfo.h"
#endif
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
@@ -97,7 +97,7 @@ struct InsTrim : public ModulePass {
#if LLVM_VERSION_MAJOR >= 4 || \
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
-#define AFL_HAVE_VECTOR_INTRINSICS 1
+ #define AFL_HAVE_VECTOR_INTRINSICS 1
#endif
bool runOnModule(Module &M) override {
@@ -160,9 +160,21 @@ struct InsTrim : public ModulePass {
else
#else
if (ngram_size_str)
+#ifdef LLVM_VERSION_STRING
FATAL(
"Sorry, NGRAM branch coverage is not supported with llvm version %s!",
LLVM_VERSION_STRING);
+#else
+#ifndef LLVM_VERSION_PATCH
+ FATAL(
+ "Sorry, NGRAM branch coverage is not supported with llvm version %d.%d.%d!",
+ LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, 0);
+#else
+ FATAL(
+ "Sorry, NGRAM branch coverage is not supported with llvm version %d.%d.%d!",
+ LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, LLVM_VERISON_PATCH);
+#endif
+#endif
#endif
PrevLocSize = 1;
@@ -196,17 +208,17 @@ struct InsTrim : public ModulePass {
#ifdef AFL_HAVE_VECTOR_INTRINSICS
if (ngram_size)
-#ifdef __ANDROID__
+ #ifdef __ANDROID__
AFLPrevLoc = new GlobalVariable(
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
/* Initializer */ nullptr, "__afl_prev_loc");
-#else
+ #else
AFLPrevLoc = new GlobalVariable(
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
/* Initializer */ nullptr, "__afl_prev_loc",
/* InsertBefore */ nullptr, GlobalVariable::GeneralDynamicTLSModel,
/* AddressSpace */ 0, /* IsExternallyInitialized */ false);
-#endif
+ #endif
else
#endif
#ifdef __ANDROID__
diff --git a/llvm_mode/MarkNodes.cc b/llvm_mode/MarkNodes.cc
index cff6c90a..20a7df35 100644
--- a/llvm_mode/MarkNodes.cc
+++ b/llvm_mode/MarkNodes.cc
@@ -15,9 +15,9 @@ typedef long double max_align_t;
#include "llvm/IR/BasicBlock.h"
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/CFG.h"
+ #include "llvm/IR/CFG.h"
#else
-#include "llvm/Support/CFG.h"
+ #include "llvm/Support/CFG.h"
#endif
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c
index 07754d1d..49dc6c1c 100644
--- a/llvm_mode/afl-clang-fast.c
+++ b/llvm_mode/afl-clang-fast.c
@@ -844,14 +844,14 @@ int main(int argc, char **argv, char **envp) {
"\nafl-clang-fast specific environment variables:\n"
"AFL_LLVM_CMPLOG: log operands of comparisons (RedQueen mutator)\n"
"AFL_LLVM_INSTRUMENT: set instrumentation mode: DEFAULT, CFG "
- "(INSTRIM), LTO, CTX, NGRAM-2 ... NGRAM-16\n"
+ "(INSTRIM), PCGUARD, LTO, CTX, NGRAM-2 ... NGRAM-16\n"
" You can also use the old environment variables instead:"
- " AFL_LLVM_CTX: use context sensitive coverage\n"
" AFL_LLVM_USE_TRACE_PC: use LLVM trace-pc-guard instrumentation\n"
- " AFL_LLVM_NGRAM_SIZE: use ngram prev_loc count coverage\n"
" AFL_LLVM_INSTRIM: use light weight instrumentation InsTrim\n"
" AFL_LLVM_INSTRIM_LOOPHEAD: optimize loop tracing for speed (sub "
- "option to INSTRIM)\n");
+ "option to INSTRIM)\n"
+ " AFL_LLVM_CTX: use context sensitive coverage\n"
+ " AFL_LLVM_NGRAM_SIZE: use ngram prev_loc count coverage\n");
#ifdef AFL_CLANG_FLTO
SAYF(
diff --git a/llvm_mode/afl-llvm-common.cc b/llvm_mode/afl-llvm-common.cc
index db604e14..35eabbf0 100644
--- a/llvm_mode/afl-llvm-common.cc
+++ b/llvm_mode/afl-llvm-common.cc
@@ -33,7 +33,10 @@ char *getBBName(const llvm::BasicBlock *BB) {
std::string Str;
raw_string_ostream OS(Str);
+#if LLVM_VERSION_MAJOR >= 4 || \
+ (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)
BB->printAsOperand(OS, false);
+#endif
name = strdup(OS.str().c_str());
return name;
@@ -171,7 +174,7 @@ bool isInWhitelist(llvm::Function *F) {
#else
if (!Loc.isUnknown()) {
- DILocation cDILoc(Loc.getAsMDNode(C));
+ DILocation cDILoc(Loc.getAsMDNode(F->getContext()));
unsigned int instLine = cDILoc.getLineNumber();
StringRef instFilename = cDILoc.getFilename();
diff --git a/llvm_mode/afl-llvm-common.h b/llvm_mode/afl-llvm-common.h
index cf14d2e1..50ad3abc 100644
--- a/llvm_mode/afl-llvm-common.h
+++ b/llvm_mode/afl-llvm-common.h
@@ -25,11 +25,11 @@ typedef long double max_align_t;
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/CFG.h"
+ #include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/CFG.h"
#else
-#include "llvm/DebugInfo.h"
-#include "llvm/Support/CFG.h"
+ #include "llvm/DebugInfo.h"
+ #include "llvm/Support/CFG.h"
#endif
char * getBBName(const llvm::BasicBlock *BB);
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 2d23ad21..5bf705f8 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -54,11 +54,11 @@ typedef long double max_align_t;
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/CFG.h"
+ #include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/CFG.h"
#else
-#include "llvm/DebugInfo.h"
-#include "llvm/Support/CFG.h"
+ #include "llvm/DebugInfo.h"
+ #include "llvm/Support/CFG.h"
#endif
#include "afl-llvm-common.h"
@@ -115,7 +115,7 @@ uint64_t PowerOf2Ceil(unsigned in) {
/* #if LLVM_VERSION_STRING >= "4.0.1" */
#if LLVM_VERSION_MAJOR >= 4 || \
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
-#define AFL_HAVE_VECTOR_INTRINSICS 1
+ #define AFL_HAVE_VECTOR_INTRINSICS 1
#endif
bool AFLCoverage::runOnModule(Module &M) {
@@ -211,8 +211,15 @@ bool AFLCoverage::runOnModule(Module &M) {
else
#else
if (ngram_size_str)
- FATAL("Sorry, NGRAM branch coverage is not supported with llvm version %s!",
- LLVM_VERSION_STRING);
+#ifndef LLVM_VERSION_PATCH
+ FATAL("Sorry, NGRAM branch coverage is not supported with llvm version %d.%d.%d!",
+ LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR,
+ 0);
+#else
+ FATAL("Sorry, NGRAM branch coverage is not supported with llvm version %d.%d.%d!",
+ LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR,
+ LLVM_VERSION_PATCH);
+#endif
#endif
PrevLocSize = 1;
@@ -242,17 +249,17 @@ bool AFLCoverage::runOnModule(Module &M) {
#ifdef AFL_HAVE_VECTOR_INTRINSICS
if (ngram_size)
-#ifdef __ANDROID__
+ #ifdef __ANDROID__
AFLPrevLoc = new GlobalVariable(
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
/* Initializer */ nullptr, "__afl_prev_loc");
-#else
+ #else
AFLPrevLoc = new GlobalVariable(
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
/* Initializer */ nullptr, "__afl_prev_loc",
/* InsertBefore */ nullptr, GlobalVariable::GeneralDynamicTLSModel,
/* AddressSpace */ 0, /* IsExternallyInitialized */ false);
-#endif
+ #endif
else
#endif
#ifdef __ANDROID__
diff --git a/llvm_mode/afl-llvm-rt.o.c b/llvm_mode/afl-llvm-rt.o.c
index ce8df332..c0d1569d 100644
--- a/llvm_mode/afl-llvm-rt.o.c
+++ b/llvm_mode/afl-llvm-rt.o.c
@@ -21,7 +21,7 @@
*/
#ifdef __ANDROID__
-#include "android-ashmem.h"
+ #include "android-ashmem.h"
#endif
#include "config.h"
#include "types.h"
@@ -43,7 +43,7 @@
#include <sys/types.h>
#ifdef __linux__
-#include "snapshot-inl.h"
+ #include "snapshot-inl.h"
#endif
/* This is a somewhat ugly hack for the experimental 'trace-pc-guard' mode.
@@ -53,7 +53,7 @@
#define CONST_PRIO 5
#ifndef MAP_FIXED_NOREPLACE
-#define MAP_FIXED_NOREPLACE MAP_FIXED
+ #define MAP_FIXED_NOREPLACE MAP_FIXED
#endif
#include <sys/mman.h>
@@ -826,15 +826,15 @@ void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2) {
}
#if defined(__APPLE__)
-#pragma weak __sanitizer_cov_trace_const_cmp1 = __cmplog_ins_hook1
-#pragma weak __sanitizer_cov_trace_const_cmp2 = __cmplog_ins_hook2
-#pragma weak __sanitizer_cov_trace_const_cmp4 = __cmplog_ins_hook4
-#pragma weak __sanitizer_cov_trace_const_cmp8 = __cmplog_ins_hook8
-
-#pragma weak __sanitizer_cov_trace_cmp1 = __cmplog_ins_hook1
-#pragma weak __sanitizer_cov_trace_cmp2 = __cmplog_ins_hook2
-#pragma weak __sanitizer_cov_trace_cmp4 = __cmplog_ins_hook4
-#pragma weak __sanitizer_cov_trace_cmp8 = __cmplog_ins_hook8
+ #pragma weak __sanitizer_cov_trace_const_cmp1 = __cmplog_ins_hook1
+ #pragma weak __sanitizer_cov_trace_const_cmp2 = __cmplog_ins_hook2
+ #pragma weak __sanitizer_cov_trace_const_cmp4 = __cmplog_ins_hook4
+ #pragma weak __sanitizer_cov_trace_const_cmp8 = __cmplog_ins_hook8
+
+ #pragma weak __sanitizer_cov_trace_cmp1 = __cmplog_ins_hook1
+ #pragma weak __sanitizer_cov_trace_cmp2 = __cmplog_ins_hook2
+ #pragma weak __sanitizer_cov_trace_cmp4 = __cmplog_ins_hook4
+ #pragma weak __sanitizer_cov_trace_cmp8 = __cmplog_ins_hook8
#else
void __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2)
__attribute__((alias("__cmplog_ins_hook1")));
diff --git a/llvm_mode/cmplog-instructions-pass.cc b/llvm_mode/cmplog-instructions-pass.cc
index 628151c6..b7f3cffa 100644
--- a/llvm_mode/cmplog-instructions-pass.cc
+++ b/llvm_mode/cmplog-instructions-pass.cc
@@ -38,12 +38,12 @@
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/Verifier.h"
-#include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/Verifier.h"
+ #include "llvm/IR/DebugInfo.h"
#else
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/DebugInfo.h"
-#define nullptr 0
+ #include "llvm/Analysis/Verifier.h"
+ #include "llvm/DebugInfo.h"
+ #define nullptr 0
#endif
#include <set>
diff --git a/llvm_mode/cmplog-routines-pass.cc b/llvm_mode/cmplog-routines-pass.cc
index b74fb712..bb78273a 100644
--- a/llvm_mode/cmplog-routines-pass.cc
+++ b/llvm_mode/cmplog-routines-pass.cc
@@ -38,12 +38,12 @@
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/Verifier.h"
-#include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/Verifier.h"
+ #include "llvm/IR/DebugInfo.h"
#else
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/DebugInfo.h"
-#define nullptr 0
+ #include "llvm/Analysis/Verifier.h"
+ #include "llvm/DebugInfo.h"
+ #define nullptr 0
#endif
#include <set>
diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc
index 00732dbc..1ebc54d7 100644
--- a/llvm_mode/compare-transform-pass.so.cc
+++ b/llvm_mode/compare-transform-pass.so.cc
@@ -25,7 +25,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/ADT/Statistic.h"
-#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
@@ -38,12 +37,12 @@
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/Verifier.h"
-#include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/Verifier.h"
+ #include "llvm/IR/DebugInfo.h"
#else
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/DebugInfo.h"
-#define nullptr 0
+ #include "llvm/Analysis/Verifier.h"
+ #include "llvm/DebugInfo.h"
+ #define nullptr 0
#endif
#include <set>
diff --git a/llvm_mode/split-compares-pass.so.cc b/llvm_mode/split-compares-pass.so.cc
index 9c91e44f..2c4ed71c 100644
--- a/llvm_mode/split-compares-pass.so.cc
+++ b/llvm_mode/split-compares-pass.so.cc
@@ -27,7 +27,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/Pass.h"
-#include "llvm/IR/DebugInfo.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
@@ -37,12 +36,12 @@
#include "llvm/IR/IRBuilder.h"
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/Verifier.h"
-#include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/Verifier.h"
+ #include "llvm/IR/DebugInfo.h"
#else
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/DebugInfo.h"
-#define nullptr 0
+ #include "llvm/Analysis/Verifier.h"
+ #include "llvm/DebugInfo.h"
+ #define nullptr 0
#endif
using namespace llvm;
diff --git a/llvm_mode/split-switches-pass.so.cc b/llvm_mode/split-switches-pass.so.cc
index e8639347..4a6ca3d9 100644
--- a/llvm_mode/split-switches-pass.so.cc
+++ b/llvm_mode/split-switches-pass.so.cc
@@ -26,7 +26,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/ADT/Statistic.h"
-#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
@@ -40,12 +39,12 @@
#include "llvm/IR/IRBuilder.h"
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
-#include "llvm/IR/Verifier.h"
-#include "llvm/IR/DebugInfo.h"
+ #include "llvm/IR/Verifier.h"
+ #include "llvm/IR/DebugInfo.h"
#else
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/DebugInfo.h"
-#define nullptr 0
+ #include "llvm/Analysis/Verifier.h"
+ #include "llvm/DebugInfo.h"
+ #define nullptr 0
#endif
#include <set>