Fix AFLCoverage Pass & small fixes (#678)

* fix

* more

* declare LIBAFL_CC_LLVM_VERSION at least when no llvm-config found

* More llvm14 fixes
This commit is contained in:
Dongjia Zhang 2022-06-24 00:55:06 +09:00 committed by GitHub
parent 5fd63c0076
commit 49de0046e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -248,6 +248,8 @@ fn main() {
pub const CLANG_PATH: &str = \"clang\"; pub const CLANG_PATH: &str = \"clang\";
/// The path to the `clang++` executable /// The path to the `clang++` executable
pub const CLANGXX_PATH: &str = \"clang++\"; pub const CLANGXX_PATH: &str = \"clang++\";
/// The llvm version used to build llvm passes
pub const LIBAFL_CC_LLVM_VERSION: Option<usize> = None;
" "
) )
.expect("Could not write file"); .expect("Could not write file");

View File

@ -51,6 +51,11 @@
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/FormatVariadic.h"
// Without this, Can't build with llvm-14 & old PM
#if LLVM_VERSION_MAJOR >= 14 && !defined(USE_NEW_PM)
#include "llvm/Pass.h"
#endif
#if LLVM_VERSION_MAJOR > 3 || \ #if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4) (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
#include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugInfo.h"
@ -593,11 +598,21 @@ bool AFLCoverage::runOnModule(Module &M) {
/* Load prev_loc */ /* Load prev_loc */
LoadInst *PrevLoc = IRB.CreateLoad( LoadInst *PrevLoc;
if (Ngram) {
PrevLoc = IRB.CreateLoad(
#if LLVM_VERSION_MAJOR >= 14 #if LLVM_VERSION_MAJOR >= 14
PrevLocTy, PrevLocTy,
#endif #endif
AFLPrevLoc); AFLPrevLoc);
} else {
PrevLoc = IRB.CreateLoad(
#if LLVM_VERSION_MAJOR >= 14
IRB.getInt32Ty(),
#endif
AFLPrevLoc);
}
PrevLoc->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); PrevLoc->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
Value *PrevLocTrans; Value *PrevLocTrans;

View File

@ -41,6 +41,11 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
// Without this, Can't build with llvm-14 & old PM
#if LLVM_VERSION_MAJOR >= 14 && !defined(USE_NEW_PM)
#include "llvm/Pass.h"
#endif
#if LLVM_VERSION_MAJOR > 3 || \ #if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4) (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
#include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugInfo.h"