aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHexcoder <heiko@hexco.de>2019-06-03 23:20:47 +0200
committerHexcoder <heiko@hexco.de>2019-06-03 23:20:47 +0200
commitb4678b77f1e090e78935a50c98a4493ee2abda09 (patch)
treeed68a4b136c7ade8138531ca556b7702e2b5460e
parentb3a504248f566e089175b5b42b0bd78c9148993a (diff)
downloadafl++-b4678b77f1e090e78935a50c98a4493ee2abda09.tar.gz
fix llvm compatibility problems. Should compile now with llvm 3.8.0
up to llvm 8.0
-rw-r--r--llvm_mode/Makefile14
-rw-r--r--llvm_mode/README.llvm3
-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.cc12
-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, 45 deletions
diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile
index c9e04aa5..8577ad97 100644
--- a/llvm_mode/Makefile
+++ b/llvm_mode/Makefile
@@ -23,11 +23,11 @@ BIN_PATH = $(PREFIX)/bin
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 '^[7-9]' && echo 1 || echo 0 )
+#LLVM_OK = $(shell $(LLVM_CONFIG) --version | egrep -q '^[5-6]' && echo 0 || echo 1 )
+LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version | egrep -q '^[3].0' && echo 1 || echo 0 )
ifeq "$(LLVM_UNSUPPORTED)" "1"
- $(error llvm_mode only supports versions 3.9 up to 6.0.1 )
+ $(error llvm_mode only supports llvm versions 3.8.0 and higher )
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` -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 3c152023..63532d9c 100644
--- a/llvm_mode/README.llvm
+++ b/llvm_mode/README.llvm
@@ -7,8 +7,7 @@ Fast LLVM-based instrumentation for afl-fuzz
1) Introduction
---------------
-! llvm_mode works with verison 3.0 up to 6.0.1 !
-! llvm version 7, 8 and 9 do not work !
+!!! This works with LLVM from version 3.8.1 up to version 8 !!!
The code in this directory allows you to instrument programs for AFL using
true compiler-level instrumentation, instead of the more crude
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 75c280f4..7222ea27 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
@@ -76,7 +72,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
Constant* c = M.getOrInsertFunction("tolower",
Int32Ty,
Int32Ty
-#if __clang_major__ < 7
+#if LLVM_VERSION_MAJOR < 5
, nullptr
#endif
);
@@ -222,7 +218,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();
@@ -263,7 +259,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