RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
minix.h
1#ifndef MINIX_H
2#define MINIX_H
3
4#include "../common.h"
5#include "../linker/linker.h"
6#include "../linker/module.h"
7#include "../linker/segment.h"
8#include "../linker/writer.h"
9
10namespace MINIX
11{
18 {
19 public:
20 /* TODO: incorporate relocations and far code segment from around ELKS 0.8.0 */
21
22 void ReadFile(Linker::Reader& rd) override;
23
24 bool FormatIs16bit() const override;
25
26 enum format_type
27 {
28 FormatCombined = 0x10,
29 FormatSeparate = 0x20,
30 UnmappedZeroPage = 0x01,
31 };
32 format_type format;
33
34 enum cpu_type
35 {
36 /* TODO: extend for 68K? */
37 I86 = 0x04,
38 M68K = 0x0B,
39 NS16K = 0x0C,
40 I386 = 0x10,
41 SPARC = 0x17,
42 };
43 cpu_type cpu;
44
45 static ::EndianType GetEndianType(cpu_type cpu);
46
47 ::EndianType GetEndianType() const;
48
49 static constexpr size_t PAGE_SIZE = 0x1000;
50
51 MINIXFormat(format_type format, cpu_type cpu = cpu_type(0))
52 : format(format), cpu(cpu)
53 {
54 }
55
56 uint32_t code_base_address = 0; /* TODO: parametrize */
57 //uint32_t data_base_address = 0; /* TODO: parametrize */
58 uint32_t heap_top_address = 0; /* TODO: parametrize */
59
60 /* generated */
61 std::shared_ptr<Linker::Segment> code, data, bss;
62 uint32_t entry_address = 0;
63
64 using LinkerManager::SetLinkScript;
65
66 void SetOptions(std::map<std::string, std::string>& options) override;
67
68 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
69
70 void CreateDefaultSegments();
71
72 std::unique_ptr<Script::List> GetScript(Linker::Module& module);
73
74 void Link(Linker::Module& module);
75
76 void ProcessModule(Linker::Module& module) override;
77
78 void CalculateValues() override;
79
80 void WriteFile(Linker::Writer& wr) override;
81
82 void GenerateFile(std::string filename, Linker::Module& module) override;
83
84 std::string GetDefaultExtension(Linker::Module& module) override;
85 };
86
87}
88
89#endif /* MINIX_H */
A helper class to collect sections into segments.
Definition linker.h:19
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:20
A class that provides a general interface to setting up generation for a format.
Definition format.h:56
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
MINIX/ELKS a.out file format.
Definition minix.h:18
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition minix.cc:39
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition minix.cc:6
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition minix.cc:164
bool FormatIs16bit() const override
Whether the format is 16-bit or not.
Definition minix.cc:11
void WriteFile(Linker::Writer &wr) override
Stores data in memory to file.
Definition minix.cc:243
void OnNewSegment(std::shared_ptr< Linker::Segment > segment) override
Callback function when allocating a new segment When the linker script runs, it creates segments cons...
Definition minix.cc:44
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition minix.cc:226
std::string GetDefaultExtension(Linker::Module &module) override
Provides a default filename for the output file.
Definition minix.cc:278
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition minix.cc:261