ROSE 0.11.145.192
sageInterfaceAsm.h
1#ifndef ROSE_SAGE_INTERFACE_ASM
2#define ROSE_SAGE_INTERFACE_ASM
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6// These functions in this file are expected to become a part of the
7// Binary Analysis and Transformation interfaces in the new ROSE API.
8
9namespace SageInterface
10 {
11 // DQ (4/26/2010): Added this file of functions to support binary analysis work.
12
13 void addComment(SgAsmStatement* stmt, const std::string & input_string );
14
15 SgAsmElfSection* getSection ( SgProject* project, const std::string & name );
16
17 // Simple way to get the section that that a pointer points into (if any).
18 SgAsmElfSection* getSection ( SgProject* project, size_t ptr );
19
22
25
28
29 std::string generateUniqueName ( size_t value, std::map<size_t,int> & usedOffsets, size_t & counter );
30
31 size_t get_value ( SgAsmValueExpression* asmValueExpression );
32 std::string get_valueString( SgAsmValueExpression* asmValueExpression );
33
34 bool isMovInstruction ( SgAsmInstruction* asmInstruction );
35
36 bool isInstructionKind ( SgAsmInstruction* asmInstruction, Rose::BinaryAnalysis::X86InstructionKind instuctionKind );
37
38 typedef bool (*EquivalenceTestFunctionType) (SgNode* x, SgNode* y);
39
40 // Definition of object equivalence for purposes of the AST matching using for instruction recognition.
41 bool equivalenceTest(SgNode* x, SgNode* y);
42
43 // These functions are used internally within the find function.
44 std::vector<SgNode*> flattenAST ( SgNode* node );
45 std::vector<SgNode*> matchAST ( SgNode* node, std::vector<SgNode*> & listOfNodes, EquivalenceTestFunctionType equivalenceTest );
46
47 // General function to find matching target AST in larger AST.
48 // SgNode* find ( SgNode* astNode, SgNode* target, EquivalenceTestFunctionType equivalenceTest );
49 std::vector<SgNode*> find ( SgNode* astNode, SgNode* target, EquivalenceTestFunctionType equivalenceTest );
50
51 // DQ (4/28/2010): Added support for interface to detect NOP's in all their glory.
53 // bool isNOP ( const SgAsmInstruction* asmInstruction );
54 bool isNOP ( SgAsmInstruction* asmInstruction );
56 bool isNOP ( const std::vector<SgAsmInstruction*> & asmInstructionList );
58 std::vector<std::vector<SgAsmInstruction*> > find_NOP_sequences ( SgAsmBlock* asmBlock );
59
60 // DQ (5/1/2010): We need a whole set of interface functions similar to this.
62 void insertInstruction(SgAsmInstruction* targetInstruction, SgAsmInstruction* newInstruction, bool insertBefore);
63
65 void insertInstructionBefore(SgAsmInstruction* targetInstruction, SgAsmInstruction* newInstruction);
66
69
70 }
71
72#endif
73#endif
Instruction basic block.
Base class for ELF file sections.
Represents a synthesized function.
Base class for machine instructions.
Represents an interpretation of a binary container.
Base class for all binary analysis IR nodes.
Base class for statement-like subclasses.
Base class for values.
This class represents the base class for all IR nodes within Sage III.
This class represents a source project, with a list of SgFile objects and global information about th...
X86InstructionKind
List of all x86 instructions known to the ROSE disassembler/assembler.
Functions that are useful when operating on the AST.
Definition sageBuilder.h:25
void insertInstruction(SgAsmInstruction *targetInstruction, SgAsmInstruction *newInstruction, bool insertBefore)
Support for insertion of instruction relative to a target instruction.
bool isNOP(SgAsmInstruction *asmInstruction)
Test an instruction for if it has no side-effect to the state (is so then it is a NOP)....
SgAsmBlock * getAsmBlock(SgAsmInstruction *asmInstruction)
Traverses AST backwards up the tree along the "parent" edges to the SgAsmBlock.
std::string generateUniqueName(const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations)
Generate unique name from C and C++ constructs. The name may contain space.
std::vector< std::vector< SgAsmInstruction * > > find_NOP_sequences(SgAsmBlock *asmBlock)
find sequences of NOP instructions in a SgAsmBlock
SgAsmInterpretation * getAsmInterpretation(SgAsmNode *asmNode)
Traverses AST backwards up the tree along the "parent" edges to the SgAsmInterpretation.
SgAsmFunction * getAsmFunction(SgAsmInstruction *asmInstruction)
Traverses AST backwards up the tree along the "parent" edges to the SgAsmFunction.
void removeInstruction(SgAsmStatement *instruction)
Remove a instruction.
void insertInstructionBefore(SgAsmInstruction *targetInstruction, SgAsmInstruction *newInstruction)
Insert a instruction before a target instruction.