5#include "../dumper/dumper.h"
6#include "../linker/options.h"
7#include "../linker/segment_manager.h"
25 InitializeFields(stub);
37 unsigned FormatAdditionalSectionFlags(std::string section_name)
const override;
52 FLAG_TRANSPARENT = 0x8000,
57 uint32_t total_length;
60 AbstractSegment(
unsigned access = TYPE_DATA,
unsigned flags = 0, uint32_t total_length = 0)
61 : access(access_type(access)), flags(flag_type(flags)), total_length(total_length)
101 virtual void Dump(
Dumper::Dumper& dump,
const BWFormat& bw, offset_t file_offset, uint16_t selector_offset)
const = 0;
107 std::shared_ptr<Linker::Image> image;
114 Segment(std::shared_ptr<Linker::Segment> segment,
unsigned access = TYPE_DATA,
unsigned flags = 0)
127 void Dump(
Dumper::Dumper& dump,
const BWFormat& bw, offset_t file_offset, uint16_t selector_offset)
const override;
133 DummySegment(uint32_t total_length,
unsigned access = TYPE_DATA,
unsigned flags = 0)
146 void Dump(
Dumper::Dumper& dump,
const BWFormat& bw, offset_t file_offset, uint16_t selector_offset)
const override;
170 void Dump(
Dumper::Dumper& dump,
const BWFormat& bw, offset_t file_offset, uint16_t selector_offset)
const override;
183 bool option_force_relocations =
true;
187 EXP_FLAG_RELOCATABLE = 0x0001,
189 exp_flag_type exp_flags = exp_flag_type(0);
193 OPTION_RELOCATIONS = 0x1000,
195 option_type options = option_type(0);
200 uint16_t selector = 0;
202 std::vector<uint16_t> offsets;
205 std::vector<Relocation> relocations_list;
206 std::map<uint16_t, std::set<uint16_t>> relocations_map;
207 uint16_t last_relocation_selector = 0;
208 uint16_t remaining_relocation_offsets = 0;
209 bool must_read_relocation_count =
false;
211 offset_t MeasureRelocations()
const;
213 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
215 void SetOptions(std::map<std::string, std::string>& options)
override;
217 offset_t file_size = 0;
218 offset_t min_extra = 0;
219 offset_t max_extra = 0;
220 uint16_t ss = 0, sp = 0, cs = 0, ip = 0, relocsel = 0;
221 uint16_t runtime_gdt_length = 0xFFFF;
222 uint16_t version = 0;
223 uint32_t next_header_offset = 0;
224 uint32_t debug_info_offset = 0;
225 uint16_t last_used_selector = 0;
226 uint16_t first_selector = 0x0080;
227 uint32_t private_xm = 0;
228 uint16_t ext_reserve = 0;
229 uint16_t transparent_stack = 0;
230 uint32_t program_size = 0;
231 uint16_t gdt_size = 0;
232 uint8_t default_memory_strategy = 0;
233 uint16_t transfer_buffer_size = 0;
234 std::string exp_name;
238 std::vector<std::unique_ptr<AbstractSegment>> segments;
239 std::map<std::shared_ptr<Linker::Segment>,
size_t> segment_indices;
240 int default_data = 0;
242 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
248 size_t GetDefaultDataIndex();
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