mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-19 13:03:44 +00:00
fix llvm compatibility problems. Should compile now with llvm 3.8.0
up to llvm 8.0
This commit is contained in:
@ -23,11 +23,11 @@ BIN_PATH = $(PREFIX)/bin
|
|||||||
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
LLVM_CONFIG ?= llvm-config
|
LLVM_CONFIG ?= llvm-config
|
||||||
LLVM_OK = $(shell $(LLVM_CONFIG) --version | egrep -q '^[5-6]' && echo 0 || echo 1 )
|
#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_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version | egrep -q '^[3].0' && echo 1 || echo 0 )
|
||||||
|
|
||||||
ifeq "$(LLVM_UNSUPPORTED)" "1"
|
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
|
endif
|
||||||
|
|
||||||
CFLAGS ?= -O3 -funroll-loops
|
CFLAGS ?= -O3 -funroll-loops
|
||||||
@ -42,7 +42,7 @@ CXXFLAGS ?= -O3 -funroll-loops
|
|||||||
CXXFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
|
CXXFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
|
||||||
-DVERSION=\"$(VERSION)\" -Wno-variadic-macros
|
-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)
|
CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
|
||||||
|
|
||||||
# User teor2345 reports that this is required to make things work on MacOS X.
|
# User teor2345 reports that this is required to make things work on MacOS X.
|
||||||
@ -57,11 +57,7 @@ endif
|
|||||||
|
|
||||||
ifeq "$(origin CC)" "default"
|
ifeq "$(origin CC)" "default"
|
||||||
CC = clang
|
CC = clang
|
||||||
ifeq "$(LLVM_OK)" "1"
|
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
else
|
|
||||||
CXX = g++
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef AFL_TRACE_PC
|
ifndef AFL_TRACE_PC
|
||||||
|
@ -7,8 +7,7 @@ Fast LLVM-based instrumentation for afl-fuzz
|
|||||||
1) Introduction
|
1) Introduction
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
! llvm_mode works with verison 3.0 up to 6.0.1 !
|
!!! This works with LLVM from version 3.8.1 up to version 8 !!!
|
||||||
! llvm version 7, 8 and 9 do not work !
|
|
||||||
|
|
||||||
The code in this directory allows you to instrument programs for AFL using
|
The code in this directory allows you to instrument programs for AFL using
|
||||||
true compiler-level instrumentation, instead of the more crude
|
true compiler-level instrumentation, instead of the more crude
|
||||||
|
@ -296,8 +296,6 @@ static void edit_params(u32 argc, char** argv) {
|
|||||||
|
|
||||||
if (maybe_linking) {
|
if (maybe_linking) {
|
||||||
|
|
||||||
cc_params[cc_par_cnt++] = "-Wl,-znodelete";
|
|
||||||
|
|
||||||
if (x_set) {
|
if (x_set) {
|
||||||
cc_params[cc_par_cnt++] = "-x";
|
cc_params[cc_par_cnt++] = "-x";
|
||||||
cc_params[cc_par_cnt++] = "none";
|
cc_params[cc_par_cnt++] = "none";
|
||||||
|
@ -32,21 +32,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "llvm/IR/BasicBlock.h"
|
#include "llvm/IR/BasicBlock.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
#include "llvm/IR/LegacyPassManager.h"
|
#include "llvm/IR/LegacyPassManager.h"
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Transforms/IPO/PassManagerBuilder.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 "llvm/IR/CFG.h"
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -45,12 +45,8 @@ namespace {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
|
|
||||||
#if (__clang_major__ < 4)
|
#if LLVM_VERSION_MAJOR < 4
|
||||||
#ifndef __GNUG__
|
|
||||||
const char * getPassName() const override {
|
const char * getPassName() const override {
|
||||||
#else
|
|
||||||
StringRef getPassName() const override {
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
StringRef getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
#endif
|
#endif
|
||||||
@ -76,7 +72,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
|
|||||||
Constant* c = M.getOrInsertFunction("tolower",
|
Constant* c = M.getOrInsertFunction("tolower",
|
||||||
Int32Ty,
|
Int32Ty,
|
||||||
Int32Ty
|
Int32Ty
|
||||||
#if __clang_major__ < 7
|
#if LLVM_VERSION_MAJOR < 5
|
||||||
, nullptr
|
, nullptr
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
@ -222,7 +218,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
|
|||||||
BranchInst::Create(end_bb, next_bb);
|
BranchInst::Create(end_bb, next_bb);
|
||||||
PHINode *PN = PHINode::Create(Int32Ty, constLen + 1, "cmp_phi");
|
PHINode *PN = PHINode::Create(Int32Ty, constLen + 1, "cmp_phi");
|
||||||
|
|
||||||
#if __clang_major__ < 8
|
#if LLVM_VERSION_MAJOR < 8
|
||||||
TerminatorInst *term = bb->getTerminator();
|
TerminatorInst *term = bb->getTerminator();
|
||||||
#else
|
#else
|
||||||
Instruction *term = bb->getTerminator();
|
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);
|
next_bb = BasicBlock::Create(C, "cmp_added", end_bb->getParent(), end_bb);
|
||||||
BranchInst::Create(end_bb, next_bb);
|
BranchInst::Create(end_bb, next_bb);
|
||||||
|
|
||||||
#if __clang_major__ < 8
|
#if LLVM_VERSION_MAJOR < 8
|
||||||
TerminatorInst *term = cur_bb->getTerminator();
|
TerminatorInst *term = cur_bb->getTerminator();
|
||||||
#else
|
#else
|
||||||
Instruction *term = cur_bb->getTerminator();
|
Instruction *term = cur_bb->getTerminator();
|
||||||
|
@ -33,14 +33,10 @@ namespace {
|
|||||||
SplitComparesTransform() : ModulePass(ID) {}
|
SplitComparesTransform() : ModulePass(ID) {}
|
||||||
|
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
#if __clang_major__ >= 4
|
#if LLVM_VERSION_MAJOR >= 4
|
||||||
StringRef getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
#else
|
#else
|
||||||
#ifndef __GNUG__
|
|
||||||
const char * getPassName() const override {
|
const char * getPassName() const override {
|
||||||
#else
|
|
||||||
StringRef getPassName() const override {
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
return "simplifies and splits ICMP instructions";
|
return "simplifies and splits ICMP instructions";
|
||||||
}
|
}
|
||||||
|
@ -45,14 +45,10 @@ namespace {
|
|||||||
|
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
|
|
||||||
#if __clang_major__ >= 4
|
#if LLVM_VERSION_MAJOR >= 4
|
||||||
StringRef getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
#else
|
#else
|
||||||
#ifndef __GNUG__
|
|
||||||
const char * getPassName() const override {
|
const char * getPassName() const override {
|
||||||
#else
|
|
||||||
StringRef getPassName() const override {
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
return "splits switch constructs";
|
return "splits switch constructs";
|
||||||
}
|
}
|
||||||
@ -258,12 +254,8 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) {
|
|||||||
/* Prepare cases vector. */
|
/* Prepare cases vector. */
|
||||||
CaseVector Cases;
|
CaseVector Cases;
|
||||||
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i)
|
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i)
|
||||||
#if __clang_major__ < 5
|
#if LLVM_VERSION_MAJOR < 5
|
||||||
#ifndef __GNUG__
|
|
||||||
Cases.push_back(CaseExpr(i.getCaseValue(), i.getCaseSuccessor()));
|
Cases.push_back(CaseExpr(i.getCaseValue(), i.getCaseSuccessor()));
|
||||||
#else
|
|
||||||
Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
|
Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user