ROSE  0.11.109.0
SageBuilderAsm.h
1 #ifndef ROSE_SageBuilderAsm_H
2 #define ROSE_SageBuilderAsm_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <AssemblerX86Init.h> // for X86InstructionKind
7 
8 namespace Rose {
9 
11 namespace SageBuilderAsm {
12 
14 // Build files
15 
33 SgBinaryComposite* buildBinaryComposite(const std::string &fileName);
34 
35 
36 
38 // Build data types
39 //
40 // These data type builders always return the same IR node and are thread-safe.
41 
42 // Generic data types
43 SgAsmIntegerType* buildTypeU(size_t nBits);
44 SgAsmIntegerType* buildTypeI(size_t nBits);
62 // Architecture-specific data types
74 // Generic value builders
76 SgAsmIntegerValueExpression* buildValueInteger(uint64_t value, SgAsmType*);
78 SgAsmFloatValueExpression* buildValueFloat(double value, SgAsmType*);
80 
82 // Building integer or FP values.
83 
84 // Build integer or FP values generically (one of these per buildType function above)
85 SgAsmIntegerValueExpression* buildValueU1(bool);
86 SgAsmIntegerValueExpression* buildValueU8(uint8_t);
87 SgAsmIntegerValueExpression* buildValueU16(uint16_t);
88 SgAsmIntegerValueExpression* buildValueU32(uint32_t);
89 SgAsmIntegerValueExpression* buildValueU64(uint64_t);
90 SgAsmIntegerValueExpression* buildValueI8(int8_t);
91 SgAsmIntegerValueExpression* buildValueI16(int16_t);
92 SgAsmIntegerValueExpression* buildValueI32(int32_t);
93 SgAsmIntegerValueExpression* buildValueI64(int64_t);
94 SgAsmFloatValueExpression* buildValueIeee754Binary32(double);
95 SgAsmFloatValueExpression* buildValueIeee754Binary64(double);
96 
97 // Template specializations for building integer values
98 template <class T>
99 SgAsmIntegerValueExpression* buildValue(T);
100 
101 // Building integer or FP values with x86-specific type names
102 SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
103 SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
104 SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
105 SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
106 SgAsmFloatValueExpression* buildValueX86Float32(double);
107 SgAsmFloatValueExpression* buildValueX86Float64(double);
108 SgAsmFloatValueExpression* buildValueX86Float80(double);
109 
111 // Operators
112 SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
113 SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
114 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
115 SgAsmBinaryPreupdate* buildPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
116 SgAsmBinaryPostupdate* buildPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
117 SgAsmBinaryMsl* buildMslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
118 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
119 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
120 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
121 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
122 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
123 SgAsmUnaryTruncate* buildTruncateExpression(SgAsmExpression*, SgAsmType*);
124 SgAsmBinaryConcat* buildConcatExpression(SgAsmExpression *moreSignificant, SgAsmExpression *lessSignificant);
125 SgAsmUnarySignedExtend* buildSignedExtendExpression(SgAsmExpression*, SgAsmType*);
126 SgAsmUnaryUnsignedExtend* buildUnsignedExtendExpression(SgAsmExpression*, SgAsmType*);
127 SgAsmExprListExp* buildExprListExpression();
128 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
129 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
130  SgAsmType *type=NULL);
136  SgAsmExpression*);
137 
138 
139 template <typename Insn>
140 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
141  SgAsmOperandList* operands = insn->get_operandList();
142  operands->get_operands().push_back(op);
143  op->set_parent(operands);
144  return insn; // For chaining this operation
145 }
146 
148 // Build instruction
152 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
153 
155 // Build basic blocks
156 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
157 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
158 
160 // Build data blocks
161 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
162 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
163 
164 
165 } // namespace
166 } // namespace
167 
168 #endif
169 #endif
Expression that adds two operands.
Expression that performs a right rotate.
Instruction basic block.
SgAsmIntegerType * buildTypeU16()
16-bit unsigned.
Expression that represents an update to a storage location.
SgAsmFloatType * buildIeee754Binary32()
32-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeI64()
64-bit signed.
RiscOperator
One enum per RISC operator.
SgAsmIntegerType * buildTypeU1()
1-bit unsigned (Boolean).
const SgAsmExpressionPtrList & get_operands() const
Property: Ordered list of instruction operands.
List of expression nodes.
SgAsmIntegerType * buildTypeU64()
64-bit unsigned.
Expression that performs an arithmetic, sign-bit preserving right shift.
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
Expression that performs a logical, sign-bit non-preserving right shift.
SgAsmFloatType * buildTypeM68kFloat96()
Motorola M68k 96-bit float (16-bits are always zero).
Expression representing truncation.
Represents a synthesized function.
SgAsmIntegerType * buildTypeU8()
8-bit unsigned.
SgAsmIntegerType * buildTypeU4()
4-bit unsigned.
Main namespace for the ROSE library.
SgAsmIntegerType * buildTypeI32()
32-bit signed.
SgAsmIntegerType * buildTypeX86Byte()
8-bit unsigned.
SgAsmIntegerType * buildTypeI16()
16-bit signed.
SgAsmFloatType * buildIeee754Binary128()
128-bit IEEE-754 floating-point.
Reference to memory locations.
SgAsmFloatType * buildTypeX86Float32()
32-bit IEEE-754 floating-point.
Base class for integer values.
List of operands for an instruction.
SgBinaryComposite * buildBinaryComposite(const std::string &fileName)
Build a new binary composite object.
SgAsmIntegerType * buildTypeX86DoubleWord()
32-bit unsigned.
SgAsmIntegerType * buildTypeU32()
32-bit unsigned.
SgAsmIntegerType * buildTypeX86QuadWord()
64-bit unsigned.
Represents static data in an executable.
Represents one Intel x86 machine instruction.
SgAsmFloatType * buildIeee754Binary16()
16-bit IEEE-754 floating-point.
Expression representing sign extending.
Base class for expressions.
Expression that performs a logical left shift operation.
Expression that multiplies two operands.
Expression that performs a logical left shift operation filling low-order bits with one...
Expression representing unsigned extending.
Base class for binary types.
SgAsmIntegerType * buildTypeI8()
8-bit signed.
SgAsmFloatType * buildTypeM68kFloat80()
Motorola M68k 96-bit float w/out 16-bit constant zero field.
Floating-point value.
SgAsmIntegerType * buildTypeU(size_t nBits)
Unsigned type of specified size.
Expression that subtracts the second operand from the first.
SgAsmIntegerType * buildTypeX86Word()
16-bit unsigned.
Expression that represents an update to a storage location.
SgAsmFloatType * buildIeee754Binary80()
80-bit IEEE-754 floating-point (as in x86).
Expression that concatenates two values to form a wider value.
X86InstructionKind
List of all x86 instructions known to the ROSE disassembler/assembler.
SgAsmFloatType * buildIeee754Binary64()
64-bit IEEE-754 floating-point.
Integer types.
SgAsmFloatType * buildTypeX86Float80()
80-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeI(size_t nBits)
Signed type of specified size.
Floating point types.
SgAsmVectorType * buildTypeVector(size_t, SgAsmType *)
Fixed-size, packed array.
Base class for vector types.
Static representation of instruction semantics.
SgAsmFloatType * buildTypeX86Float64()
64-bit IEEE-754 floating-point.
SgAsmVectorType * buildTypeX86DoubleQuadWord()
Vector of two 64-bit unsigned integers.