-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.h
88 lines (76 loc) · 1.85 KB
/
entrypoint.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef _ENTRYPOINT_
#define _ENTRYPOINT_
/*
Equivalent to crtn in gcc-land I suppose? Does the necessary setup and teardown
before and after entering Enki's outer function, e.g. explicitly calling the exit
syscall.
*/
#include "component.h"
// Platform-specific stuff equivalent to the stuff before and
// after calling main() in C
class BasicBlock;
class FunctionScope;
class Image;
class Entrypoint : public Component
{
public:
virtual std::string name() = 0;
virtual void generatePrologue(BasicBlock *, FunctionScope *, Image *)
{
}
virtual void generateEpilogue(BasicBlock *, FunctionScope *, Image *)
{
}
};
class InannaEntrypoint : public Entrypoint
{
public:
virtual std::string name()
{
return "inannaentrypoint";
}
};
class WindowsEntrypoint : public Entrypoint
{
public:
virtual std::string name()
{
return "windowsentrypoint";
}
virtual void generateEpilogue(BasicBlock *, FunctionScope *, Image *) override;
};
// Ends with an exit() syscall as appropriate for the platform
class UnixEntrypoint : public Entrypoint
{
public:
UnixEntrypoint()
{
syscall_number = -1;
exitcode_reg = -1;
}
virtual bool configure(std::string, std::string) override;
virtual std::string name()
{
return "unixentrypoint";
}
virtual void generateEpilogue(BasicBlock *, FunctionScope *, Image *) override;
protected:
int syscall_number;
int syscall_reg;
int exitcode_reg;
};
// Add branch-to-thumb at start
class ThumbEntrypoint : public UnixEntrypoint
{
public:
public:
ThumbEntrypoint()
{
jump_to_thumb = false;
}
virtual bool configure(std::string, std::string) override;
virtual void generatePrologue(BasicBlock *, FunctionScope *, Image *) override;
protected:
bool jump_to_thumb;
};
#endif