about summary refs log tree commit diff
path: root/llvm_mode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/Makefile12
-rw-r--r--llvm_mode/README.llvm2
-rw-r--r--llvm_mode/afl-clang-fast.c2
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc9
-rw-r--r--llvm_mode/compare-transform-pass.so.cc14
-rw-r--r--llvm_mode/split-compares-pass.so.cc6
-rw-r--r--llvm_mode/split-switches-pass.so.cc12
7 files changed, 13 insertions, 44 deletions
diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile
index faa0e1a1..441f8877 100644
--- a/llvm_mode/Makefile
+++ b/llvm_mode/Makefile
@@ -24,10 +24,10 @@ VERSION     = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
 
 LLVM_CONFIG ?= llvm-config
 #LLVM_OK = $(shell $(LLVM_CONFIG) --version | egrep -q '^[5-6]' && echo 0 || echo 1 )
-LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version | egrep -q '^9' && echo 1 || echo 0 )
+LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version | egrep -q '^9|3.0' && echo 1 || echo 0 )
 
 ifeq "$(LLVM_UNSUPPORTED)" "1"
-  $(warn llvm_mode only supports versions 3.9 up to 8 )
+  $(warn llvm_mode only supports versions 3.8.0 up to 8.x )
 endif
 
 CFLAGS      ?= -O3 -funroll-loops
@@ -42,7 +42,7 @@ CXXFLAGS    ?= -O3 -funroll-loops
 CXXFLAGS    += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
                -DVERSION=\"$(VERSION)\" -Wno-variadic-macros
 
-CLANG_CFL    = `$(LLVM_CONFIG) --cxxflags` -Wl,-znodelete -fno-rtti -fpic $(CXXFLAGS) 
+CLANG_CFL    = `$(LLVM_CONFIG) --cxxflags` -Wl,-znodelete -fno-rtti -fpic $(CXXFLAGS)
 CLANG_LFL    = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
 
 # User teor2345 reports that this is required to make things work on MacOS X.
@@ -57,11 +57,7 @@ endif
 
 ifeq "$(origin CC)" "default"
   CC         = clang
-#  ifeq "$(LLVM_OK)" "1"
-    CXX        = clang++
-#  else
-#    CXX        = g++
-#  endif
+  CXX        = clang++
 endif
 
 ifndef AFL_TRACE_PC
diff --git a/llvm_mode/README.llvm b/llvm_mode/README.llvm
index 64fd8f44..dc860e97 100644
--- a/llvm_mode/README.llvm
+++ b/llvm_mode/README.llvm
@@ -7,7 +7,7 @@ Fast LLVM-based instrumentation for afl-fuzz
 1) Introduction
 ---------------
 
-! llvm_mode works with verison 3.9 up to 8 !
+! llvm_mode works with llvm version 3.8.1 up to 8.x !
 ! llvm version 9 does not work yet !
 
 The code in this directory allows you to instrument programs for AFL using
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c
index 4a082a55..1e2e04ea 100644
--- a/llvm_mode/afl-clang-fast.c
+++ b/llvm_mode/afl-clang-fast.c
@@ -296,8 +296,6 @@ static void edit_params(u32 argc, char** argv) {
 
   if (maybe_linking) {
 
-    cc_params[cc_par_cnt++] = "-Wl,-znodelete";
-
     if (x_set) {
       cc_params[cc_par_cnt++] = "-x";
       cc_params[cc_par_cnt++] = "none";
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 85f52de1..15b3764a 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -32,21 +32,12 @@
 #include <unistd.h>
 
 #include "llvm/IR/BasicBlock.h"
-#include "llvm/ADT/Statistic.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
-#include "llvm/IR/BasicBlock.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Type.h"
 #include "llvm/IR/CFG.h"
-#include <algorithm>
 
 using namespace llvm;
 
diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc
index 6652de0f..54d33e18 100644
--- a/llvm_mode/compare-transform-pass.so.cc
+++ b/llvm_mode/compare-transform-pass.so.cc
@@ -45,12 +45,8 @@ namespace {
 
       bool runOnModule(Module &M) override;
 
-#if (__clang_major__ < 4)
- #ifndef __GNUG__
+#if LLVM_VERSION_MAJOR < 4
       const char * getPassName() const override {
- #else
-      StringRef getPassName() const override {
- #endif
 #else
       StringRef getPassName() const override {
 #endif
@@ -74,7 +70,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
   IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
   IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
 
-#if __clang_major__ < 9
+#if LLVM_VERSION_MAJOR < 9
   Constant* 
 #else
   FunctionCallee
@@ -82,7 +78,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
                c = M.getOrInsertFunction("tolower",
                                          Int32Ty,
                                          Int32Ty
-#if __clang_major__ < 7
+#if LLVM_VERSION_MAJOR < 5
 					 , nullptr
 #endif
 					 );
@@ -228,7 +224,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
     BranchInst::Create(end_bb, next_bb);
     PHINode *PN = PHINode::Create(Int32Ty, constLen + 1, "cmp_phi");
 
-#if __clang_major__ < 8
+#if LLVM_VERSION_MAJOR < 8
     TerminatorInst *term = bb->getTerminator();
 #else
     Instruction *term = bb->getTerminator();
@@ -269,7 +265,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
         next_bb =  BasicBlock::Create(C, "cmp_added", end_bb->getParent(), end_bb);
         BranchInst::Create(end_bb, next_bb);
 
-#if __clang_major__ < 8
+#if LLVM_VERSION_MAJOR < 8
         TerminatorInst *term = cur_bb->getTerminator();
 #else
         Instruction *term = cur_bb->getTerminator();
diff --git a/llvm_mode/split-compares-pass.so.cc b/llvm_mode/split-compares-pass.so.cc
index ae6a2d52..5c16c408 100644
--- a/llvm_mode/split-compares-pass.so.cc
+++ b/llvm_mode/split-compares-pass.so.cc
@@ -33,14 +33,10 @@ namespace {
       SplitComparesTransform() : ModulePass(ID) {}
 
       bool runOnModule(Module &M) override;
-#if __clang_major__ >= 4
+#if LLVM_VERSION_MAJOR >= 4
       StringRef getPassName() const override {
 #else
- #ifndef __GNUG__
       const char * getPassName() const override {
- #else
-      StringRef getPassName() const override {
- #endif
 #endif
         return "simplifies and splits ICMP instructions";
       }
diff --git a/llvm_mode/split-switches-pass.so.cc b/llvm_mode/split-switches-pass.so.cc
index 12be8a95..8d4db292 100644
--- a/llvm_mode/split-switches-pass.so.cc
+++ b/llvm_mode/split-switches-pass.so.cc
@@ -45,14 +45,10 @@ namespace {
 
       bool runOnModule(Module &M) override;
 
-#if __clang_major__ >= 4
+#if LLVM_VERSION_MAJOR >= 4
       StringRef getPassName() const override {
 #else
- #ifndef __GNUG__
       const char * getPassName() const override {
- #else
-      StringRef getPassName() const override {
- #endif
 #endif
         return "splits switch constructs";
       }
@@ -258,12 +254,8 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) {
     /* Prepare cases vector. */
     CaseVector Cases;
     for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i)
-#if __clang_major__ < 5
- #ifndef __GNUG__
+#if LLVM_VERSION_MAJOR < 5
       Cases.push_back(CaseExpr(i.getCaseValue(), i.getCaseSuccessor()));
- #else
-      Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
- #endif
 #else
       Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
 #endif