ROSE 2.9.0
Loading...
Searching...
No Matches
BinaryAnalysis/ByteCode/Analysis.h
1#ifndef ROSE_BinaryAnalysis_ByteCode_Analysis_H
2#define ROSE_BinaryAnalysis_ByteCode_Analysis_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/Disassembler/BasicTypes.h>
7#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
8
9// For operators
10#include <Rose/BinaryAnalysis/InstructionSemantics/SymbolicSemantics.h>
11
13
16
17namespace Rose {
18namespace BinaryAnalysis {
19namespace ByteCode {
20
21using BasicBlockPtr = P2::BasicBlockPtr;
22using PartitionerPtr = P2::PartitionerPtr;
23
24// Forward references
25class Class;
26class Namespace;
27
28using NamespacePtr = Sawyer::SharedPointer<Namespace>;
29
35 public Sawyer::SharedFromThis<Code> {
36 public:
39
40 virtual ~Code();
41
42public:
43 virtual const uint8_t* bytes() const = 0;
44 virtual size_t size() const = 0;
45 virtual Address offset() const = 0;
46
47protected:
48 Code();
49};
50
56 public Sawyer::SharedFromThis<Field> {
57 public:
60
61 virtual ~Field();
62
63public:
64 virtual std::string name() const = 0;
65
66protected:
67 Field();
68};
69
76 public Sawyer::SharedFromThis<Method> {
77 public:
80
81 virtual ~Method();
82
83public:
84 virtual std::string name() const = 0;
85 virtual bool isSystemReserved(const std::string &name) const = 0;
86
87 virtual const Code & code() const = 0;
88 virtual const SgAsmInstructionList* instructions() const = 0;
89 virtual void decode(const Disassembler::BasePtr&) const = 0;
90
91 /* Annotate the AST (.e.g., add comments to instructions) */
92 virtual void annotate() = 0;
93
94 /* Set of instruction branch targets */
95 std::set<Address> targets() const;
96
97 // Methods associated with basic blocks (Rose::BinaryAnalysis::Partitioner2)
98 //
99 const std::vector<BasicBlockPtr>& blocks() const;
100 void append(BasicBlockPtr bb);
101
102 Method() = delete;
103
104protected:
106 Address classAddr_;
107 P2::FunctionPtr function_;
108 std::vector<BasicBlockPtr> blocks_;
109};
110
116 public Sawyer::SharedFromThis<Class> {
117 public:
120
121 virtual ~Interface();
122
123 virtual std::string name() const = 0;
124
125 protected:
126 Interface();
127};
128
134 public Sawyer::SharedFromThis<Attribute> {
135public:
138
139 virtual ~Attribute();
140
141 virtual std::string name() const = 0;
142
143 protected:
144 Attribute();
145};
146
152 public Sawyer::SharedFromThis<Class> {
153 public:
156
157 virtual ~Class();
158
160 // Dynamic pointer cast. No-op since this is the base class
161 // static Class promote(const Class&);
162
163 virtual std::string name() const = 0;
164 virtual std::string super_name() const = 0;
165 virtual std::string typeSeparator() const = 0;
166
167 virtual const std::vector<std::string>& strings();
168
169 const std::vector<Field::Ptr>& fields() const;
170 const std::vector<Method::Ptr>& methods() const;
171 const std::vector<Attribute::Ptr>& attributes() const;
172 const std::vector<Interface::Ptr>& interfaces() const;
173
174 virtual void partition(const PartitionerPtr &partitioner, BS::RiscOperatorsPtr &ops,
175 std::map<std::string,Address> &discoveredFunctions) const;
176
177 virtual void digraph() const;
178 virtual void dump() = 0;
179
180 Address address() const;
181
182 Class() = delete;
183
184 protected:
185 Address address_;
186 NamespacePtr namespace_;
187 Class(NamespacePtr ns, Address va);
188
189 std::vector<Field::Ptr> fields_;
190 std::vector<Method::Ptr> methods_;
191 std::vector<Attribute::Ptr> attributes_;
192 std::vector<Interface::Ptr> interfaces_;
193 std::vector<std::string> strings_;
194};
195
201 public Sawyer::SharedFromThis<Namespace> {
202 public:
205
206 virtual ~Namespace();
207
209 static Ptr instance();
210
211 virtual std::string name() const;
212 virtual void partition(const PartitionerPtr &partitioner, BS::RiscOperatorsPtr &ops,
213 std::map<std::string,Address> &discoveredFunctions) const;
214
215 void append(Class::Ptr ptr);
216
217 const std::vector<ByteCode::Class::Ptr>& classes() const;
218
219 protected:
220 Namespace();
221 std::vector<ByteCode::Class::Ptr> classes_;
222};
223
229 public Sawyer::SharedFromThis<Container> {
230 public:
233
234 virtual ~Container();
235
236 /* A unique (per container) virtual address for system/library functions */
237 static Address nextSystemReservedVa();
238
239 public:
240 virtual std::string name() const = 0;
241 virtual bool isSystemReserved(const std::string &name) const = 0;
242 virtual void partition(const PartitionerPtr &partitioner, BS::RiscOperatorsPtr &ops) const;
243
244 const std::vector<Namespace::Ptr>& namespaces() const;
245
246 protected:
247 Container();
248 std::vector<Namespace::Ptr> namespaces_;
249
250 private:
251 static Address nextSystemReservedVa_;
252};
253
254} // namespace
255} // namespace
256} // namespace
257
258#endif
259#endif
static Ptr instance()
Allocating constructor.
Creates SharedPointer from this.
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
List of SgAsmInstruction nodes.
Base classes for instruction semantics.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
Binary function detection.
Sawyer::SharedPointer< Partitioner > PartitionerPtr
Shared-ownership pointer for Partitioner.
Sawyer::SharedPointer< BasicBlock > BasicBlockPtr
Shared-ownersip pointer for BasicBlock.
std::uint64_t Address
Address.
Definition Address.h:11
The ROSE library.