8#include "../linker/module.h"
9#include "../linker/segment.h"
10#include "../linker/segment_manager.h"
11#include "../linker/writer.h"
241 static const std::map<uint32_t, MachineType> MACHINE_TYPES;
260 virtual offset_t GetAddress()
const = 0;
261 virtual size_t GetSize()
const = 0;
262 virtual size_t GetEntrySize()
const = 0;
274 static constexpr uint16_t
R_ABS = 0;
296 COFFVariantType coff_variant;
299 offset_t address = 0;
300 uint32_t symbol_index = 0;
302 uint32_t information = 0;
305 : coff_variant(coff_variant), cpu_type(cpu_type)
311 offset_t GetAddress()
const override;
313 size_t GetSize()
const override;
315 size_t GetEntrySize()
const override;
332 static constexpr uint16_t R_Z80_IMM8 = 0x22;
333 static constexpr uint16_t R_Z80_IMM16 = 0x01;
334 static constexpr uint16_t R_Z80_IMM24 = 0x33;
335 static constexpr uint16_t R_Z80_IMM32 = 0x17;
336 static constexpr uint16_t R_Z80_OFF8 = 0x32;
337 static constexpr uint16_t R_Z80_JR = 0x02;
339 static constexpr uint16_t R_Z8K_IMM4L = 0x23;
340 static constexpr uint16_t R_Z8K_IMM4H = 0x24;
341 static constexpr uint16_t R_Z8K_DISP7 = 0x25;
342 static constexpr uint16_t R_Z8K_IMM8 = 0x22;
343 static constexpr uint16_t R_Z8K_IMM16 = 0x01;
344 static constexpr uint16_t R_Z8K_REL16 = 0x04;
345 static constexpr uint16_t R_Z8K_IMM32 = 0x11;
346 static constexpr uint16_t R_Z8K_JR = 0x02;
347 static constexpr uint16_t R_Z8K_CALLR = 0x05;
349 static constexpr uint16_t R_W65_ABS8 = 0x01;
350 static constexpr uint16_t R_W65_ABS16 = 0x02;
351 static constexpr uint16_t R_W65_ABS24 = 0x03;
352 static constexpr uint16_t R_W65_ABS8S8 = 0x04;
353 static constexpr uint16_t R_W65_ABS8S16 = 0x05;
354 static constexpr uint16_t R_W65_ABS16S8 = 0x06;
355 static constexpr uint16_t R_W65_ABS16S16 = 0x07;
356 static constexpr uint16_t R_W65_PCR8 = 0x08;
357 static constexpr uint16_t R_W65_PCR16 = 0x09;
358 static constexpr uint16_t R_W65_DP = 0x0A;
390 offset_t GetAddress()
const override;
392 size_t GetSize()
const override;
394 size_t GetEntrySize()
const override;
440 bool IsExternal()
const;
495 std::shared_ptr<Linker::Image>
image;
525 void ReadSectionHeader(
Linker::Reader& rd, COFFVariantType coff_variant);
527 void WriteSectionHeader(
Linker::Writer& wr, COFFVariantType coff_variant);
529 uint32_t ImageSize()
const;
613 std::unique_ptr<Linker::Buffer> buffer =
nullptr;
616 : buffer(std::make_unique<Linker::Buffer>(size))
620 uint32_t
GetSize()
const override;
676 uint32_t
GetSize()
const override;
709 uint32_t
GetSize()
const override;
734 uint32_t code_size = 0;
735 uint32_t data_size = 0;
736 uint32_t bss_size = 0;
737 uint32_t symbol_table_size = 0;
738 uint32_t entry_address = 0;
739 uint32_t code_relocation_size = 0;
740 uint32_t data_relocation_size = 0;
742 uint32_t
GetSize()
const override;
763 uint32_t bss_address;
767 uint32_t cpr_mask[4];
776 uint32_t
GetSize()
const override;
796 static constexpr uint16_t OMAGIC = 0x0107;
797 static constexpr uint16_t NMAGIC = 0x0108;
798 static constexpr uint16_t ZMAGIC = 0x010B;
803 static constexpr uint16_t SYM_STAMP = 0x030D;
853 uint32_t
GetSize()
const override;
998 uint8_t shared_memory_page = 0;
1006 uint32_t
GetSize()
const override;
1017 void Clear()
override;
1019 void AssignMagicValue();
1021 COFFVariantType coff_variant = COFFVariantType(0);
1035 bool DetectCpuType(::EndianType expected);
1037 void DetectCpuType();
1060 void SetupOptions(std::shared_ptr<Linker::OutputFormat> format)
override;
1062 bool option_segmentation =
false;
1068 std::string segment_prefix();
1070 std::string segment_of_prefix();
1075 std::string segmented_address_prefix();
1079 std::string segment_difference_prefix();
1155 : coff_variant(coff_variant),
type(
type)
1164 unsigned FormatAdditionalSectionFlags(std::string section_name)
const override;
1166 static std::shared_ptr<COFFFormat> CreateWriter(format_type
type);
1168 void SetOptions(std::map<std::string, std::string>& options)
override;
1173 FLAG_NO_RELOCATIONS = 0x0001,
1174 FLAG_EXECUTABLE = 0x0002,
1175 FLAG_NO_LINE_NUMBERS = 0x0004,
1176 FLAG_NO_SYMBOLS = 0x0008,
1177 FLAG_32BIT_LITTLE_ENDIAN = 0x0100,
1178 FLAG_32BIT_BIG_ENDIAN = 0x0200,
1186 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
1188 void CreateDefaultSegments();
1195 std::shared_ptr<Linker::Segment>
GetSegment(std::unique_ptr<Section>& section);
1197 std::shared_ptr<Linker::Segment> GetCodeSegment();
1199 std::shared_ptr<Linker::Segment> GetDataSegment();
1201 std::shared_ptr<Linker::Segment> GetBssSegment();
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
A brief record, such as a relocation or imported library.
Definition dumper.h:506
A record that represents a region within the file.
Definition dumper.h:485
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