Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions crates/libafl_cc/src/autotokens-pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,11 @@ PreservedAnalyses AutoTokensPass::run(Module &M, ModuleAnalysisManager &MAM) {
isStrcmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
FT->getParamType(0) == PointerType::get(M.getContext(), 0);
isStrcasecmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
FT->getParamType(0) == PointerType::get(M.getContext(), 0);
isMemcmp &= FT->getNumParams() == 3 &&
FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0)->isPointerTy() &&
Expand All @@ -314,14 +312,12 @@ PreservedAnalyses AutoTokensPass::run(Module &M, ModuleAnalysisManager &MAM) {
isStrncmp &=
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
FT->getParamType(0) == PointerType::get(M.getContext(), 0) &&
FT->getParamType(2)->isIntegerTy();
isStrncasecmp &=
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
FT->getParamType(0) == PointerType::get(M.getContext(), 0) &&
FT->getParamType(2)->isIntegerTy();
isStdString &= FT->getNumParams() >= 2 &&
FT->getParamType(0)->isPointerTy() &&
Expand Down
2 changes: 1 addition & 1 deletion crates/libafl_cc/src/cmplog-instructions-pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
}
#endif

Constant *Null = Constant::getNullValue(PointerType::get(Int8Ty, 0));
Constant *Null = Constant::getNullValue(PointerType::get(M.getContext(), 0));

/* iterate over all functions, bbs and instruction and add suitable calls */
for (auto &F : M) {
Expand Down
8 changes: 3 additions & 5 deletions crates/libafl_cc/src/cmplog-routines-pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
PointerType *i8PtrTy = PointerType::get(Int8Ty, 0);
PointerType *i8PtrTy = PointerType::get(M.getContext(), 0);

FunctionCallee cmplogHookFn;
FunctionCallee cmplogLlvmStdStd;
Expand Down Expand Up @@ -229,8 +229,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
isStrcmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
FT->getParamType(0) == PointerType::get(M.getContext(), 0);

bool isStrncmp = (!FuncName.compare("strncmp") ||
!FuncName.compare("xmlStrncmp") ||
Expand All @@ -246,8 +245,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
isStrncmp &=
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
FT->getParamType(0) == PointerType::get(M.getContext(), 0) &&
FT->getParamType(2)->isIntegerTy();

bool isGccStdStringStdString =
Expand Down
28 changes: 22 additions & 6 deletions crates/libafl_cc/src/common-llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#define HAVE_VECTOR_INTRINSICS 1

#include <optional>
#if LLVM_VERSION_MAJOR >= 16
// None constant being deprecated for LLVM-16, it is recommended
// to use the std::nullopt_t type instead. (#1010)
constexpr std::nullopt_t None = std::nullopt;
#endif

// all llvm includes and friends
#include "llvm/Support/CommandLine.h"
Expand All @@ -25,10 +20,31 @@ constexpr std::nullopt_t None = std::nullopt;
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IR/CFG.h"
#include "llvm/Passes/PassPlugin.h"
#if LLVM_VERSION_MAJOR >= 22
#include "llvm/Plugins/PassPlugin.h"
#else
#include "llvm/Passes/PassPlugin.h"
#endif
#include "llvm/Passes/PassBuilder.h"
#include "llvm/IR/PassManager.h"

#if LLVM_VERSION_MAJOR >= 21
// None is only used in libafl_cc as the second parameter of MDNode::get()
// that param is an ArrayRef, which can no longer be constructed with a
// nullopt since LLVM 21+
//
// Keep these around to keep IWYU quiet
#include "llvm/ADT/ArrayRef.h"
namespace llvm {
class Metadata;
}
inline constexpr llvm::ArrayRef<llvm::Metadata *> None{};
#elif LLVM_VERSION_MAJOR >= 16
// None constant being deprecated for LLVM-16, it is recommended
// to use the std::nullopt_t type instead. (#1010)
constexpr std::nullopt_t None = std::nullopt;
#endif

#define FATAL(...) \
do { \
fprintf(stderr, "FATAL: " __VA_ARGS__); \
Expand Down
6 changes: 3 additions & 3 deletions crates/libafl_cc/src/coverage-accounting-pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ PreservedAnalyses AFLCoverage::run(Module &M, ModuleAnalysisManager &MAM) {
__afl_acc_prev_loc is thread-local. */

GlobalVariable *AFLMemOpPtr = new GlobalVariable(
M, PointerType::get(Int32Ty, 0), false, GlobalValue::ExternalLinkage, 0,
"__afl_acc_memop_ptr");
M, PointerType::get(M.getContext(), 0), false,
GlobalValue::ExternalLinkage, 0, "__afl_acc_memop_ptr");

GlobalVariable *AFLPrevLoc;

Expand Down Expand Up @@ -301,7 +301,7 @@ PreservedAnalyses AFLCoverage::run(Module &M, ModuleAnalysisManager &MAM) {
/* Load SHM pointer */

LoadInst *MemReadPtr =
IRB.CreateLoad(PointerType::get(Int32Ty, 0), AFLMemOpPtr);
IRB.CreateLoad(PointerType::get(M.getContext(), 0), AFLMemOpPtr);
MemReadPtr->setMetadata(M.getMDKindID("nosanitize"),
MDNode::get(C, None));
Value *MemReadPtrIdx =
Expand Down
7 changes: 0 additions & 7 deletions crates/libafl_cc/src/dump-cfg-pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@

#include <nlohmann/json.hpp>

#define FATAL(x...) \
do { \
fprintf(stderr, "FATAL: " x); \
exit(1); \
\
} while (0)

using namespace llvm;

namespace {
Expand Down
6 changes: 5 additions & 1 deletion crates/libafl_cc/src/function-logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/IRBuilder.h"

#include "llvm/Passes/PassPlugin.h"
#if LLVM_VERSION_MAJOR >= 22
#include "llvm/Plugins/PassPlugin.h"
#else
#include "llvm/Passes/PassPlugin.h"
#endif
#include "llvm/Passes/PassBuilder.h"
#include "llvm/IR/PassManager.h"

Expand Down
Loading