6#include "../dumper/dumper.h"
7#include "../linker/format.h"
8#include "../linker/reader.h"
9#include "../linker/writer.h"
29 void WriteWord(
size_t bytes, uint64_t value)
32 for(
size_t offset = 0; offset < bytes; offset++, value >>= 8)
38 size_t WriteData(
const std::vector<uint8_t>& data)
41 for(
size_t offset = 0; offset < bytes; offset++)
43 checksum -= data[offset];
48 size_t WriteData(std::string text)
51 for(
size_t offset = 0; offset < text.size(); offset++)
53 checksum -= text[offset];
58 void Skip(offset_t count)
236 std::shared_ptr<SegmentDefinitionRecord> record;
252 std::shared_ptr<GroupDefinitionRecord> record;
272 std::shared_ptr<TypeDefinitionRecord> record;
288 std::shared_ptr<BlockDefinitionRecord> record;
304 std::shared_ptr<OverlayDefinitionRecord> record;
346 uint8_t segment_index;
354 uint32_t element_size;
360 value.far.number = value.far.element_size = 0;
382 void CalculateValues(
OMF86Format * omf, Module * mod);
383 void ResolveReferences(
OMF86Format * omf, Module * mod);
438 uint16_t GetSymbolSize(
OMF86Format * omf,
bool is32bit)
const;
472 typedef std::vector<std::shared_ptr<DataBlock>>
Blocks;
474 typedef std::vector<uint8_t>
Data;
502 std::variant<ThreadNumber, SegmentIndex, GroupIndex, ExternalIndex, FrameNumber>
target =
ThreadNumber(0);
504 std::variant<ThreadNumber, SegmentIndex, GroupIndex, ExternalIndex, FrameNumber, UsesSource, UsesTarget, UsesAbsolute>
frame =
ThreadNumber(0);
509 uint16_t GetSize(
OMF86Format * omf,
bool is32bit)
const;
588 LibraryHeader = 0xF0,
688 RelocatableModule = 1,
811 uint16_t maximum_segment_length;
812 uint16_t group_offset;
830 Combination_Public4 =
FlagTIS | 4,
837 Combination_Common =
FlagTIS | 6,
840 Combination_Public7 =
FlagTIS | 4,
862 AccessExecuteOnly = 1,
863 AccessExecuteRead = 2,
912 uint32_t maximum_group_length;
913 uint32_t group_length;
931 std::variant<ExternalIndex, SegmentIndex, SegmentClassOverlayNames, LoadTimeLocatable, Absolute>
component =
ExternalIndex();
934 uint16_t GetComponentSize(
OMF86Format * omf)
const;
990 std::variant<uint32_t, int32_t, std::string, TypeIndex, Null, Repeat>
leaf =
Null();
1050 UnsignedInteger = 0x7C,
1051 SignedInteger = 0x7D,
1225 enum frame_type_t : uint8_t
1231 frame_type_t frame_type;
1233 static constexpr uint8_t SymbolBaseMethod = 0x00;
1234 static constexpr uint8_t ExternalMethod = 0x01;
1235 static constexpr uint8_t BlockMethod = 0x02;
1237 std::variant<BaseSpecification, ExternalIndex, BlockIndex> base =
ExternalIndex();
1239 std::vector<SymbolDefinition> names;
1366 std::variant<SegmentIndex, GroupIndex, ExternalIndex, FrameNumber, UsesSource, UsesTarget, UsesAbsolute>
reference =
FrameNumber(0);
1417 uint16_t GetSize(
OMF86Format * omf,
bool is32bit)
const;
1551 uint16_t GetRegisterSize(
OMF86Format * omf)
const;
1589 std::optional<std::variant<Reference, std::tuple<uint16_t, uint16_t>>>
start_address;
1711 uint16_t GetGroupSize()
const;
1748 enum location_type_t : uint8_t
1753 Location32bit_IBM = 9,
1756 std::vector<OffsetValuePair> offset_value_pairs;
1789 enum location_type_t : uint8_t
1794 Location32bit_IBM = 9,
1798 std::vector<OffsetValuePair> offset_value_pairs;
1829 enum selection_criterion_t : uint8_t
1831 SelectNoMatch = 0x00,
1832 SelectPickAny = 0x10,
1833 SelectSameSize = 0x20,
1834 SelectExactMatch = 0x30,
1836 static constexpr uint8_t SelectionCriterionMask = 0xF0;
1837 selection_criterion_t selection_criterion;
1839 enum allocation_type_t : uint8_t
1841 AllocateExplicit = 0x00,
1842 AllocateFarCode = 0x01,
1843 AllocateFarData = 0x02,
1844 AllocateCode32 = 0x03,
1845 AllocateData32 = 0x04,
1847 static constexpr uint8_t AllocationTypeMask = 0x0F;
1848 allocation_type_t allocation_type;
1857 std::shared_ptr<DataBlock> data;
1885 std::vector<LineNumber> line_numbers;
1914 std::string alias_name;
1915 std::string substitute_name;
1918 uint16_t GetAliasDefinitionSize(
OMF86Format * omf)
const;
1921 std::vector<AliasDefinition> alias_definitions;
1944 std::string version;
1967 uint16_t vendor_number;
1968 std::string extension;
1993 enum comment_class_t : uint8_t
1996 IntelCopyright = 0x01,
1997 LibrarySpecifier = 0x81,
1998 MSDOSVersion = 0x9C,
2001 DefaultLibrarySearchName = 0x9F,
2002 OMFExtension = 0xA0,
2003 NewOMFExtension = 0xA1,
2004 LinkPassSeparator = 0xA2,
2016 DependencyFile = 0xE9,
2019 comment_class_t comment_class;
2026 CommentRecord(comment_class_t comment_class = comment_class_t(0))
2027 :
Record(COMENT), comment_class(comment_class)
2032 virtual uint16_t GetCommentSize(
OMF86Format * omf)
const = 0;
2051 std::vector<uint8_t> data;
2059 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2072 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2087 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2094 std::vector<SegmentIndex> segments;
2102 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2119 uint16_t GetAssociationSize(
OMF86Format * omf)
const;
2126 std::vector<ExternalAssociation> associations;
2134 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2144 enum extension_type_t : uint8_t
2149 ProtectedModeLibrary = 0x04,
2154 extension_type_t subtype;
2168 std::vector<uint8_t> data;
2176 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2189 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2196 std::string internal_name;
2197 std::string module_name;
2198 std::variant<std::string, uint16_t> entry_ident;
2206 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2215 uint8_t parameter_count;
2216 std::string exported_name;
2217 std::string internal_name;
2218 std::optional<uint16_t> ordinal;
2226 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2233 uint16_t extdef_delta;
2234 uint16_t linnum_delta;
2235 uint16_t padding_byte_count;
2243 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2250 bool new_executable;
2251 bool omit_codeview_publics;
2253 uint8_t pseudocode_version;
2254 uint8_t codeview_version;
2256 static constexpr uint8_t FlagNewExecutable = 0x01;
2257 static constexpr uint8_t FlagOmitCodeViewPublics = 0x02;
2258 static constexpr uint8_t FlagRunMPC = 0x04;
2266 uint16_t GetCommentSize(
OMF86Format * omf)
const override;
2273 uint32_t dictionary_offset;
2274 uint16_t dictionary_size;
2275 bool case_sensitive;
2332 std::vector<std::shared_ptr<SegmentDefinitionRecord>>
segdefs;
2334 std::vector<std::shared_ptr<GroupDefinitionRecord>>
grpdefs;
2336 std::vector<std::shared_ptr<TypeDefinitionRecord>>
typdefs;
2338 std::vector<std::shared_ptr<BlockDefinitionRecord>>
blkdefs;
2340 std::vector<std::shared_ptr<OverlayDefinitionRecord>>
ovldefs;
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, encapsulating functionality needed to export binary data.
Definition writer.h:15
void WriteData(size_t count, const void *data)
Write out a sequence of bytes.
Definition writer.cc:7
void Skip(offset_t offset)
Jump to a distance in the output stream.
Definition writer.cc:103
void WriteWord(size_t bytes, uint64_t value, EndianType endiantype)
Read a word.
Definition writer.cc:66
Convenience class to calculate the checksum of a record while writing it.
Definition omf.h:19