本文整理汇总了C++中instruction::Ptr::getMemoryReadOperands方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::getMemoryReadOperands方法的具体用法?C++ Ptr::getMemoryReadOperands怎么用?C++ Ptr::getMemoryReadOperands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类instruction::Ptr
的用法示例。
在下文中一共展示了Ptr::getMemoryReadOperands方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isNopInsn
bool isNopInsn(Instruction::Ptr insn)
{
// TODO: add LEA no-ops
if(insn->getOperation().getID() == e_nop)
return true;
if(insn->getOperation().getID() == e_lea)
{
std::set<Expression::Ptr> memReadAddr;
insn->getMemoryReadOperands(memReadAddr);
std::set<RegisterAST::Ptr> writtenRegs;
insn->getWriteSet(writtenRegs);
if(memReadAddr.size() == 1 && writtenRegs.size() == 1)
{
if(**(memReadAddr.begin()) == **(writtenRegs.begin()))
{
return true;
}
}
// Check for zero displacement
nopVisitor visitor;
// We need to get the src operand
insn->getOperand(1).getValue()->apply(&visitor);
if (visitor.isNop) return true;
}
return false;
}
示例2: assert
bool IA_x86Details::computeTableBounds(Instruction::Ptr maxSwitchInsn,
Instruction::Ptr branchInsn,
Instruction::Ptr tableInsn,
bool foundJCCAlongTaken,
unsigned& tableSize,
unsigned& tableStride)
{
assert(maxSwitchInsn && branchInsn);
Result compareBound = maxSwitchInsn->getOperand(1).getValue()->eval();
if(!compareBound.defined) return false;
tableSize = compareBound.convert<unsigned>();
// Sanity check the bounds; 32k tables would be an oddity, and larger is almost certainly
// a misparse
static const unsigned int maxTableSize = 32768;
if(tableSize > maxTableSize)
{
parsing_printf("\tmaxSwitch of %d above %d, BAILING OUT\n", tableSize, maxTableSize);
return false;
}
if(foundJCCAlongTaken)
{
if(branchInsn->getOperation().getID() == e_jbe ||
branchInsn->getOperation().getID() == e_jle)
{
tableSize++;
}
}
else
{
if(branchInsn->getOperation().getID() == e_jnbe ||
branchInsn->getOperation().getID() == e_jnle)
{
tableSize++;
}
}
parsing_printf("\tmaxSwitch set to %d\n", tableSize);
tableStride = currentBlock->_isrc->getAddressWidth();
std::set<Expression::Ptr> tableInsnReadAddr;
tableInsn->getMemoryReadOperands(tableInsnReadAddr);
if(tableStride == 8)
{
static Immediate::Ptr four(new Immediate(Result(u8, 4)));
static BinaryFunction::funcT::Ptr multiplier(new BinaryFunction::multResult());
static Expression::Ptr dummy(new DummyExpr());
static BinaryFunction::Ptr scaleCheck(new BinaryFunction(four, dummy, u64, multiplier));
for(std::set<Expression::Ptr>::const_iterator curExpr = tableInsnReadAddr.begin();
curExpr != tableInsnReadAddr.end();
++curExpr)
{
if((*curExpr)->isUsed(scaleCheck))
{
tableSize = tableSize >> 1;
parsing_printf("\tmaxSwitch revised to %d\n",tableSize);
}
}
}