RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
cpm86.h
1#ifndef CPM86_H
2#define CPM86_H
3
4#include <array>
5#include <map>
6#include <set>
7#include <vector>
8#include "../common.h"
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"
15
16namespace DigitalResearch
17{
155 class CPM86Format : public virtual Linker::SegmentManager
156 {
157 public:
158 /* * * General members * * */
159
180 {
181 public:
221 uint16_t size_paras = 0;
223 uint16_t load_segment = 0;
225 uint16_t min_size_paras = 0;
227 uint16_t max_size_paras = 0;
234 uint32_t offset = 0;
236 std::shared_ptr<Linker::Contents> image = nullptr;
238 bool attach_zero_page = false;
239
240 virtual void Clear();
241
243 {
244 Clear();
245 }
246
250 virtual uint16_t GetSizeParas(const CPM86Format& module) const;
251
252 void ReadDescriptor(const std::shared_ptr<Linker::Reader>& rd);
253
257 void Prepare(CPM86Format& module);
258
259 void WriteDescriptor(const std::shared_ptr<Linker::Writer>& wr, const CPM86Format& module) const;
260
261 virtual void WriteData(const std::shared_ptr<Linker::Writer>& wr, const CPM86Format& module) const;
262
263 std::string GetDefaultName() const;
264
265 virtual void ReadData(const std::shared_ptr<Linker::Reader>& rd, const CPM86Format& module);
266 };
267
272 {
274 number_t segment;
276 offset_t offset;
277
279 : segment(0), offset(0)
280 {
281 }
282
283 relocation_source(size_t segment, offset_t offset)
285 {
286 }
287
288 bool operator==(const relocation_source& other) const;
289 bool operator<(const relocation_source& other) const;
290 };
291
292 typedef relocation_source relocation_target;
293
298 {
299 uint8_t source = 0;
300 uint16_t paragraph = 0;
301 uint8_t offset = 0;
302 uint8_t target = 0;
303
304 Relocation()
305 {
306 }
307
308 Relocation(uint8_t source, uint16_t paragraph, uint16_t offset, uint8_t target)
309 : source(source), paragraph(paragraph), offset(offset), target(target)
310 {
311 }
312
313 Relocation(relocation_source source, uint8_t target = 0)
314 : source(source.segment), paragraph(source.offset >> 4), offset(source.offset & 0xF), target(target)
315 {
316 }
317
318 operator bool() const;
319
320 void Read(const std::shared_ptr<Linker::Reader>& rd, CPM86Format& module, bool is_library = false);
321
322 void Write(const std::shared_ptr<Linker::Writer>& wr) const;
323
324 relocation_source GetSource() const;
325 };
326
333 {
335 std::string rsx_file_name;
337 std::string name;
344 uint16_t offset_record = 0;
345 static constexpr uint16_t RSX_TERMINATE = 0xFFFF;
346 static constexpr uint16_t RSX_DYNAMIC = 0x0000;
350 std::shared_ptr<Linker::Contents> contents;
351
352 void Clear();
353
354 void Read(const std::shared_ptr<Linker::Reader>& rd);
355
356 void ReadModule(const std::shared_ptr<Linker::Reader>& rd);
357
358 void Write(const std::shared_ptr<Linker::Writer>& wr) const;
359
360 void WriteModule(const std::shared_ptr<Linker::Writer>& wr) const;
361
362 offset_t GetFullFileSize() const;
363 void SetOffset(offset_t new_offset);
364
365 void Dump(Dumper::Dumper& dump) const;
366 };
367
375 {
377 std::string name;
379 uint16_t major_version = 0;
381 uint16_t minor_version = 0;
383 uint32_t flags = 0x11010000;
384
385 library_id() { }
386
387 library_id(std::string name, uint16_t major_version, uint16_t minor_version)
389 {
390 }
391
392 library_id(std::string name, uint16_t major_version, uint16_t minor_version, uint32_t flags)
394 {
395 }
396
397 library_id(const library_id& lib) = default;
398
400 static library_id ParseNameAndVersion(std::string name_and_version);
401
402 bool operator ==(const library_id& other) const;
403
404 void Write(const std::shared_ptr<Linker::Writer>& wr) const;
405
406 void Read(const std::shared_ptr<Linker::Reader>& rd);
407 };
408
415 struct library : public library_id
416 {
418 std::vector<Relocation> relocations;
420 uint16_t relocation_count = 0;
421
423 uint16_t first_selector = 0;
425 uint16_t unknown = 0;
426
428 std::set<relocation_source> relocation_targets;
429
430 library()
431 {
432 }
433
434 library(std::string name, uint16_t major_version, uint16_t minor_version)
436 {
437 }
438
439 library(std::string name, uint16_t major_version, uint16_t minor_version, uint32_t flags)
440 : library_id(name, major_version, minor_version, flags)
441 {
442 }
443
444 library(const library_id& lib)
445 : library_id(lib)
446 {
447 }
448
449 void Write(const std::shared_ptr<Linker::Writer>& wr) const;
450
451 void WriteExtended(const std::shared_ptr<Linker::Writer>& wr) const;
452
453 void Read(const std::shared_ptr<Linker::Reader>& rd);
454
455 void ReadExtended(const std::shared_ptr<Linker::Reader>& rd);
456 };
457
460 {
461 public:
463 std::vector<library> libraries;
464
465 void Clear() override;
466
470 void Prepare(CPM86Format& module);
471
472#if 0
476 bool IsFastLoadFormat() const;
477#endif
478
479 library& FetchImportedLibrary(std::string name_dot_version);
480
481 library& FetchImportedLibrary(library_id id);
482
483 uint16_t GetSizeParas(const CPM86Format& module) const override;
484
485 void WriteData(const std::shared_ptr<Linker::Writer>& wr, const CPM86Format& module) const override;
486
487 void ReadData(const std::shared_ptr<Linker::Reader>& rd, const CPM86Format& module) override;
488 };
489
492 {
493 public:
495 uint16_t maximum_entries = 0;
497 uint16_t first_free_entry = 0;
499 uint16_t index_base = 0;
501 uint16_t first_used_index = 0;
502
504 {
506 uint16_t limit = 0;
508 uint32_t address = 0;
510 uint8_t group = 0;
511 uint16_t reserved = 0;
512
513 void Read(const std::shared_ptr<Linker::Reader>& rd);
514
515 void Write(const std::shared_ptr<Linker::Writer>& wr) const;
516 };
517
518 std::vector<ldt_descriptor> ldt;
519
520 void Clear() override;
521
522 uint16_t GetSizeParas(const CPM86Format& module) const override;
523
524 void WriteData(const std::shared_ptr<Linker::Writer>& wr, const CPM86Format& module) const override;
525
526 void ReadData(const std::shared_ptr<Linker::Reader>& rd, const CPM86Format& module) override;
527 };
528
532 std::array<Descriptor, 8> descriptors;
548 std::vector<Relocation> relocations;
552 uint32_t relocations_offset = 0;
556 std::array<rsx_record, 8> rsx_table;
560 uint32_t rsx_table_offset = 0;
564 uint8_t flags = 0;
568 uint8_t cpm_flags = 0;
569
573 uint32_t file_offset = 0;
575 mutable offset_t file_size = offset_t(-1);
576
577 enum
578 {
586 FLAG_RSX = 0x10,
593 };
594
595 enum
596 {
597 CPM_FLAG_F1 = 0x01,
598 CPM_FLAG_F2 = 0x02,
599 CPM_FLAG_F3 = 0x03,
600 CPM_FLAG_F4 = 0x04,
601 };
602
603 void Clear() override;
604
635
659
662 {
663 }
664
666 {
667 Clear();
668 }
669
670 uint16_t GetRelocationSizeParas() const;
671
672 size_t CountValidGroups();
673
674 number_t FindSegmentGroup(unsigned group) const;
675
676 void CheckValidSegmentGroup(unsigned group);
677
678 bool IsFastLoadFormat() const;
679 bool IsSharedRunTimeLibrary() const;
680
681 void ReadRelocations(const std::shared_ptr<Linker::Reader>& rd);
682
683 void WriteRelocations(const std::shared_ptr<Linker::Writer>& wr) const;
684
685 offset_t MeasureRelocations();
686
687 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
688
689 offset_t ImageSize() const override;
690
692 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
693
694 offset_t GetFullFileSize() const;
695
696 void Dump(Dumper::Dumper& dump) const override;
697
698 void CalculateValues() override;
699
700 /* * * Writer members * * */
701
703 {
704 public:
705 enum system_type
706 {
707 System_CPM86,
708 System_FlexOS286,
709 };
710
711 class SystemEnumeration : public Linker::Enumeration<system_type>
712 {
713 public:
715 : Enumeration(
716 "CPM", System_CPM86,
717 "CPM86", System_CPM86,
718 "FLEXOS", System_FlexOS286,
719 "FLEXOS286", System_FlexOS286)
720 {
721 descriptions = {
722 { System_CPM86, "Digital Research CP/M-86" },
723 { System_FlexOS286, "Digital Research FlexOS 286" },
724 };
725 }
726 };
727
728 enum format_type
729 {
730 Format_8080,
731 Format_Small,
732 Format_Compact,
733 };
734
735 class FormatEnumeration : public Linker::Enumeration<format_type>
736 {
737 public:
739 : Enumeration(
740 "8080", Format_8080,
741 "TINY", Format_8080,
742 "T", Format_8080,
743 "SMALL", Format_Small,
744 "S", Format_Small,
745 "COMPACT", Format_Compact,
746 "COMP", Format_Compact,
747 "C", Format_Compact)
748 {
749 descriptions = {
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" },
753 };
754 }
755 };
756
757 Linker::Option<Linker::ItemOf<SystemEnumeration>> system{"system", "Target operating system"};
758 Linker::Option<Linker::ItemOf<FormatEnumeration>> format{"format", "File format"};
759 Linker::Option<bool> postlink{"postlink", "Generate fast load (POSTLINK) format (only for FlexOS)"};
760 Linker::Option<bool> noreloc{"noreloc", "Suppress generating relocations"};
761 Linker::Option<bool> sharedcode{"sharedcode", "Make the code segment shared (descriptor type 9)"};
762 Linker::Option<std::optional<std::vector<std::string>>> rsx_file_names{"rsx", "List of filenames to append as Resident System Extensions (CP/M)"};
763 Linker::Option<bool> fixupgroup{"fixupgroup", "Generates group descriptor for fixups (FlexOS)"};
764 Linker::Option<std::optional<std::string>> srtl{"srtl", "Generate shared run-time library, parameter: <library name>.<major version>.<minor version>[.<optional flags as hexadecimal value>]"};
765 Linker::Option<std::string> x87{"8087", "Sets 8087 usage, valid values: off/on/auto", "off"};
766 Linker::Option<bool> directvideo{"directvideo", "Direct video access"};
767 Linker::Option<bool> mpmlock{"mpmlock", "MP/M-style record handling (Concurrent DOS)"};
768 Linker::Option<bool> nobank{"nobank", "Cannot run in banked memory"};
769 Linker::Option<bool> f1{"f1", "CP/M F1 flag (Concurrent DOS)"};
770 Linker::Option<bool> f2{"f2", "CP/M F2 flag (Concurrent DOS)"};
771 Linker::Option<bool> f3{"f3", "CP/M F3 flag (Concurrent DOS)"};
772 Linker::Option<bool> f4{"f4", "CP/M F4 flag (Concurrent DOS)"};
773 // TODO: make stack size a parameter (for FlexOS)
774
775 CPM86OptionCollector()
776 {
777 InitializeFields(system, format, postlink, noreloc, sharedcode, rsx_file_names, fixupgroup, srtl, x87, directvideo, mpmlock, nobank, f1, f2, f3, f4);
778 }
779 };
780
782 bool option_shared_code = false;
787
790 {
791 MODEL_DEFAULT,
798 };
801
802 bool FormatSupportsSegmentation() const override;
803
804 bool FormatIs16bit() const override;
805
806 bool FormatIsProtectedMode() const override;
807
808 bool FormatSupportsLibraries() const override;
809
810 unsigned FormatAdditionalSectionFlags(std::string section_name) const override;
811
812 std::vector<std::shared_ptr<Linker::Segment>>& Segments();
813
815 std::map<std::shared_ptr<Linker::Segment>, Descriptor::group_type> segment_types;
816
818 void AssignSegmentTypes();
819
820 unsigned GetSegmentNumber(std::shared_ptr<Linker::Segment> segment);
821
822 static std::vector<Linker::OptionDescription<void>> MemoryModelNames;
823
824 std::vector<Linker::OptionDescription<void>> GetMemoryModelNames() override;
825
826 void SetModel(std::string model) override;
827
828 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
829
830 void SetOptions(std::map<std::string, std::string>& options) override;
831
832 std::unique_ptr<Script::List> GetScript(Linker::Module& module);
833
834 void Link(Linker::Module& module);
835
837 void BuildLDTImage(Linker::Module& module);
838
839 void ProcessModule(Linker::Module& module) override;
840
841 void GenerateFile(std::string filename, Linker::Module& module) override;
842
844 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
845 };
846
847}
848
849#endif /* CPM86_H */
A representation of segment group within the executable.
Definition cpm86.h:180
uint16_t load_segment
Load segment address of the group, or 0 if it can be relocated. Not to be used outside of system driv...
Definition cpm86.h:223
void Prepare(CPM86Format &module)
Sets up any values before it can be written to file.
Definition cpm86.cc:39
bool attach_zero_page
Set to true if a supplementary 256 bytes of zeros are required. When generating image,...
Definition cpm86.h:238
group_type type
The type of the group.
Definition cpm86.h:219
std::shared_ptr< Linker::Contents > image
The actual binary image of the group.
Definition cpm86.h:236
uint16_t max_size_paras
Maximum required size of the group, when loaded into memory, in 16-byte paragraphs.
Definition cpm86.h:227
virtual uint16_t GetSizeParas(const CPM86Format &module) const
Returns the size of the segment group in 16-byte paragraphs.
Definition cpm86.cc:18
uint16_t min_size_paras
Minimum required size of the group, when loaded into memory, in 16-byte paragraphs.
Definition cpm86.h:225
uint32_t offset
Offset to image in file.
Definition cpm86.h:234
uint16_t size_paras
Size of the group, as stored on disk, in 16-byte paragraphs.
Definition cpm86.h:221
group_type
Group type, stored as the first byte of the descriptor.
Definition cpm86.h:184
@ Code
A group containing executable instructions, the starting segment will be loaded into CS....
Definition cpm86.h:188
@ Auxiliary2
A group containing data.
Definition cpm86.h:198
@ Undefined
This group type is not the type of an actual group. Instead, it signals the end of the group descript...
Definition cpm86.h:186
@ Libraries
(FlexOS 286 only) The shared runtime library group descriptor is stored at offset 0x48 in the header,...
Definition cpm86.h:211
@ Data
A group containing data, the starting segment will be loaded into DS.
Definition cpm86.h:190
@ Fixups
(FlexOS 286 only) The group containing the relocations. Not required, since the offset to the relocat...
Definition cpm86.h:207
@ Auxiliary3
A group containing data.
Definition cpm86.h:200
@ Extra
A group containing data, the starting semgnet will be loaded into ES.
Definition cpm86.h:192
@ Stack
A group describing the stack data. Unlike the other associated segments, SS does not point to it at t...
Definition cpm86.h:194
@ Auxiliary4
A group containing data. The group type was later repurposed to represent the relocations in a file....
Definition cpm86.h:202
@ ActualFixups
(FlexOS 286 only) The group containing the relocations, used when it is clear this is a fixup group
Definition cpm86.h:216
@ Auxiliary1
A group containing data.
Definition cpm86.h:196
@ ActualAuxiliary4
A group containing data, used when it is clear this is an auxiliary group.
Definition cpm86.h:214
@ FastLoad
(FlexOS 286 only) The fast load group descriptor is stored at offset 0x51 in the header,...
Definition cpm86.h:209
@ SharedCode
A group containing executable instructions, the starting segment will be loaded into CS....
Definition cpm86.h:204
(FlexOS 286 only) The fast loading group (unimplemented)
Definition cpm86.h:492
uint16_t GetSizeParas(const CPM86Format &module) const override
Returns the size of the segment group in 16-byte paragraphs.
Definition cpm86.cc:425
uint16_t index_base
The index base.
Definition cpm86.h:499
uint16_t first_used_index
First used index.
Definition cpm86.h:501
uint16_t first_free_entry
First free entry in LDT after last filled entry.
Definition cpm86.h:497
uint16_t maximum_entries
Maximum allowed LDT entries.
Definition cpm86.h:495
A special descriptor to represent the group for imported shared runtime libraries.
Definition cpm86.h:460
uint16_t GetSizeParas(const CPM86Format &module) const override
Returns the size of the segment group in 16-byte paragraphs.
Definition cpm86.cc:354
void Prepare(CPM86Format &module)
Sets up any values before it can be written to file.
Definition cpm86.cc:327
std::vector< library > libraries
The shared runtime libraries to be imported.
Definition cpm86.h:463
The native file format for 8086 based CP/M derived operating systems, including FlexOS 186/286.
Definition cpm86.h:156
uint8_t cpm_flags
CP/M specific flags used by Concurrent DOS, stored at offset 0x7A.
Definition cpm86.h:568
uint32_t rsx_table_offset
The actual RSX table, stored in 128 byte units at offset 0x7B.
Definition cpm86.h:560
offset_t file_size
The full size of the image.
Definition cpm86.h:575
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition cpm86.cc:1013
std::shared_ptr< Linker::OptionCollector > GetOptions() override
Returns object containing a sequence of option fields provided with the -S command line flag.
Definition cpm86.cc:1300
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition cpm86.cc:1943
std::array< Descriptor, 8 > descriptors
A .cmd file may contain up to 8 descriptors that describer the segment groups.
Definition cpm86.h:532
void BuildLDTImage(Linker::Module &module)
Creates the LDT image for a fastload FlexOS binary.
Definition cpm86.cc:1785
bool option_no_relocation
Flag to indicate that relocations must be suppressed.
Definition cpm86.h:784
application_type application
Target application type.
Definition cpm86.h:658
std::array< rsx_record, 8 > rsx_table
Represents a list of attached RSX modules.
Definition cpm86.h:556
FastLoadDescriptor fastload_descriptor
FlexOS 286 defines a fast load segment (unknown name) at offset 0x51.
Definition cpm86.h:540
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition cpm86.cc:790
format_type
Describes the number and type of segment groups, as well as the target operating system.
Definition cpm86.h:607
@ FORMAT_FASTLOAD
FlexOS 286 fastload format as generated by postlink, with an LDT image in file.
Definition cpm86.h:631
@ FORMAT_FLEXOS
FlexOS 286 format, running in protected mode, possible SRTL shared libraries.
Definition cpm86.h:627
@ FORMAT_COMPACT
CP/M-86 format, each non-executable section will have its own group, including stack and up to 4 auxi...
Definition cpm86.h:623
@ FORMAT_8080
CP/M-86 format, only a single non-shared code group is present, with optional relocations and attache...
Definition cpm86.h:615
@ FORMAT_UNKNOWN
Unspecified.
Definition cpm86.h:611
@ FORMAT_SMALL
CP/M-86 format, only code (possibly shared) and a separate data group is present, also used for mediu...
Definition cpm86.h:619
memory_model_t memory_model
Memory model of generated code, determines how the offsets are calculated within a segment group.
Definition cpm86.h:800
memory_model_t
Represents the memory model of the running executable, which is the way in which the segments are set...
Definition cpm86.h:790
@ MODEL_COMPACT
DS!=SS!=ES.
Definition cpm86.h:797
@ MODEL_TINY
CS=DS=SS=ES, only possible in 8080 mode.
Definition cpm86.h:793
@ MODEL_SMALL
DS=SS=ES, only possible in 8080 or small mode.
Definition cpm86.h:795
std::vector< Relocation > relocations
The sequence of intramodule relocations.
Definition cpm86.h:548
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition cpm86.cc:668
uint32_t relocations_offset
Offset of relocation records, stored in 128 byte units at offset 0x7D.
Definition cpm86.h:552
bool FormatSupportsLibraries() const override
Whether the format supports libraries.
Definition cpm86.cc:1125
application_type
Definition cpm86.h:637
@ APPL_RSX
CP/M-86 .rsx resident system extension file.
Definition cpm86.h:643
@ APPL_OVR
CP/M-86 .ovr overlay (unsupported)
Definition cpm86.h:651
@ APPL_RSP
MP/M-86 or Concurrent CP/M-86 .rsp resident system process file (unsupported)
Definition cpm86.h:645
@ APPL_286
FlexOS 286 .286 executable file (limited support)
Definition cpm86.h:653
@ APPL_SRL
FlexOS 286 .SRL shared runtime library (limited support)
Definition cpm86.h:655
@ APPL_MPM
MP/M-86 .mpm system module file (unsupported)
Definition cpm86.h:647
@ APPL_UNKNOWN
Unspecified.
Definition cpm86.h:639
@ APPL_CMD
CP/M-86 .cmd executable file.
Definition cpm86.h:641
@ APPL_CON
Concurrent CP/M-86 .con system module file (unsupported)
Definition cpm86.h:649
bool FormatIs16bit() const override
Whether the format is 16-bit or not.
Definition cpm86.cc:1115
std::map< std::shared_ptr< Linker::Segment >, Descriptor::group_type > segment_types
Assignment from each segment to the segment group type number (1: code, 2: data, etc....
Definition cpm86.h:815
uint8_t flags
Execution flags, stored at offset 0x7F.
Definition cpm86.h:564
void SetModel(std::string model) override
Sets the way memory is organized, typically modifying a built-in script.
Definition cpm86.cc:1267
bool option_shared_code
Flag indicating that the code group is shared, not possible in 8080 format.
Definition cpm86.h:782
std::vector< Linker::OptionDescription< void > > GetMemoryModelNames() override
Returns a list of the supported memory models, used for documentation.
Definition cpm86.cc:1262
library_id lib_id
FlexOS 286 library identifier (for libraries) at offset 0x60.
Definition cpm86.h:544
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition cpm86.cc:1305
void Clear() override
Resets all fields to their default values, deallocate memory.
Definition cpm86.cc:456
@ FLAG_DIRECT_VIDEO
Set when the program uses direct video access. Such programs cannot execute in the background.
Definition cpm86.h:588
@ FLAG_FIXUPS
Set when relocations are present, indicates that the executable is relocatable and needs fixing up be...
Definition cpm86.h:580
@ FLAG_REQUIRED_8087
Set when the software only runs if an 8087 is present. The system will allocate 8087 resources.
Definition cpm86.h:584
@ FLAG_RSX
Set for residential system extensions (RSX files)
Definition cpm86.h:586
@ FLAG_MPMLOCK
Program uses record locking functions of MP/M-86 instead of those of Concurrent CP/M-86 or Concurrent...
Definition cpm86.h:590
@ FLAG_NO_BANKING
Set when the program cannot run in banked memory.
Definition cpm86.h:592
@ FLAG_OPTIONAL_8087
Set when the software expects the system to allocate 8087 resources, but it can emulate the missing 8...
Definition cpm86.h:582
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition cpm86.cc:2122
void AssignSegmentTypes()
Determine the segment group type number, must be called before accessing segment_types.
Definition cpm86.cc:1153
bool FormatSupportsSegmentation() const override
Whether the format supports multiple segments.
Definition cpm86.cc:1110
LibraryDescriptor library_descriptor
FlexOS 286 defines a shared runtime library group at offset 0x48.
Definition cpm86.h:536
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition cpm86.cc:673
format_type format
Format of file to generate.
Definition cpm86.h:634
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition cpm86.cc:2132
uint32_t file_offset
The start of the image within the file, typically 0 except for embedded modules, usually for embedded...
Definition cpm86.h:573
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition cpm86.cc:582
bool FormatIsProtectedMode() const override
Whether the format is in protected mode or not (x86 only)
Definition cpm86.cc:1120
bool option_generate_fixup_group
On FlexOS, relocations can be part of its own group.
Definition cpm86.h:786
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
offset_t WriteFile(const std::shared_ptr< Writer > &wr) const override=0
Stores data in memory to file.
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
virtual std::string GetDefaultExtension(Module &module, std::string filename) const
Appends a default extension to the filename.
A helper class to collect sections into segments.
Definition segment_manager.h:32
uint32_t address
Intel 286 descriptor base address, 24-bit.
Definition cpm86.h:508
uint8_t group
Group the segment belongs to.
Definition cpm86.h:510
uint16_t limit
Intel 286 descriptor limit.
Definition cpm86.h:506
Represents a single relocation.
Definition cpm86.h:298
(FlexOS only) A shared runtime library identifier
Definition cpm86.h:375
uint16_t major_version
The major version of the library.
Definition cpm86.h:379
std::string name
The name of the library, 8 characters long.
Definition cpm86.h:377
static library_id ParseNameAndVersion(std::string name_and_version)
Converts a string in the format "FILENAME.MAJ.MIN.FLAGS" to an identifier.
Definition cpm86.cc:228
uint32_t flags
System specific flags, undocumented.
Definition cpm86.h:383
uint16_t minor_version
The minor version of the library.
Definition cpm86.h:381
(FlexOS 286 only) A shared runtime library entry in the shared runtime library group
Definition cpm86.h:416
uint16_t relocation_count
Relocation count.
Definition cpm86.h:420
uint16_t first_selector
(FASTLOAD only) First selector that references this library
Definition cpm86.h:423
uint16_t unknown
(FASTLOAD only) Unknown
Definition cpm86.h:425
std::vector< Relocation > relocations
The set of relocations.
Definition cpm86.h:418
std::set< relocation_source > relocation_targets
Unordered relocations, only used during binary generation.
Definition cpm86.h:428
Represents the location of a 16-bit words that needs to be relocated.
Definition cpm86.h:272
offset_t offset
The offset to the word within the segment group.
Definition cpm86.h:276
number_t segment
The segment group number that contains the required relocation.
Definition cpm86.h:274
Represents an attached RSX file (residential system extension)
Definition cpm86.h:333
uint16_t offset_record
The offset to the attached RSX file, in 128-byte units.
Definition cpm86.h:344
std::shared_ptr< Linker::Contents > contents
A reference to the stored module, either parsed or a raw block of data.
Definition cpm86.h:350
std::string name
The filename of the RSX file, 8-byte long.
Definition cpm86.h:337
std::string rsx_file_name
The host filename of the RSX file, used only for writing.
Definition cpm86.h:335