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"
14#include "../dumper/dumper.h"
16namespace DigitalResearch
236 std::shared_ptr<Linker::Contents>
image =
nullptr;
240 virtual void Clear();
252 void ReadDescriptor(
const std::shared_ptr<Linker::Reader>& rd);
259 void WriteDescriptor(
const std::shared_ptr<Linker::Writer>& wr,
const CPM86Format& module)
const;
261 virtual void WriteData(
const std::shared_ptr<Linker::Writer>& wr,
const CPM86Format& module)
const;
263 std::string GetDefaultName()
const;
265 virtual void ReadData(
const std::shared_ptr<Linker::Reader>& rd,
const CPM86Format& module);
288 bool operator==(
const relocation_source& other)
const;
289 bool operator<(
const relocation_source& other)
const;
292 typedef relocation_source relocation_target;
300 uint16_t paragraph = 0;
308 Relocation(uint8_t source, uint16_t paragraph, uint16_t offset, uint8_t target)
309 : source(source), paragraph(paragraph), offset(offset), target(target)
314 : source(source.segment), paragraph(source.offset >> 4), offset(source.offset & 0xF), target(target)
318 operator bool()
const;
320 void Read(
const std::shared_ptr<Linker::Reader>& rd,
CPM86Format& module,
bool is_library =
false);
322 void Write(
const std::shared_ptr<Linker::Writer>& wr)
const;
345 static constexpr uint16_t RSX_TERMINATE = 0xFFFF;
346 static constexpr uint16_t RSX_DYNAMIC = 0x0000;
354 void Read(
const std::shared_ptr<Linker::Reader>& rd);
356 void ReadModule(
const std::shared_ptr<Linker::Reader>& rd);
358 void Write(
const std::shared_ptr<Linker::Writer>& wr)
const;
360 void WriteModule(
const std::shared_ptr<Linker::Writer>& wr)
const;
362 offset_t GetFullFileSize()
const;
363 void SetOffset(offset_t new_offset);
397 library_id(
const library_id& lib) =
default;
402 bool operator ==(
const library_id& other)
const;
404 void Write(
const std::shared_ptr<Linker::Writer>& wr)
const;
406 void Read(
const std::shared_ptr<Linker::Reader>& rd);
444 library(
const library_id& lib)
449 void Write(
const std::shared_ptr<Linker::Writer>& wr)
const;
451 void WriteExtended(
const std::shared_ptr<Linker::Writer>& wr)
const;
453 void Read(
const std::shared_ptr<Linker::Reader>& rd);
455 void ReadExtended(
const std::shared_ptr<Linker::Reader>& rd);
465 void Clear()
override;
476 bool IsFastLoadFormat()
const;
479 library& FetchImportedLibrary(std::string name_dot_version);
485 void WriteData(
const std::shared_ptr<Linker::Writer>& wr,
const CPM86Format& module)
const override;
487 void ReadData(
const std::shared_ptr<Linker::Reader>& rd,
const CPM86Format& module)
override;
511 uint16_t reserved = 0;
513 void Read(
const std::shared_ptr<Linker::Reader>& rd);
515 void Write(
const std::shared_ptr<Linker::Writer>& wr)
const;
518 std::vector<ldt_descriptor> ldt;
520 void Clear()
override;
524 void WriteData(
const std::shared_ptr<Linker::Writer>& wr,
const CPM86Format& module)
const override;
526 void ReadData(
const std::shared_ptr<Linker::Reader>& rd,
const CPM86Format& module)
override;
603 void Clear()
override;
670 uint16_t GetRelocationSizeParas()
const;
672 size_t CountValidGroups();
674 number_t FindSegmentGroup(
unsigned group)
const;
676 void CheckValidSegmentGroup(
unsigned group);
678 bool IsFastLoadFormat()
const;
679 bool IsSharedRunTimeLibrary()
const;
681 void ReadRelocations(
const std::shared_ptr<Linker::Reader>& rd);
683 void WriteRelocations(
const std::shared_ptr<Linker::Writer>& wr)
const;
685 offset_t MeasureRelocations();
687 void ReadFile(
const std::shared_ptr<Linker::Reader>& rd)
override;
692 offset_t
WriteFile(
const std::shared_ptr<Linker::Writer>& wr)
const override;
694 offset_t GetFullFileSize()
const;
717 "CPM86", System_CPM86,
718 "FLEXOS", System_FlexOS286,
719 "FLEXOS286", System_FlexOS286)
722 { System_CPM86,
"Digital Research CP/M-86" },
723 { System_FlexOS286,
"Digital Research FlexOS 286" },
743 "SMALL", Format_Small,
745 "COMPACT", Format_Compact,
746 "COMP", Format_Compact,
750 { Format_8080,
"8080 model, a single segment group is generated" },
751 { Format_Small,
"Small model, a single code and separate data group is generated" },
752 { Format_Compact,
"Compact model, a single code and multiple data groups are generated" },
759 Linker::Option<bool> postlink{
"postlink",
"Generate fast load (POSTLINK) format (only for FlexOS)"};
761 Linker::Option<bool> sharedcode{
"sharedcode",
"Make the code segment shared (descriptor type 9)"};
763 Linker::Option<bool> fixupgroup{
"fixupgroup",
"Generates group descriptor for fixups (FlexOS)"};
775 CPM86OptionCollector()
777 InitializeFields(system, format, postlink, noreloc, sharedcode, rsx_file_names, fixupgroup, srtl, x87, directvideo, mpmlock, nobank, f1, f2, f3, f4);
810 unsigned FormatAdditionalSectionFlags(std::string section_name)
const override;
812 std::vector<std::shared_ptr<Linker::Segment>>& Segments();
820 unsigned GetSegmentNumber(std::shared_ptr<Linker::Segment> segment);
822 static std::vector<Linker::OptionDescription<void>> MemoryModelNames;
826 void SetModel(std::string model)
override;
828 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
830 void SetOptions(std::map<std::string, std::string>& options)
override;
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:1009
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:499
Documents and handles command line options.
Definition options.h:306
A helper class to collect sections into segments.
Definition segment_manager.h:32