[Rose-public] Help with Binary inter-procedural dataflow analysis
matzke at hoosierfocus.com
Wed Mar 4 16:41:58 PST 2015
On 03/04/2015 07:14 PM, Shubham Bansal wrote:
> Okay. I got your point but the main problem is how to detect if the
> instruction is reading or writing given only SgAsmInstruction ?
> Should i look for signatures like detecting the mov* instructions ? and
> how to find out which operand is used for read/write and how ?
I see. There are three ways I can think of quickly:
1. You can find if an SgAsmInstruction has an operand that references
memory by doing an AST traversal starting at the instruction and looking
for a SgAsmMemoryReference node. This is easy but won't work for
instructions that implicitly reference memory (e.g., PUSH, POP).
2. Your idea: a big switch statement that makes the read/write decision
based on the kind of instruction (SgAsmX86Instruction::get_kind). This
will be architecture-dependent.
3. Semantics (my previous email): this is the most flexible and
architecture-independent way to get read/write info without a lot of coding.
More information about the rose-public