5#include "../dumper/dumper.h"
6#include "../linker/module.h"
7#include "../linker/options.h"
8#include "../linker/segment.h"
9#include "../linker/segment_manager.h"
10#include "../linker/writer.h"
33 InitializeFields(total_memory, stack_size, heap_size);
45 UnmappedZeroPage = 0x01,
47 NewStyleSymbolTable = 0x04,
48 FormatCombined = 0x10,
49 FormatSeparate = 0x20,
53 format_type format = format_type(0);
64 cpu_type cpu = cpu_type(0);
66 uint8_t header_size = 0x20;
67 uint16_t format_version = 0;
69 ::EndianType endian_type = ::UndefinedEndian;
70 static ::EndianType GetEndianType(cpu_type cpu);
72 ::EndianType GetEndianType()
const;
74 static constexpr size_t PAGE_SIZE = 0x1000;
76 explicit MINIXFormat() =
default;
78 MINIXFormat(format_type format,
int version = -1)
79 : format(format), format_version(version)
83 MINIXFormat(format_type format, cpu_type cpu,
int version = -1)
84 : format(format), cpu(cpu), format_version(version)
88 uint32_t bss_size = 0;
89 uint32_t total_memory = 0;
90 uint16_t heap_size = 0, stack_size = 0;
91 uint32_t code_relocation_base = 0;
92 uint32_t data_relocation_base = 0;
94 bool enable_relocations =
false;
95 bool enable_symbols =
false;
99 static constexpr uint8_t N_SECT = 0x07;
101 static constexpr uint8_t N_UNDF = 0x00;
102 static constexpr uint8_t N_ABS = 0x01;
103 static constexpr uint8_t N_TEXT = 0x02;
104 static constexpr uint8_t N_DATA = 0x03;
105 static constexpr uint8_t N_BSS = 0x04;
106 static constexpr uint8_t N_COMM = 0x05;
108 static constexpr uint8_t N_CLASS = 0xF8;
110 static constexpr uint8_t S_NULL = 0x00;
111 static constexpr uint8_t S_EXT = 0x10;
112 static constexpr uint8_t S_STAT = 0x18;
122 void Dump(
Dumper::Dumper& dump,
unsigned index, offset_t relocations_offset)
const;
124 std::vector<Symbol> symbols;
128 static constexpr uint16_t S_ABS = uint16_t(-1);
129 static constexpr uint16_t S_TEXT = uint16_t(-2);
130 static constexpr uint16_t S_DATA = uint16_t(-3);
131 static constexpr uint16_t S_BSS = uint16_t(-4);
133 static constexpr uint16_t S_FTEXT = uint16_t(-5);
135 static constexpr uint16_t R_ABBS = 0;
136 static constexpr uint16_t R_RELLBYTE = 2;
137 static constexpr uint16_t R_PCRBYTE = 3;
138 static constexpr uint16_t R_RELWORD = 4;
139 static constexpr uint16_t R_PCRWORD = 5;
140 static constexpr uint16_t R_RELLONG = 6;
141 static constexpr uint16_t R_PCRLONG = 7;
142 static constexpr uint16_t R_REL3BYTE = 8;
143 static constexpr uint16_t R_KBRANCHE = 9;
145 static constexpr uint16_t R_SEGWORD = 80;
147 uint32_t address = 0;
150 std::string symbol_name;
153 void FetchSymbolName(std::vector<Symbol>& symbols);
155 void Dump(
Dumper::Dumper& dump,
unsigned index, offset_t relocations_offset)
const;
156 size_t GetSize()
const;
158 std::vector<Relocation> code_relocations, data_relocations, far_code_relocations;
161 std::shared_ptr<Linker::Contents> code, data, far_code;
162 std::shared_ptr<Linker::Segment> bss, heap, stack;
163 uint32_t entry_address = 0;
165 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
168 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
170 void SetOptions(std::map<std::string, std::string>& options)
override;
172 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
174 void CreateDefaultSegments();
176 void SetLinkScript(std::string script_file, std::map<std::string, std::string>& options)
override;
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:773
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
Helper class that contains the options interpreted by the format.
Definition options.h:474
Documents and handles command line options.
Definition options.h:306
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:20
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