RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
epoc.h
1#ifndef EPOC_H
2#define EPOC_H
3
4#include <array>
5#include "../linker/format.h"
6
7namespace EPOC
8{
10 {
11 public:
12 /* * * General members * * */
13 enum executable_type
14 {
15 KDirectFileStoreLayoutUid = 0x10000037,
16 KPermanentFileStoreLayoutUid = 0x10000050,
17 KDynamicLibraryUid = 0x10000079,
18 KExecutableImageUid = 0x1000007A,
19 };
20 executable_type uid1 = executable_type(0);
21
22 enum application_type
23 {
24 /* for KDirectFileStoreLayoutUid or KPermanentFileStoreLayoutUid */
25 _OPLObjectModule = 0x10000073,
26 _OPLApplication = 0x10000074,
27 KUidAppDllDoc = 0x10003A12,
28 KUidAppInfoFile = 0x10003A38,
29 /* for KDynamicLibraryUid */
30 _OPLExtensions = 0x1000005D,
31 _Application = 0x1000006C,
32 KSharedLibraryUid = 0x1000008D,
33 KLogicalDeviceDriverUid8 = 0x100000AE,
34 KLogicalDeviceDriverUid16 = 0x100000AF,
35 KUidApp = 0x100039CE,
36 KPhysicalDeviceDriverUid16 = 0x100039D0,
37 KPhysicalDeviceDriverUid8 = 0x100000AD,
38 /* ? */
39 KMachineConfigurationUid = 0x100000F4,
40 KLocaleDllUid16 = 0x100039E6,
41 KLocaleDllUid8 = 0x100000C3,
42 KKeyboardUid = 0x100000DB,
43 KEka1EntryStubUid = 0x101FDF0F,
44 KKeyboardDataUid16 = 0x100039E0,
45 KKeyboardDataUid8 = 0x100000DC,
46 KKeyboardTranUid16 = 0x100039E1,
47 KKeyboardTranUid8 = 0x100000DD,
48 KConsoleDllUid16 = 0x100039E7,
49 KConsoleDllUid8 = 0x100000C5,
50 KSystemStartupModeKey = 0x10204BB5,
51 KSystemEmulatorOrientationKey = 0x10204BB6,
52 KServerProcessUid = 0x1000008C,
53 KFileSystemUid = 0x1000008F,
54 KFileServerUid = 0x100000BB,
55 KLocalFileSystemUid = 0x100000D6,
56 KFileServerDllUid = 0x100000BD,
57 };
58 application_type uid2 = application_type(0);
59
60 uint32_t uid3 = 0;
61 uint32_t uid_checksum = 0;
62
63 bool new_format = true;
64
65 enum cpu_type
66 {
67 ECpuUnknown = 0,
68 ECpuX86 = 0x1000,
69 ECpuArmV4 = 0x2000,
70 ECpuArmV5 = 0x2001,
71 ECpuArmV6 = 0x2002,
72 ECpuMCore = 0x4000,
73 };
74 cpu_type cpu = ECpuUnknown;
75
76 uint32_t header_crc = 0;
77 union
78 {
79 uint32_t code_checksum;
80 uint32_t module_version;
81 };
82 union
83 {
84 uint32_t data_checksum;
85 uint32_t compression_type;
86 };
87
88 uint32_t tool_version;
89 uint64_t timestamp;
90 enum flags_type
91 {
92 };
93 flags_type flags = flags_type(0);
94 uint32_t heap_size_min = 0;
95 uint32_t heap_size_max = 0;
96 uint32_t stack_size = 0;
97 uint32_t bss_size = 0;
98 uint32_t entry_point = 0;
99 uint32_t code_address = 0;
100 uint32_t data_address = 0;
101 uint32_t export_table_offset = 0;
102 uint32_t import_table_offset = 0;
103 uint32_t code_offset = 0;
104 uint32_t data_offset = 0;
105 uint32_t import_offset = 0;
106 uint32_t code_relocation_offset = 0;
107 uint32_t data_relocation_offset = 0;
108 uint32_t process_priority = 0;
109
110 // new header
111 uint32_t uncompressed_size = 0;
112 uint32_t secure_id = 0;
113 uint32_t vendor_id = 0;
114 enum capability_type
115 {
116 // TODO
117 };
118 std::array<capability_type, 2> capabilities;
119 uint32_t exception_descriptor = 0;
120 uint8_t export_description_type = 0;
121 std::vector<uint8_t> export_description;
122
123 std::shared_ptr<Linker::Image> code, data;
124
126 {
127 uint32_t name_offset = 0;
128 std::vector<uint32_t> imports;
129 };
130
131 std::vector<ImportBlock> dll_reference_table;
132 uint32_t dll_reference_table_size = 0;
133
135 {
136 uint16_t offset = 0;
137 enum relocation_type
138 {
139 FromCode = 1,
140 FromData = 2,
141 FromEither = 3,
142 };
143 relocation_type type = relocation_type(0);
144 };
145
147 {
148 uint32_t page_offset = 0;
149 std::vector<Relocation> relocations;
150 };
151
153 {
154 std::vector<RelocationBlock> blocks;
155 uint32_t GetSize() const;
156 uint32_t GetCount() const;
157 void ReadFile(Linker::Reader& rd);
158 };
159 RelocationSection code_relocations, data_relocations;
160
162 : code_checksum(0), data_checksum(0)
163 {
164 }
165
166 void ReadFile(Linker::Reader& rd) override;
167
168 offset_t ImageSize() const override;
169
171 offset_t WriteFile(Linker::Writer& wr) const override;
172
173 void Dump(Dumper::Dumper& dump) const override;
174 };
175}
176
177#endif /* EPOC_H */
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
Definition epoc.h:10
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition epoc.cc:55
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition epoc.cc:190
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition epoc.cc:166
offset_t ImageSize() const override
Retrieves size of stored data.
Definition epoc.cc:160
A class to encode a general file format.
Definition format.h:27
offset_t WriteFile(Writer &wr) const override=0
Stores data in memory to file.
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15
Definition epoc.h:135