message(STATUS"LLVM_INCLUDE_DIRS : ${LLVM_INCLUDE_DIRS}") message(STATUS"LLVM_LIBRARY_DIRS : ${LLVM_LIBRARY_DIRS}") # 添加项目文件 add_library( hello-world SHARED hello-world.cpp ) # Use C++11 to compile your pass (i.e., supply -std=c++11). target_compile_features(hello-world PRIVA...
CmakeLists.txt文件如下 cmake_minimum_required(VERSION3.22)project(testVERSION1.0.0LANGUAGESCCXX)set(CMAKE_CXX_STANDARD17)find_package(LLVMREQUIRED)message(STATUS"Found LLVM: "${LLVM_FOUND})message(STATUS"LLVM version: "${LLVM_VERSION})message(STATUS"LLVM include directory: "${LLVM_INCLUDE_DIRS})...
#include "llvm/Passes/PassBuilder.h" // 提供 PassBuilder,用于注册和管理 Pass #include "llvm/Passes/PassPlugin.h" // 用于实现动态插件的接口 #include "llvm/IR/Module.h" // 定义了 Module 类,用于表示 LLVM IR 的顶层结构 #include "llvm/Support/raw_ostream.h" // 提供 LLVM 的输出支持,如 ...
message(STATUS"LLVM_INCLUDE_DIRS : ${LLVM_INCLUDE_DIRS}") message(STATUS"LLVM_LIBRARY_DIRS : ${LLVM_LIBRARY_DIRS}") # 添加项目文件 add_library( hello-world SHARED hello-world.cpp ) # Use C++11 to compile your pass (i.e., supply -std=c++11). target_compile_features(hello-world PRIVA...
include_directories(${LLVM_INCLUDE_DIRS}) add_definitions(${LLVM_DEFINITIONS}) # Now build our tools add_executable(hello-world ${SOURCE_FILES}) # Find the libraries that correspond to the LLVM components # that we wish to use llvm_map_components_to_libnames(llvm_libs support core irreader...
include_directories(${LLVM_INCLUDE_DIRS}) add_subdirectory(下级目录名) 配置好后,写一个简单的函数名和变量名加密的Pass,实现方式主要是通过Module遍历Function,getName获取Function名后加密函数名,这里用MD5代替加密函数,之后通过setName再设置成加密后的函...
#include<cstdio>voidHello(){printf("Hello, World!\n");return; }intmain(){Hello();return0; } 先试试.ll格式的 clang -S -emit-llvm hello.cpp -o hello.ll 然后出来大概是这样的 ; ModuleID ='hello.cpp' source_filename ="hello.cpp"target datalayout ="e-m:e-p270:32:32-p271:32:...
cmake_minimum_required(VERSION 3.0) project(YourProjectName) # 设置C++标准 set(CMAKE_CXX_STANDARD 11) # 导入llvm库 find_package(LLVM REQUIRED CONFIG) # 添加llvm头文件路径 include_directories(${LLVM_INCLUDE_DIRS}) add_definitions(${LLVM_DEFINITIONS}) # 添加你的源文件 add_executable(YourExecutab...
include_directories(${LLVM_INCLUDE_DIRS}) add_subdirectory(下级目录名) namespace { struct EncodeFunctionName2 : public ModulePass { static charID; EncodeFunctionName2() : ModulePass(ID) {} boolrunOnFunction(Function &F) { Module*M=F.getParent(); ...
set(LLVM_INCLUDE_DIRS"${LLVM_INSTALL_PREFIX}/include") set(LLVM_LIBRARY_DIRS"${LLVM_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}") # These variables are duplicated, but they must match the LLVM variables of the # same name. The variables ending in "S" could some day become lists, and ar...