42 lines
846 B
C++
42 lines
846 B
C++
//---
|
|
// fxos.passes.pcrel: Resolution of PC-relative addresses
|
|
//---
|
|
|
|
#include <fxos/disasm-passes/pcrel.h>
|
|
|
|
namespace FxOS {
|
|
|
|
PcrelPass::PcrelPass(Disassembly &disasm):
|
|
DisassemblyPass(disasm)
|
|
{
|
|
}
|
|
|
|
void PcrelPass::analyze(uint32_t pc, ConcreteInstruction &ci)
|
|
{
|
|
Instruction const &i = ci.inst;
|
|
|
|
for(size_t n = 0; n < i.args.size(); n++)
|
|
{
|
|
Argument const &a = i.args[n];
|
|
ConcreteInstructionArg &ca = ci.args[n];
|
|
|
|
if(a.kind == Argument::PcRel)
|
|
{
|
|
uint32_t target = (pc & ~(a.opsize - 1)) + 4 + a.disp;
|
|
ca.location = RelConstDomain().constant(target);
|
|
|
|
/* Also compute the value */
|
|
uint32_t value = m_disasm.target().
|
|
}
|
|
else if(a.kind == Argument::PcJump)
|
|
{
|
|
uint32_t target = pc + 4 + a.disp;
|
|
ca.location = RelConstDomain().constant(target);
|
|
}
|
|
}
|
|
|
|
enqueue_unseen_successors(pc, ci);
|
|
}
|
|
|
|
} /* namespace FxOS */
|