5#include "../dumper/dumper.h"
6#include "../linker/options.h"
7#include "../linker/segment_manager.h"
26 InitializeFields(stub, stack);
32 unsigned FormatAdditionalSectionFlags(std::string section_name)
const override;
36 std::shared_ptr<Linker::Contents> image;
38 static const uint32_t REL32 = 0x80000000;
43 uint32_t offset : 31, rel32 : 1;
48 : offset(offset), rel32(rel32)
57 bool operator ==(
const Relocation& other)
const;
59 bool operator <(
const Relocation& other)
const;
62 offset_t image_size = 0;
63 std::vector<Relocation> relocations;
64 offset_t header_size = 0;
65 offset_t min_extra_pages = 0;
66 offset_t max_extra_pages = 0;
69 uint16_t checksum = 0;
70 offset_t relocation_offset = 0;
71 uint16_t relocation_count = 0;
76 MPFormat(
bool has_relocations =
false)
77 : has_relocations(has_relocations)
81 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
83 void SetOptions(std::map<std::string, std::string>& options)
override;
85 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
117 InitializeFields(stub, stack);
130 bool FormatSupportsStackSection()
const override;
133 bool is_multisegmented;
136 uint16_t header_size = 0;
137 uint32_t file_size = 0;
138 uint16_t checksum16 = 0;
139 uint32_t checksum32 = 0;
141 uint32_t runtime_parameters_offset = 0;
142 uint32_t runtime_parameters_size = 0;
143 uint32_t relocation_table_offset = 0;
144 uint32_t relocation_table_size = 0;
145 uint32_t segment_information_table_offset = 0;
146 uint32_t segment_information_table_size = 0;
147 uint16_t segment_information_table_entry_size = 0;
148 uint32_t load_image_offset = 0;
149 uint32_t load_image_size = 0;
150 uint32_t symbol_table_offset = 0;
151 uint32_t symbol_table_size = 0;
152 uint32_t gdt_address = 0;
153 uint32_t gdt_size = 0;
154 uint32_t ldt_address = 0;
155 uint32_t ldt_size = 0;
156 uint32_t idt_address = 0;
157 uint32_t idt_size = 0;
158 uint32_t tss_address = 0;
159 uint32_t tss_size = 0;
160 uint32_t minimum_extra = 0;
161 uint32_t maximum_extra = 0;
162 uint32_t base_load_offset = 0;
170 uint32_t memory_requirements = 0;
171 uint32_t stack_size = 0;
175 P3Format(
bool is_multisegmented =
true,
bool is_32bit =
true)
176 : is_multisegmented(is_multisegmented), is_32bit(is_32bit)
188 uint32_t address = 0;
190 virtual uint32_t GetStoredSize()
const = 0;
191 virtual uint32_t GetLoadedSize()
const = 0;
200 std::weak_ptr<AbstractSegment>
image = std::weak_ptr<AbstractSegment>();
223 uint16_t selector = 0;
227 static Descriptor FromSegment(uint32_t access, std::weak_ptr<AbstractSegment>
image = std::weak_ptr<AbstractSegment>());
230 bool IsSegment()
const;
233 void CalculateValues();
244 std::vector<Descriptor> descriptors;
246 uint32_t GetStoredSize()
const override;
248 uint32_t GetLoadedSize()
const override;
252 void CalculateValues();
261 uint32_t esp0 = 0, esp1 = 0, esp2 = 0;
262 uint32_t cr3 = 0, eip = 0, eflags = 0, eax = 0, ecx = 0, edx = 0, ebx = 0, esp = 0, ebp = 0, esi = 0, edi = 0;
263 uint16_t ss0 = 0, ss1 = 0, ss2 = 0, es = 0, cs = 0, ss = 0, ds = 0, fs = 0, gs = 0, ldtr = 0, iopb = 0;
271 uint32_t GetStoredSize()
const override;
273 uint32_t GetLoadedSize()
const override;
284 uint16_t selector = 0;
286 uint32_t base_offset = 0;
287 uint32_t zero_fill = 0;
294 uint32_t GetStoredSize()
const override;
296 virtual uint32_t GetZeroSize()
const;
298 uint32_t GetLoadedSize()
const override;
304 static std::shared_ptr<SITEntry> ReadSITEntry(
Linker::Reader& rd);
316 std::shared_ptr<Linker::Segment> segment;
320 Segment(std::shared_ptr<Linker::Segment> segment, uint32_t access, uint16_t selector)
321 :
SITEntry(selector), segment(segment), access(access)
325 uint32_t GetStoredSize()
const override;
327 uint32_t GetZeroSize()
const override;
339 Relocation(uint16_t selector, uint32_t offset)
340 : selector(selector), offset(offset)
344 bool operator ==(
const Relocation& other)
const;
346 bool operator <(
const Relocation& other)
const;
354 uint16_t min_realmode_param = 0, max_realmode_param = 0, min_int_buffer_size_kb = 0, max_int_buffer_size_kb = 0, int_stack_count = 0, int_stack_size_kb = 0;
355 uint32_t realmode_area_end = 0;
356 uint16_t call_buffer_size_kb = 0, flags = 0, ring = 0;
360 void CalculateValues();
366 std::vector<std::shared_ptr<AbstractSegment>> segments;
369 std::vector<Relocation> relocations;
374 std::shared_ptr<Linker::Image> image;
377 std::shared_ptr<DescriptorTable> gdt = std::make_shared<DescriptorTable>();
379 std::shared_ptr<DescriptorTable> idt = std::make_shared<DescriptorTable>();
381 std::shared_ptr<DescriptorTable> ldt = std::make_shared<DescriptorTable>();
383 std::shared_ptr<TaskStateSegment> tss = std::make_shared<TaskStateSegment>();
385 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
387 void SetOptions(std::map<std::string, std::string>& options)
override;
406 Flat(
bool is_32bit =
true)
411 std::shared_ptr<Linker::Segment> GetSegment();
412 std::shared_ptr<const Linker::Segment> GetSegment()
const;
414 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
437 std::map<std::shared_ptr<Linker::Segment>, uint16_t> segment_associations;
438 std::shared_ptr<Segment> code;
439 std::shared_ptr<Segment> data;
441 void OnNewSegment(std::shared_ptr<Linker::Segment> linker_segment)
override;
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:773
A brief record, such as a relocation or imported library.
Definition dumper.h:687
A record that represents a region within the file.
Definition dumper.h:666
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
Corresponds to an entry in the Segment Information Table.
Definition pharlap.h:282