9#include "../linker/module.h"
10#include "../linker/options.h"
11#include "../linker/segment.h"
12#include "../linker/segment_manager.h"
13#include "../linker/writer.h"
269 static const std::map<uint32_t, MachineType> MACHINE_TYPES;
305 constexpr size_t GetRelocationEntrySize()
const
307 switch(relocation_format)
334 static constexpr uint16_t
R_ABS = 0;
356 static constexpr uint16_t
R_AUX = 11;
570 static constexpr uint16_t R_Z80_IMM8 = 0x22;
571 static constexpr uint16_t R_Z80_IMM16 = 0x01;
572 static constexpr uint16_t R_Z80_IMM24 = 0x33;
573 static constexpr uint16_t R_Z80_IMM32 = 0x17;
574 static constexpr uint16_t R_Z80_OFF8 = 0x32;
575 static constexpr uint16_t R_Z80_JR = 0x02;
577 static constexpr uint16_t R_Z8K_IMM4L = 0x23;
578 static constexpr uint16_t R_Z8K_IMM4H = 0x24;
579 static constexpr uint16_t R_Z8K_DISP7 = 0x25;
580 static constexpr uint16_t R_Z8K_IMM8 = 0x22;
581 static constexpr uint16_t R_Z8K_IMM16 = 0x01;
582 static constexpr uint16_t R_Z8K_REL16 = 0x04;
583 static constexpr uint16_t R_Z8K_IMM32 = 0x11;
584 static constexpr uint16_t R_Z8K_JR = 0x02;
585 static constexpr uint16_t R_Z8K_CALLR = 0x05;
587 static constexpr uint16_t R_W65_ABS8 = 0x01;
588 static constexpr uint16_t R_W65_ABS16 = 0x02;
589 static constexpr uint16_t R_W65_ABS24 = 0x03;
590 static constexpr uint16_t R_W65_ABS8S8 = 0x04;
591 static constexpr uint16_t R_W65_ABS8S16 = 0x05;
592 static constexpr uint16_t R_W65_ABS16S8 = 0x06;
593 static constexpr uint16_t R_W65_ABS16S16 = 0x07;
594 static constexpr uint16_t R_W65_PCR8 = 0x08;
595 static constexpr uint16_t R_W65_PCR16 = 0x09;
596 static constexpr uint16_t R_W65_DP = 0x0A;
671 bool IsExternal()
const;
685 std::string file_name;
696 int32_t section_length;
697 uint16_t relocation_entry_count;
698 uint16_t line_number_count;
712 int32_t next_entry_index;
739 int32_t pointer_to_line_number;
740 int32_t next_entry_index;
741 uint16_t transfer_table_index;
753 uint16_t declaration_line_number;
755 std::array<uint16_t, 4> dimensions;
767 uint16_t line_number;
769 int32_t next_entry_index;
789 std::unique_ptr<AuxiliaryEntry> auxiliary_entry =
nullptr;
966 std::shared_ptr<Linker::Contents>
image;
975 static constexpr uint32_t
TEXT = 0x0020;
977 static constexpr uint32_t
DATA = 0x0040;
979 static constexpr uint32_t
BSS = 0x0080;
985 static constexpr uint32_t
DSECT = 0x0001;
987 static constexpr uint32_t
NOLOAD = 0x0002;
989 static constexpr uint32_t
GROUP = 0x0004;
991 static constexpr uint32_t
PAD = 0x0008;
993 static constexpr uint32_t
COPY = 0x0010;
995 static constexpr uint32_t
INFO = 0x0200;
997 static constexpr uint32_t
OVER = 0x0400;
999 static constexpr uint32_t
LIB = 0x0800;
1006 static constexpr uint32_t
RDATA = 0x00000100;
1008 static constexpr uint32_t
SDATA = 0x00000200;
1010 static constexpr uint32_t
SBSS = 0x00000400;
1012 static constexpr uint32_t
UCODE = 0x00000800;
1014 static constexpr uint32_t
GOT = 0x00001000;
1018 static constexpr uint32_t
DYNSYM = 0x00004000;
1022 static constexpr uint32_t
DYNSTR = 0x00010000;
1024 static constexpr uint32_t
HASH = 0x00020000;
1028 static constexpr uint32_t
MSYM = 0x00080000;
1034 static constexpr uint32_t
FINI = 0x01000000;
1038 static constexpr uint32_t
RCONST = 0x02200000;
1040 static constexpr uint32_t
XDATA = 0x02400000;
1044 static constexpr uint32_t
TLSBSS = 0x02600000;
1048 static constexpr uint32_t
PDATA = 0x02800000;
1050 static constexpr uint32_t
LITA = 0x04000000;
1052 static constexpr uint32_t
LIT8 = 0x08000000;
1054 static constexpr uint32_t
LIT4 = 0x10000000;
1058 static constexpr uint32_t
INIT = 0x80000000;
1075 static constexpr uint32_t
GPREL = 0x00008000;
1110 static constexpr uint32_t
PAD = 0x0008;
1112 static constexpr uint32_t
DWARF = 0x0010;
1116 static constexpr uint32_t
INFO = 0x0200;
1118 static constexpr uint32_t
TDATA = 0x0400;
1120 static constexpr uint32_t
TBSS = 0x0800;
1124 static constexpr uint32_t
DEBUG = 0x2000;
1135 static constexpr uint32_t
DSECT = 0x00000001;
1137 static constexpr uint32_t
NOLOAD = 0x00000002;
1139 static constexpr uint32_t
GROUP = 0x00000004;
1141 static constexpr uint32_t
PAD = 0x00000008;
1143 static constexpr uint32_t
COPY = 0x00000010;
1145 static constexpr uint32_t
BLOCK = 0x00010000;
1147 static constexpr uint32_t
PASS = 0x00020000;
1149 static constexpr uint32_t
CLINK = 0x00040000;
1151 static constexpr uint32_t
VECTOR = 0x00080000;
1153 static constexpr uint32_t
PADDED = 0x00100000;
1266 operator size_t()
const;
1281 std::unique_ptr<Linker::Buffer> buffer =
nullptr;
1284 : buffer(std::make_unique<Linker::Buffer>(size))
1288 uint32_t
GetSize()
const override;
1344 uint32_t
GetSize()
const override;
1365 uint32_t reserved1 = 0;
1366 uint32_t reserved2 = 0;
1373 uint32_t
GetSize()
const override;
1411 uint32_t
GetSize()
const override;
1436 uint32_t code_size = 0;
1437 uint32_t data_size = 0;
1438 uint32_t bss_size = 0;
1439 uint32_t symbol_table_size = 0;
1440 uint32_t entry_address = 0;
1441 uint32_t code_relocation_size = 0;
1442 uint32_t data_relocation_size = 0;
1444 uint32_t
GetSize()
const override;
1465 uint32_t bss_address;
1469 uint32_t cpr_mask[4];
1478 uint32_t
GetSize()
const override;
1502 static constexpr uint16_t SYM_STAMP = 0x030D;
1552 uint32_t
GetSize()
const override;
1697 uint8_t shared_memory_page = 0;
1705 uint32_t
GetSize()
const override;
1716 void Clear()
override;
1739 bool DetectCpuType(::EndianType expected);
1741 void DetectCpuType();
1764 void SetupOptions(std::shared_ptr<Linker::OutputFormat> format)
override;
1766 bool option_segmentation =
false;
1772 std::string segment_prefix();
1774 std::string segment_of_prefix();
1779 std::string segmented_address_prefix();
1783 std::string segment_difference_prefix();
1832 bool option_unmapped_zero_page =
false;
1851 {
OMAGIC,
"Impure executable (OMAGIC)" },
1852 {
NMAGIC,
"Pure executable (NMAGIC)" },
1853 {
ZMAGIC,
"Demand paged executable (ZMAGIC)" },
1866 COFFOptionCollector()
1868 InitializeFields(stub, type, Nflag, nflag, zflag);
1955 unsigned FormatAdditionalSectionFlags(std::string section_name)
const override;
1957 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
1960 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
1962 void SetOptions(std::map<std::string, std::string>& options)
override;
1983 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
1985 void CreateDefaultSegments();
1992 std::shared_ptr<Linker::Segment>
GetSegment(std::shared_ptr<Section>& section);
1994 std::shared_ptr<Linker::Segment> GetCodeSegment();
1996 std::shared_ptr<Linker::Segment> GetDataSegment();
1998 std::shared_ptr<Linker::Segment> GetBssSegment();
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
A representation of an enumeration with associated string representations for each value.
Definition options.h:15
std::map< value_type, std::string > descriptions
An empty dictionary that explains the value types in detail.
Definition options.h:20
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