-
Notifications
You must be signed in to change notification settings - Fork 3
/
Loader.hpp
49 lines (37 loc) · 1.09 KB
/
Loader.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef SoftWire_Loader_hpp
#define SoftWire_Loader_hpp
#include "Link.hpp"
namespace SoftWire
{
class Linker;
class Encoding;
class Loader
{
public:
Loader(const Linker &linker, bool x64);
virtual ~Loader();
void (*callable(const char *entryLabel = 0))();
void (*finalize(const char *entryLabel = 0))();
void *acquire();
Encoding *appendEncoding(const Encoding &encoding);
const char *getListing();
void clearListing();
void reset();
int instructionCount();
private:
const Linker &linker;
typedef Link<Encoding> Instruction;
Instruction *instructions;
unsigned char *machineCode;
char *listing;
const bool x64; // Long mode
bool possession;
bool finalized;
void loadCode(const char *entryLabel = 0);
const unsigned char *resolveReference(const char *name, const Instruction *position) const;
const unsigned char *resolveLocal(const char *name, const Instruction *position) const;
const unsigned char *resolveExternal(const char *name) const;
int codeLength() const;
};
}
#endif // SoftWire_Loader_hpp