RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
pmode.h
1#ifndef PMODE_H
2#define PMODE_H
3
4#include "../common.h"
5#include "../linker/reader.h"
6#include "../linker/segment_manager.h"
7#include "../linker/writer.h"
8
9/* TODO: unimplemented */
10
11namespace PMODE
12{
16 class PMW1Format : public virtual Linker::SegmentManager
17 {
18 public:
19 /* * * General members * * */
20 offset_t file_offset = 0;
22 {
23 uint8_t major;
24 uint8_t minor;
25 };
26 version_type version = { };
27 static constexpr uint16_t FLAG_COMPRESSED = 0x0001;
28 uint16_t flags = 0;
29 uint32_t eip_object = 0;
30 uint32_t eip = 0;
31 uint32_t esp_object = 0;
32 uint32_t esp = 0;
33 uint32_t object_table_offset = 0;
34 uint32_t relocation_table_offset = 0;
35 uint32_t data_offset = 0;
36
37 class Object
38 {
39 public:
41 {
42 public:
43 uint8_t type = 0;
44 uint32_t source = 0;
45 uint8_t target_object = 0;
46 uint32_t target_offset = 0;
47 };
48
49 uint32_t memory_size = 0;
50 uint32_t file_size = 0; // compressed
51 uint32_t flags = 0;
52 uint32_t relocation_offset = 0;
53 uint32_t relocation_count = 0; // only needed during reading
54 uint32_t image_size = 0; // without compression
55 std::shared_ptr<Linker::Image> image;
56 std::vector<Relocation> relocations;
57 };
58 std::vector<Object> objects;
59
60 void ReadFile(Linker::Reader& rd) override;
62 offset_t WriteFile(Linker::Writer& wr) const override;
63
64 void Dump(Dumper::Dumper& dump) const override;
65
66 void CalculateValues() override;
67
68 /* * * Reader members * * */
69
70 /* * * Writer members * * */
72 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
73 };
74}
75
76#endif /* PMODE_H */
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
offset_t WriteFile(Writer &wr) const override=0
Stores data in memory to file.
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
virtual std::string GetDefaultExtension(Module &module, std::string filename) const
Appends a default extension to the filename.
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A helper class to collect sections into segments.
Definition segment_manager.h:32
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15
Definition pmode.h:38
PMODE/W linear executable format (https://github.com/amindlost/pmodew/blob/main/docs/pmw1fmt....
Definition pmode.h:17
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition pmode.cc:112
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition pmode.cc:63
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition pmode.cc:174
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition pmode.cc:169
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition pmode.cc:11
Definition pmode.h:22