5#include "../dumper/dumper.h"
6#include "../linker/module.h"
7#include "../linker/segment.h"
8#include "../linker/segment_manager.h"
9#include "../linker/writer.h"
29 UnmappedZeroPage = 0x01,
31 NewStyleSymbolTable = 0x04,
32 FormatCombined = 0x10,
33 FormatSeparate = 0x20,
37 format_type format = format_type(0);
48 cpu_type cpu = cpu_type(0);
50 uint8_t header_size = 0x20;
51 uint16_t format_version = 0;
53 static ::EndianType GetEndianType(cpu_type cpu);
55 ::EndianType GetEndianType()
const;
57 static constexpr size_t PAGE_SIZE = 0x1000;
62 : format(format), format_version(version)
66 MINIXFormat(format_type format, cpu_type cpu,
int version = -1)
67 : format(format), cpu(cpu), format_version(version)
71 uint32_t bss_size = 0;
72 uint32_t total_memory = 0;
73 uint16_t heap_size = 0, stack_size = 0;
74 uint32_t code_relocation_base = 0;
75 uint32_t data_relocation_base = 0;
77 bool enable_relocations =
false;
78 bool enable_symbols =
false;
82 static constexpr uint8_t N_SECT = 0x07;
84 static constexpr uint8_t N_UNDF = 0x00;
85 static constexpr uint8_t N_ABS = 0x01;
86 static constexpr uint8_t N_TEXT = 0x02;
87 static constexpr uint8_t N_DATA = 0x03;
88 static constexpr uint8_t N_BSS = 0x04;
89 static constexpr uint8_t N_COMM = 0x05;
91 static constexpr uint8_t N_CLASS = 0xF8;
93 static constexpr uint8_t S_NULL = 0x00;
94 static constexpr uint8_t S_EXT = 0x10;
95 static constexpr uint8_t S_STAT = 0x18;
105 void Dump(
Dumper::Dumper& dump,
unsigned index, offset_t relocations_offset)
const;
107 std::vector<Symbol> symbols;
111 static constexpr uint16_t S_ABS = uint16_t(-1);
112 static constexpr uint16_t S_TEXT = uint16_t(-2);
113 static constexpr uint16_t S_DATA = uint16_t(-3);
114 static constexpr uint16_t S_BSS = uint16_t(-4);
116 static constexpr uint16_t S_FTEXT = uint16_t(-5);
118 static constexpr uint16_t R_ABBS = 0;
119 static constexpr uint16_t R_RELLBYTE = 2;
120 static constexpr uint16_t R_PCRBYTE = 3;
121 static constexpr uint16_t R_RELWORD = 4;
122 static constexpr uint16_t R_PCRWORD = 5;
123 static constexpr uint16_t R_RELLONG = 6;
124 static constexpr uint16_t R_PCRLONG = 7;
125 static constexpr uint16_t R_REL3BYTE = 8;
126 static constexpr uint16_t R_KBRANCHE = 9;
128 static constexpr uint16_t R_SEGWORD = 80;
130 uint32_t address = 0;
133 std::string symbol_name;
136 void FetchSymbolName(std::vector<Symbol>& symbols);
138 void Dump(
Dumper::Dumper& dump,
unsigned index, offset_t relocations_offset)
const;
139 size_t GetSize()
const;
141 std::vector<Relocation> code_relocations, data_relocations, far_code_relocations;
144 std::shared_ptr<Linker::Image> code, data, far_code;
145 std::shared_ptr<Linker::Segment> bss, heap, stack;
146 uint32_t entry_address = 0;
148 void SetOptions(std::map<std::string, std::string>& options)
override;
150 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
152 void CreateDefaultSegments();
154 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
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