forgot one pass
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -23,6 +23,8 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- add AFL_EARY_FORKSERVER to install the forkserver as earliest as
possible in the target (for afl-gcc-fast/afl-clang-fast/
afl-clang-lto)
+ - afl-cc:
+ - converted all passed to use the new llvm pass manager for llvm 11+
- frida_mode:
- update to new frida release, handles now c++ throw/catch

MODIFY
instrumentation/afl-llvm-lto-instrumentlist.so.cc
instrumentation/afl-llvm-lto-instrumentlist.so.cc
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+//#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
+#include "llvm/Passes/PassBuilder.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/IR/CFG.h"
+#if LLVM_VERSION_MAJOR >= 14 /* how about stable interfaces? */
+ #include "llvm/Passes/OptimizationLevel.h"
+#endif
#include "afl-llvm-common.h"
@@ -54,11 +60,10 @@ using namespace llvm;
namespace {
-class AFLcheckIfInstrument : public ModulePass {
+class AFLcheckIfInstrument : public PassInfoMixin<AFLcheckIfInstrument> {
public:
- static char ID;
- AFLcheckIfInstrument() : ModulePass(ID) {
+ AFLcheckIfInstrument() {
if (getenv("AFL_DEBUG")) debug = 1;
@@ -66,12 +71,7 @@ class AFLcheckIfInstrument : public ModulePass {
}
- bool runOnModule(Module &M) override;
-
- // StringRef getPassName() const override {
-
- // return "American Fuzzy Lop Instrumentation";
- // }
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
protected:
std::list<std::string> myInstrumentList;
@@ -80,9 +80,29 @@ class AFLcheckIfInstrument : public ModulePass {
} // namespace
-char AFLcheckIfInstrument::ID = 0;
+extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
+llvmGetPassPluginInfo() {
+
+ return {LLVM_PLUGIN_API_VERSION, "AFLcheckIfInstrument", "v0.1",
+ /* lambda to insert our pass into the pass pipeline. */
+ [](PassBuilder &PB) {
+
+#if LLVM_VERSION_MAJOR <= 13
+ using OptimizationLevel = typename PassBuilder::OptimizationLevel;
+#endif
+ PB.registerOptimizerLastEPCallback(
+ [](ModulePassManager &MPM, OptimizationLevel OL) {
+
+ MPM.addPass(AFLcheckIfInstrument());
+
+ });
+
+ }};
-bool AFLcheckIfInstrument::runOnModule(Module &M) {
+}
+
+PreservedAnalyses AFLcheckIfInstrument::run(Module & M,
+ ModuleAnalysisManager &MAM) {
/* Show a banner */
@@ -131,10 +151,12 @@ bool AFLcheckIfInstrument::runOnModule(Module &M) {
}
- return true;
+ auto PA = PreservedAnalyses::all();
+ return PA;
}
+#if 0
static void registerAFLcheckIfInstrumentpass(const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
@@ -149,4 +171,5 @@ static RegisterStandardPasses RegisterAFLcheckIfInstrumentpass(
static RegisterStandardPasses RegisterAFLcheckIfInstrumentpass0(
PassManagerBuilder::EP_EnabledOnOptLevel0,
registerAFLcheckIfInstrumentpass);
+#endif

MODIFY
instrumentation/afl-llvm-pass.so.cc
instrumentation/afl-llvm-pass.so.cc
typedef long double max_align_t;
#endif
-#include "llvm/IR/IRBuilder.h"
#include "llvm/Pass.h"
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
#include "llvm/Passes/PassPlugin.h"
@@ -71,6 +70,8 @@ typedef long double max_align_t;
#include "llvm/Support/CFG.h"
#endif
+#include "llvm/IR/IRBuilder.h"
+
#include "afl-llvm-common.h"
#include "llvm-alternative-coverage.h"

forgot one pass