ROSE 2.15.0
Loading...
Searching...
No Matches
Rose/BinaryAnalysis/ByteCode/Jvm.h
1#ifndef ROSE_BinaryAnalysis_ByteCode_Jvm_H
2#define ROSE_BinaryAnalysis_ByteCode_Jvm_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
7#include <Rose/BinaryAnalysis/ByteCode/Analysis.h>
8
10class SgAsmJvmField;
12class SgAsmJvmMethod;
14
15namespace Rose {
16namespace BinaryAnalysis {
17namespace ByteCode {
18
19
24class Code {
25 public:
26 void bytes(const uint8_t *bytes);
27 const uint8_t* bytes() const;
28
29 void size(size_t size);
30 size_t size() const;
31
32 void offset(Address offset);
33 Address offset() const;
34
35 private:
36 const uint8_t *bytes_ = nullptr; // non-owning pointer to bytes
37 size_t size_ = 0;
38 Address offset_ = 0;
39};
40
41
42class JvmField final : public Field {
43 public:
46
49
50 public:
51 std::string name() const override;
52
53 JvmField() = delete;
55
56 private:
58 SgAsmJvmField* sgField_;
59};
60
61class JvmMethod final : public Method {
62 public:
65
67 static Ptr instance(std::string name, Address va, SgAsmJvmFileHeader* jfh, SgAsmJvmMethod* method);
68
69 static JvmMethod::Ptr promote(const Sawyer::SharedPointer<Method>& from);
70
71 bool isStatic() const override;
72 bool isSystemReserved(const std::string &name) const override;
73
74 const SgAsmInstructionList* instructions() const override;
75 void decode(const Disassembler::BasePtr &disassembler) const override;
76
77 void annotate() override;
78
79 std::string descriptor() const override;
80
81 SgAsmJvmConstantPool* constant_pool();
82
83 JvmMethod() = delete;
84 JvmMethod(std::string name, Address va, SgAsmJvmFileHeader* jfh, SgAsmJvmMethod* m);
85
86 private:
87 SgAsmJvmFileHeader* jfh_ = nullptr;
88 SgAsmJvmMethod* sgMethod_ = nullptr;
89 Code code_; // contains raw bytes from the JVM class file for disassembly and partitioning
90};
91
92class JvmInterface final : public Interface {
93 public:
96
98 static Ptr instance(SgAsmJvmFileHeader* jfh, uint16_t index);
99
100 std::string name() const override;
101 uint16_t index() const;
102
103 JvmInterface() = delete;
104 JvmInterface(SgAsmJvmFileHeader* jfh, uint16_t index);
105
106 private:
107 SgAsmJvmFileHeader* jfh_;
108 uint16_t index_;
109};
110
111class JvmAttribute final : public Attribute {
112 public:
115
117 static Ptr instance(SgAsmJvmFileHeader* jfh, uint16_t index);
118
119 std::string name() const override;
120 uint16_t index() const;
121
122 JvmAttribute() = delete;
123 JvmAttribute(SgAsmJvmFileHeader* jfh, uint16_t index);
124
125 private:
126 SgAsmJvmFileHeader* jfh_;
127 uint16_t index_;
128};
129
130class JvmClass final : public Class {
131 public:
134
136 static Ptr instance(std::string name, NamespacePtr ns, SgAsmJvmFileHeader* jfh);
137
138 static JvmClass::Ptr promote(const Sawyer::SharedPointer<Class>& from);
139
140 std::string typeSeparator() const override;
141 void dump() override;
142
143 const std::vector<std::string>& strings() override;
144 SgAsmJvmConstantPool* constant_pool();
145
146 JvmClass() = delete;
147 JvmClass(std::string name, NamespacePtr ns, SgAsmJvmFileHeader* jfh);
148
149 private:
150 SgAsmJvmFileHeader* jfh_;
151};
152
153class JvmContainer final : public Container {
154 public:
155 std::string name() const override;
156 bool isSystemReserved(const std::string &name) const override;
157 static bool isJvmSystemReserved(const std::string &name);
158};
159
161std::string constantPoolEntryName(uint16_t index, const SgAsmJvmConstantPool *pool);
162
163} // namespace
164} // namespace
165} // namespace
166
167#endif
168#endif
static Ptr instance(SgAsmJvmFileHeader *jfh, uint16_t index)
Allocating constructor.
static Ptr instance(std::string name, NamespacePtr ns, SgAsmJvmFileHeader *jfh)
Allocating constructor.
static Ptr instance(SgAsmJvmFileHeader *jfh, SgAsmJvmField *fld)
Allocating constructor.
static Ptr instance(SgAsmJvmFileHeader *jfh, uint16_t index)
Allocating constructor.
static Ptr instance(std::string name, Address va, SgAsmJvmFileHeader *jfh, SgAsmJvmMethod *method)
Allocating constructor.
Reference-counting intrusive smart pointer.
List of SgAsmInstruction nodes.
Represents an JVM constant pool.
Represents the file header of an JVM binary container.
std::uint64_t Address
Address.
Definition Address.h:11
The ROSE library.