我编写了一个简单的llvm Pass来计算c ++源文件中的操作码.我对源文件没有任何问题,我已成功获取它的.bc文件.现在当我通过我的Pass然后它崩溃了.传递的代码如下(SourceCode不是问题):
#define DEBUG_TYPE "opCounter"
#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
using namespace llvm;
namespace
{
struct CountOperands : public FunctionPass
{
std::map<std::string,int> opCounter;
static char ID;
/*Constructor*/
CountOperands() : FunctionPass(ID) {}
/*RunOnFuntion Method*/
virtual bool runOnFunction( Function &F)
{
errs() << "Function Name: " << F.getName() << "\n";
/*Reading the OpCode in the function*/
for (Function::iterator bb = F.begin(), e = F.end(); bb != e; ++bb)
{
BasicBlock &b = *bb;
errs() << "##########Works fine till …Run Code Online (Sandbox Code Playgroud) 我正在研究LLVM混淆项目.我已经写了一个llvm传递(让我们说流动扁平化传递),我使用以下命令在源(test.c)上运行它:
clang -emit-llvm test.c -c -o test.bc
opt -load ../../.. LLVMFlattening.so -fla <test.bc>/dev/null
Run Code Online (Sandbox Code Playgroud)
但我已经看到,在O-LLVM项目中,他们使用以下方法实现了相同的目标:
clang -emit-llvm test.c -c -o test.bc -mllvm -fla
Run Code Online (Sandbox Code Playgroud)
有人能告诉我这里的-mllvm是什么,以及如何将其改为简单的命令?