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 static ::EndianType GetEndianType(cpu_type cpu);
71 ::EndianType GetEndianType()
const;
73 static constexpr size_t PAGE_SIZE = 0x1000;
75 explicit MINIXFormat() =
default;
77 MINIXFormat(format_type format,
int version = -1)
78 : format(format), format_version(version)
82 MINIXFormat(format_type format, cpu_type cpu,
int version = -1)
83 : format(format), cpu(cpu), format_version(version)
87 uint32_t bss_size = 0;
88 uint32_t total_memory = 0;
89 uint16_t heap_size = 0, stack_size = 0;
90 uint32_t code_relocation_base = 0;
91 uint32_t data_relocation_base = 0;
93 bool enable_relocations =
false;
94 bool enable_symbols =
false;
98 static constexpr uint8_t N_SECT = 0x07;
100 static constexpr uint8_t N_UNDF = 0x00;
101 static constexpr uint8_t N_ABS = 0x01;
102 static constexpr uint8_t N_TEXT = 0x02;
103 static constexpr uint8_t N_DATA = 0x03;
104 static constexpr uint8_t N_BSS = 0x04;
105 static constexpr uint8_t N_COMM = 0x05;
107 static constexpr uint8_t N_CLASS = 0xF8;
109 static constexpr uint8_t S_NULL = 0x00;
110 static constexpr uint8_t S_EXT = 0x10;
111 static constexpr uint8_t S_STAT = 0x18;
121 void Dump(
Dumper::Dumper& dump,
unsigned index, offset_t relocations_offset)
const;
123 std::vector<Symbol> symbols;
127 static constexpr uint16_t S_ABS = uint16_t(-1);
128 static constexpr uint16_t S_TEXT = uint16_t(-2);
129 static constexpr uint16_t S_DATA = uint16_t(-3);
130 static constexpr uint16_t S_BSS = uint16_t(-4);
132 static constexpr uint16_t S_FTEXT = uint16_t(-5);
134 static constexpr uint16_t R_ABBS = 0;
135 static constexpr uint16_t R_RELLBYTE = 2;
136 static constexpr uint16_t R_PCRBYTE = 3;
137 static constexpr uint16_t R_RELWORD = 4;
138 static constexpr uint16_t R_PCRWORD = 5;
139 static constexpr uint16_t R_RELLONG = 6;
140 static constexpr uint16_t R_PCRLONG = 7;
141 static constexpr uint16_t R_REL3BYTE = 8;
142 static constexpr uint16_t R_KBRANCHE = 9;
144 static constexpr uint16_t R_SEGWORD = 80;
146 uint32_t address = 0;
149 std::string symbol_name;
152 void FetchSymbolName(std::vector<Symbol>& symbols);
154 void Dump(
Dumper::Dumper& dump,
unsigned index, offset_t relocations_offset)
const;
155 size_t GetSize()
const;
157 std::vector<Relocation> code_relocations, data_relocations, far_code_relocations;
160 std::shared_ptr<Linker::Image> code, data, far_code;
161 std::shared_ptr<Linker::Segment> bss, heap, stack;
162 uint32_t entry_address = 0;
164 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
167 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
169 void SetOptions(std::map<std::string, std::string>& options)
override;
171 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
173 void CreateDefaultSegments();
175 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:586
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:308
Documents and handles command line options.
Definition options.h:196
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