我一直在寻找几个小时,我找不到任何可以帮助我的东西.我正在开发一个涉及FunctionPass的项目.我已经实现了runOnFunction(Function&f)方法,并且工作正常.基本上它需要:
1)检测存储指令
2)将存储指令的存储器地址转换为整数
3)使用按位AND运算(0000FFFF)更改整数
4)将整数转换回指针
到目前为止,我有以下内容:
virtual bool runOnFunction(Function &F) {
for (Function::iterator bb = F.begin(), bbe = F.end(); bb != bbe; ++bb) {
BasicBlock& b = *bb;
for (BasicBlock::iterator i = b.begin(), ie = b.end(); i != ie; ++i) {
if(StoreInst *si = dyn_cast<StoreInst>(&*i)) {
PtrToIntInst* ptrToInt = new PtrToIntInst(si->getPointerOperand(), IntegerType::get(si->getContext(), 32), "", si);
}
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我不能为我的生活弄清楚如何实际插入指令,甚至找到一种方法来创建AND指令.如果有人能指出我正确的方向,那将是伟大的.
提前致谢.