RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
macos.h
1#ifndef MACOS_H
2#define MACOS_H
3
4#include <filesystem>
5#include <optional>
6#include <set>
7#include <vector>
8#include "../dumper/dumper.h"
9#include "../linker/module.h"
10#include "../linker/segment.h"
11#include "../linker/segment_manager.h"
12#include "../linker/writer.h"
13
14/* Classic 68000 Mac OS file formats */
15
16namespace Apple
17{
18 typedef char OSType[4];
19
20 /* TODO: rework with Linker::Format */
21
34 {
35 public:
36 void ReadFile(Linker::Reader& rd) override;
37
38 bool FormatSupportsResources() const override;
39
40 enum format_type
41 {
42 SINGLE,
43 DOUBLE,
44 };
45 format_type type = DOUBLE;
46 unsigned version = 2;
47 /* Only relevant for version 1 */
48 enum hfs_type
49 {
50 HFS_UNDEFINED,
51 HFS_Macintosh,
52 HFS_ProDOS,
53 HFS_MSDOS,
54 HFS_UNIX,
55 HFS_VAX_VMS,
56 };
57 hfs_type home_file_system = HFS_UNDEFINED;
58
59 class Entry : public virtual Linker::Format
60 {
61 public:
62 const uint32_t id;
63 protected:
64 Entry(uint32_t id)
65 : id(id)
66 {
67 }
68 public:
69 offset_t ImageSize() const override;
70 void ReadFile(Linker::Reader& rd) override;
72 offset_t WriteFile(Linker::Writer& out) const override;
73 void Dump(Dumper::Dumper& dump) const override;
74
75 virtual void ProcessModule(Linker::Module& module);
76 virtual void CalculateValues();
77 };
78
79 private:
80 static const char TXT_undefined[16];
81 static const char TXT_Macintosh[16];
82 static const char TXT_ProDOS[16];
83 static const char TXT_MS_DOS[16];
84 static const char TXT_UNIX[16];
85 static const char TXT_VAX_VMS[16];
86
87 public:
88 std::vector<std::shared_ptr<Entry>> entries;
89
90 enum
91 {
92 ID_DataFork = 1,
93 ID_ResourceFork,
94 ID_RealName,
95 ID_Comment,
96 ID_IconBW,
97 ID_IconColor,
98 ID_FileInfo, /* v1 only */
99 ID_FileDatesInfo, /* v2 only */
100 ID_FinderInfo,
101 ID_MacintoshFileInfo, /* v2 only */
102 ID_ProDOSFileInfo, /* v2 only */
103 ID_MSDOSFileInfo, /* v2 only */
104 ID_AFPShortName, /* v2 only */
105 ID_AFPFileInfo, /* v2 only */
106 ID_AFPDirectoryID, /* v2 only */
107 };
108
109 explicit AppleSingleDouble()
110 {
111 }
112
113 AppleSingleDouble(format_type type, unsigned version, hfs_type home_file_system)
114 : type(type), version(version), home_file_system(version == 1 ? home_file_system : HFS_UNDEFINED)
115 {
116 assert(type == SINGLE || type == DOUBLE);
117 }
118
119 AppleSingleDouble(format_type type, hfs_type home_file_system)
120 : type(type), version(1), home_file_system(home_file_system)
121 {
122 assert(type == SINGLE || type == DOUBLE);
123 }
124
125 AppleSingleDouble(format_type type, unsigned version = 2)
126 : type(type), version(version), home_file_system(HFS_UNDEFINED)
127 {
128 assert(type == SINGLE || type == DOUBLE);
129 }
130
131 /* TODO: a destructor might remove the entries of the other object as well */
132 explicit AppleSingleDouble(AppleSingleDouble& other, format_type type)
133 : type(type), version(other.version), home_file_system(other.home_file_system)
134 {
135 if(type == SINGLE && other.type == DOUBLE)
136 {
137 GetDataFork();
138 }
139 for(auto entry : other.entries)
140 {
141 if(type == DOUBLE && entry->id == ID_DataFork)
142 continue;
143 entries.push_back(entry);
144 }
145 }
146
147 explicit AppleSingleDouble(AppleSingleDouble& other)
148 : type(other.type), version(other.version), home_file_system(other.home_file_system)
149 {
150 for(auto entry : other.entries)
151 {
152 entries.push_back(entry);
153 }
154 }
155
156 void SetOptions(std::map<std::string, std::string>& options) override;
157 void SetModel(std::string model) override;
158 void SetLinkScript(std::string script_file, std::map<std::string, std::string>& options) override;
159
160 std::shared_ptr<const Entry> FindEntry(uint32_t id) const;
161 std::shared_ptr<Entry> FindEntry(uint32_t id);
162
163 protected:
164 std::shared_ptr<Entry> GetFileDatesInfo();
165 std::shared_ptr<Entry> GetMacintoshFileInfo();
166 std::shared_ptr<Entry> GetAUXFileInfo();
167 std::shared_ptr<Entry> GetProDOSFileInfo();
168 std::shared_ptr<Entry> GetMSDOSFileInfo();
169
170 std::shared_ptr<Entry> GetDataFork();
171 std::shared_ptr<Entry> GetResourceFork();
172 std::shared_ptr<Entry> GetFinderInfo();
173
174 public:
175 void SetCreationDate(uint32_t CreationDate);
176 void SetModificationDate(uint32_t ModificationDate);
177 void SetBackupDate(uint32_t BackupDate);
178 void SetAccessDate(uint32_t AccessDate);
179 void SetMacintoshAttributes(uint32_t Attributes);
180 void SetProDOSAccess(uint16_t Access);
181 void SetProDOSFileType(uint16_t FileType);
182 void SetProDOSAUXType(uint32_t AUXType);
183 void SetMSDOSAttributes(uint16_t Attributes);
184
185 uint32_t GetCreationDate();
186 uint32_t GetModificationDate();
187 uint32_t GetMacintoshAttributes();
188
189 void ProcessModule(Linker::Module& module) override;
190 void CalculateValues() override;
192 offset_t WriteFile(Linker::Writer& wr) const override;
193 void Dump(Dumper::Dumper& dump) const override;
194
195 std::string PrefixFilename(std::string prefix, std::string filename);
196 std::string PrefixFilename(std::string prefix, std::string filename, size_t limit);
197 std::string ReplaceExtension(std::string filename, std::string extension, size_t limit);
198
199 std::string GetUNIXDoubleFilename(std::string filename);
200 std::string GetMacOSXDoubleFilename(std::string filename);
201 std::string GetProDOSDoubleFilename(std::string filename);
202 std::string GetMSDOSDoubleFilename(std::string filename);
203
204 void GenerateFile(std::string filename, Linker::Module& module) override;
205
207 std::string GetDefaultExtension(Linker::Module& module) const override;
208 };
209
211 {
212 public:
213 DataFork()
214 : Entry(AppleSingleDouble::ID_DataFork)
215 {
216 }
217 /* TODO - this is a stub */
218 };
219
228 class ResourceFork : public virtual AppleSingleDouble::Entry, public virtual Linker::SegmentManager
229 {
230 public:
231 bool FormatSupportsResources() const override
232 {
233 return true;
234 }
235
236 enum memory_model_t
237 {
238 MODEL_DEFAULT,
239 MODEL_TINY,
240 };
241 memory_model_t memory_model = MODEL_DEFAULT;
242
243
244 void SetOptions(std::map<std::string, std::string>& options) override;
245
246 void SetModel(std::string model) override;
247
249 {
250 public:
251 void ReadFile(Linker::Reader& rd) override;
253 offset_t WriteFile(Linker::Writer& wr) const override;
254 void Dump(Dumper::Dumper& dump) const override;
255
256 protected:
257 Resource(const char type[4], uint16_t id, uint8_t attributes = 0)
258 : id(id), attributes(attributes)
259 {
260 memcpy(this->type, type, 4);
261 }
262
263 Resource(const char type[4], uint16_t id, std::string name, uint8_t attributes = 0)
264 : id(id), name(name), attributes(attributes)
265 {
266 memcpy(this->type, type, 4);
267 }
268
269 public:
270 char type[4];
271 uint16_t id;
272
273 std::optional<std::string> name;
274 uint8_t attributes;
275
276 /* calculated later */
277 uint16_t name_offset = 0;
278 uint32_t data_offset = 0;
279
280 offset_t ImageSize() const override = 0;
281 };
282
284 {
285 public:
286 GenericResource(const char type[4], uint16_t id)
287 : Resource(type, id)
288 {
289 }
290
291 std::shared_ptr<Linker::Segment> resource;
292
293 void ProcessModule(Linker::Module& module) override;
294
295 void CalculateValues() override;
296
297 offset_t ImageSize() const override;
298
300 offset_t WriteFile(Linker::Writer& wr) const override;
301 void Dump(Dumper::Dumper& dump) const override;
302 };
303
305 {
306 public:
308 : Resource("CODE", 0)
309 {
310 }
311
312 struct Entry
313 {
314 uint16_t segment;
315 uint32_t offset;
316 };
317
318 uint32_t above_a5 = 0;
319 uint32_t below_a5 = 0;
320 std::vector<Entry> near_entries;
321 std::vector<Entry> far_entries;
322
323 void ProcessModule(Linker::Module& module) override;
324
325 void CalculateValues() override;
326
327 offset_t ImageSize() const override;
328
329 enum
330 {
331 MOVE_DATA_SP = 0x3F3C,
332 LOADSEG = 0xA9F0,
333 };
334
336 offset_t WriteFile(Linker::Writer& wr) const override;
337 void Dump(Dumper::Dumper& dump) const override;
338 };
339
340 class CodeResource : public Resource
341 {
342 public:
343 std::shared_ptr<JumpTableCodeResource> jump_table;
344 std::shared_ptr<Linker::Segment> image;
345
346 CodeResource(uint16_t id, std::shared_ptr<JumpTableCodeResource> jump_table)
347 : Resource("CODE", id), jump_table(jump_table)/*, image("code")*/
348 {
349 }
350
351 bool is_far = false; /* TODO: test far segments thoroughly */
352 uint32_t a5_address = 0; /* TODO: meaning */
353 uint32_t base_address = 0; /* TODO: meaning */
354
355// std::vector<JumpTableCodeResource::Entry> near_entries;
356// std::vector<JumpTableCodeResource::Entry> far_entries;
357 std::set<uint16_t> near_entries;
358 std::set<uint32_t> far_entries;
359 std::set<uint32_t> a5_relocations;
360 std::set<uint32_t> segment_relocations;
361
362 /* filled in after calculation */
363 uint32_t first_near_entry_offset;
364 uint32_t first_far_entry_offset;
365 uint32_t a5_relocation_offset;
366 uint32_t segment_relocation_offset;
367 uint32_t resource_size;
368
369 void ProcessModule(Linker::Module& module) override;
370
371 void CalculateValues() override;
372
373 offset_t ImageSize() const override;
374
375 uint32_t MeasureRelocations(std::set<uint32_t>& relocations) const;
376
377 void WriteRelocations(Linker::Writer& wr, const std::set<uint32_t>& relocations) const;
378
380 offset_t WriteFile(Linker::Writer& wr) const override;
381 void Dump(Dumper::Dumper& dump) const override;
382 };
383
385 : Entry(AppleSingleDouble::ID_ResourceFork)/*, a5world(".bss")*/
386 {
387 }
388
390 {
391 }
392
393 uint16_t attributes = 0; /* TODO: parametrize */
394 std::map<uint32_t, std::map<uint16_t, std::shared_ptr<Resource>>> resources;
395
396 /* these will be calculated */
397 uint32_t data_offset = 0, data_length = 0, map_offset = 0, map_length = 0;
398 uint16_t name_list_offset = 0;
399 std::map<uint32_t, uint16_t> reference_list_offsets;
400
401 /* filled in during generation */
402 std::shared_ptr<JumpTableCodeResource> jump_table;
403 std::vector<std::shared_ptr<CodeResource>> codes;
404 std::map<std::shared_ptr<Linker::Segment>, std::shared_ptr<CodeResource>> segments;
405 std::shared_ptr<Linker::Segment> a5world;
406
407 void AddResource(std::shared_ptr<Resource> resource);
408
409 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
410
411 std::unique_ptr<Script::List> GetScript(Linker::Module& module);
412
413 void Link(Linker::Module& module);
414
415 void ProcessModule(Linker::Module& module) override;
416
417 void CalculateValues() override;
418
419 offset_t ImageSize() const override;
420
422 offset_t WriteFile(Linker::Writer& wr) const override;
423 void Dump(Dumper::Dumper& dump) const override;
424
425 void GenerateFile(std::string filename, Linker::Module& module) override;
426
428 std::string GetDefaultExtension(Linker::Module& module) const override;
429 };
430
432 {
433 public:
434 std::string name;
435
436 RealName(std::string name)
437 : Entry(AppleSingleDouble::ID_RealName), name(name)
438 {
439 }
440
441 offset_t ImageSize() const override;
442
444 offset_t WriteFile(Linker::Writer& wr) const override;
445 void Dump(Dumper::Dumper& dump) const override;
446 };
447
449 {
450 public:
451 Comment()
452 : Entry(AppleSingleDouble::ID_Comment)
453 {
454 }
455 /* TODO - this is a stub */
456 };
457
459 {
460 public:
461 IconBW()
462 : Entry(AppleSingleDouble::ID_IconBW)
463 {
464 }
465 /* TODO - this is a stub */
466 };
467
469 {
470 public:
471 IconColor()
472 : Entry(AppleSingleDouble::ID_IconColor)
473 {
474 }
475 /* TODO - this is a stub */
476 };
477
478 /* Version 1 only */
480 {
481 protected:
482 FileInfo()
483 : Entry(AppleSingleDouble::ID_FileInfo)
484 {
485 }
486
487 public:
488 class Macintosh;
489 class ProDOS;
490 class MSDOS;
491 class AUX;
492 };
493
495 {
496 public:
497 uint32_t CreationDate;
498 uint32_t ModificationDate;
499 uint32_t LastBackupDate;
500 uint32_t Attributes;
501
502 Macintosh(uint32_t CreationDate = 0,
503 uint32_t ModificationDate = 0,
504 uint32_t LastBackupDate = 0,
505 uint32_t Attributes = 0)
506 : CreationDate(CreationDate), ModificationDate(ModificationDate), LastBackupDate(LastBackupDate), Attributes(Attributes)
507 {
508 }
509
510 offset_t ImageSize() const override;
511
513 offset_t WriteFile(Linker::Writer& wr) const override;
514 void Dump(Dumper::Dumper& dump) const override;
515 };
516
518 {
519 public:
520 uint32_t CreationDate;
521 uint32_t ModificationDate;
522 uint16_t Access;
523 uint16_t FileType;
524 uint32_t AUXType;
525
526 ProDOS(uint32_t CreationDate = 0,
527 uint32_t ModificationDate = 0,
528 uint16_t Access = 0,
529 uint16_t FileType = 0,
530 uint32_t AUXType = 0)
531 : CreationDate(CreationDate), ModificationDate(ModificationDate), Access(Access), FileType(FileType), AUXType(AUXType)
532 {
533 }
534
535 offset_t ImageSize() const override;
536
538 offset_t WriteFile(Linker::Writer& wr) const override;
539 void Dump(Dumper::Dumper& dump) const override;
540 };
541
543 {
544 public:
545 uint32_t ModificationDate;
546 uint16_t Attributes;
547
548 MSDOS(uint32_t ModificationDate = 0,
549 uint16_t Attributes = 0)
550 : ModificationDate(ModificationDate), Attributes(Attributes)
551 {
552 }
553
554 offset_t ImageSize() const override;
555
557 offset_t WriteFile(Linker::Writer& wr) const override;
558 void Dump(Dumper::Dumper& dump) const override;
559 };
560
561 class FileInfo::AUX : public FileInfo
562 {
563 public:
564 uint32_t CreationDate;
565 uint32_t AccessDate;
566 uint32_t ModificationDate;
567
568 AUX(uint32_t CreationDate = 0,
569 uint32_t AccessDate = 0,
570 uint32_t ModificationDate = 0)
571 : CreationDate(CreationDate), AccessDate(AccessDate), ModificationDate(ModificationDate)
572 {
573 }
574
575 offset_t ImageSize() const override;
576
578 offset_t WriteFile(Linker::Writer& wr) const override;
579 void Dump(Dumper::Dumper& dump) const override;
580 };
581
582 /* Version 2 only */
584 {
585 public:
586 uint32_t CreationDate;
587 uint32_t ModificationDate;
588 uint32_t BackupDate;
589 uint32_t AccessDate;
590
592 uint32_t CreationDate = 0,
593 uint32_t ModificationDate = 0,
594 uint32_t BackupDate = 0,
595 uint32_t AccessDate = 0)
596 : Entry(AppleSingleDouble::ID_FileDatesInfo),
597 CreationDate(CreationDate), ModificationDate(ModificationDate), BackupDate(BackupDate), AccessDate(AccessDate)
598 {
599 }
600
601 offset_t ImageSize() const override;
602
604 offset_t WriteFile(Linker::Writer& wr) const override;
605 void Dump(Dumper::Dumper& dump) const override;
606 };
607
609 {
610 public:
611 struct Point
612 {
613 uint16_t x, y;
614 };
615
616 char Type[4] = { '?', '?', '?', '?' };
617 char Creator[4] = { '?', '?', '?', '?' };
618 uint16_t Flags = 0;
619 Point Location = { 0, 0 };
620
621 FinderInfo()
622 : Entry(AppleSingleDouble::ID_FinderInfo)
623 {
624 }
625
626 offset_t ImageSize() const override;
627
629 offset_t WriteFile(Linker::Writer& wr) const override;
630 void Dump(Dumper::Dumper& dump) const override;
631
632 void ProcessModule(Linker::Module& module) override;
633 };
634
635 /* Version 2 only */
637 {
638 public:
639 uint32_t Attributes;
640 MacintoshFileInfo(uint32_t Attributes = 0)
641 : Entry(AppleSingleDouble::ID_MacintoshFileInfo), Attributes(Attributes)
642 {
643 }
644
645 offset_t ImageSize() const override;
646
648 offset_t WriteFile(Linker::Writer& wr) const override;
649 void Dump(Dumper::Dumper& dump) const override;
650 };
651
652 /* Version 2 only */
654 {
655 public:
656 uint16_t Access;
657 uint16_t FileType;
658 uint32_t AUXType;
659
660 ProDOSFileInfo(uint16_t Access = 0,
661 uint16_t FileType = 0,
662 uint32_t AUXType = 0)
663 : Entry(AppleSingleDouble::ID_ProDOSFileInfo), Access(Access), FileType(FileType), AUXType(AUXType)
664 {
665 }
666
667 offset_t ImageSize() const override;
668
670 offset_t WriteFile(Linker::Writer& wr) const override;
671 void Dump(Dumper::Dumper& dump) const override;
672 };
673
674 /* Version 2 only */
676 {
677 public:
678 uint16_t Attributes;
679
680 MSDOSFileInfo(uint16_t Attributes = 0)
681 : Entry(AppleSingleDouble::ID_MSDOSFileInfo), Attributes(Attributes)
682 {
683 }
684
685 offset_t ImageSize() const override;
686
688 offset_t WriteFile(Linker::Writer& wr) const override;
689 void Dump(Dumper::Dumper& dump) const override;
690 };
691
692 /* Version 2 only */
694 {
695 public:
697 : Entry(AppleSingleDouble::ID_AFPShortName)
698 {
699 }
700 /* TODO - this is a stub */
701 };
702
703 /* Version 2 only */
705 {
706 public:
708 : Entry(AppleSingleDouble::ID_AFPFileInfo)
709 {
710 }
711 /* TODO - this is a stub */
712 };
713
714 /* Version 2 only */
716 {
717 public:
719 : Entry(AppleSingleDouble::ID_AFPDirectoryID)
720 {
721 }
722 /* TODO - this is a stub */
723 };
724
729 {
730 public:
731 enum version_t
732 {
733 /* assigning values to the first two does not matter, because we don't generate the fields that hold them */
734 MACBIN1,
735 MACBIN1_GETINFO, /* extension */
736 MACBIN2 = 0x11,
737 MACBIN3 = 0x12,
738 };
739 version_t version, minimum_version;
740
741 uint16_t secondary_header_size = 0; /* TODO */
742 mutable uint16_t crc = 0;
743
744 uint8_t attributes = 0;
745 uint32_t creation = 0;
746 uint32_t modification = 0;
747
748 std::string generated_file_name;
749
750 MacBinary(version_t version = MACBIN3)
751 : AppleSingleDouble(AppleSingleDouble::DOUBLE), version(version), minimum_version(version <= MACBIN2 ? version : MACBIN2)
752 {
753 }
754
755 MacBinary(version_t version, version_t minimum_version)
756 : AppleSingleDouble(AppleSingleDouble::DOUBLE), version(version), minimum_version(version < minimum_version ? version : minimum_version)
757 {
758 }
759
760 explicit MacBinary(AppleSingleDouble& apple, version_t version, version_t minimum_version)
761 : AppleSingleDouble(apple, AppleSingleDouble::DOUBLE), version(version), minimum_version(version < minimum_version ? version : minimum_version)
762 {
763 }
764
765 /* CRC16-CCITT */
766 static uint16_t crc_step[256];
767
768 void CRC_Initialize() const;
769
770 void CRC_Step(uint8_t byte = 0) const;
771
772 void Skip(Linker::Writer& wr, size_t count) const;
773
774 void WriteData(Linker::Writer& wr, size_t count, const void * data) const;
775
776 void WriteData(Linker::Writer& wr, size_t count, std::string text) const;
777
778 void WriteWord(Linker::Writer& wr, size_t bytes, uint64_t value) const;
779
780 void WriteHeader(Linker::Writer& wr) const;
781
782 void CalculateValues() override;
783
785 offset_t WriteFile(Linker::Writer& wr) const override;
786 void Dump(Dumper::Dumper& dump) const override;
787
788 void GenerateFile(std::string filename, Linker::Module& module) override;
789 };
790
799 {
800 public:
801 /* format of "filename" */
802 enum target_format_t
803 {
804 TARGET_NONE, /* do not generate main file */
805 TARGET_DATA_FORK, /* main file is a data fork, typically empty */
806 TARGET_RESOURCE_FORK, /* main file is a resource fork */
807 TARGET_APPLE_SINGLE, /* main file is an AppleSingle */
808 };
809 target_format_t target;
810
811 /* other files to produce */
812 enum produce_format_t
813 {
814 PRODUCE_RESOURCE_FORK = 1 << 0, /* under .rsrc */
815 PRODUCE_FINDER_INFO = 1 << 1, /* under .finf */
816 PRODUCE_APPLE_DOUBLE = 1 << 2, /* with % prefix */
817 PRODUCE_MAC_BINARY = 1 << 3, /* with .mbin extension */
818 };
819 produce_format_t produce;
820
821 /* Typical combinations:
822 * - Executor: Generate a data fork and an AppleDouble with % prefix
823 * - Basilisk: Generate a data fork, a resource fork (under .rsrc) and a Finder Info file (under .finf)
824 * - Generate a MacBinary with .mbin extension
825 * - Generate an AppleSingle
826 */
827
828 unsigned apple_single_double_version = 2;
829 /* Only relevant for version 1 */
830 AppleSingleDouble::hfs_type home_file_system = AppleSingleDouble::HFS_UNDEFINED;
831
832 MacBinary::version_t macbinary_version = MacBinary::MACBIN3, macbinary_minimum_version = MacBinary::MACBIN2;
833
834 MacDriver(target_format_t target = TARGET_DATA_FORK)
835 : target(target),
836 produce(target == TARGET_NONE ? PRODUCE_MAC_BINARY
837 : target == TARGET_DATA_FORK ? PRODUCE_APPLE_DOUBLE
838 : produce_format_t(0))
839 {
840 }
841
842 MacDriver(target_format_t target, int produce)
843 : target(target), produce(produce_format_t(produce))
844 {
845 }
846
847 bool FormatSupportsResources() const override;
848
849 bool AddSupplementaryOutputFormat(std::string subformat) override;
850
851 private:
852 std::shared_ptr<AppleSingleDouble> container;
853
854 std::map<std::string, std::string> options;
855 std::string model;
856 std::string script_file;
857 std::map<std::string, std::string> script_options;
858
859 public:
860 void SetOptions(std::map<std::string, std::string>& options) override;
861
862 void SetModel(std::string model) override;
863
864 void SetLinkScript(std::string script_file, std::map<std::string, std::string>& options) override;
865
866 void GenerateFile(std::string filename, Linker::Module& module) override;
867
868 void ReadFile(Linker::Reader& rd) override;
869
871 offset_t WriteFile(Linker::Writer& wr) const override;
872 };
873}
874
875#endif /* MACOS_H */
Definition macos.h:716
Definition macos.h:705
Definition macos.h:694
Definition macos.h:60
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition macos.cc:22
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:27
offset_t WriteFile(Linker::Writer &out) const override
Stores data in memory to file.
Definition macos.cc:32
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:38
AppleSingle & AppleDouble.
Definition macos.h:34
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition macos.cc:58
bool FormatSupportsResources() const override
Whether the format supports resources.
Definition macos.cc:17
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition macos.cc:12
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition macos.cc:541
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition macos.cc:688
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:628
void SetModel(std::string model) override
Sets the way memory is organized, typically modifying a built-in script.
Definition macos.cc:65
std::string GetDefaultExtension(Linker::Module &module) const override
Provides a default filename for the output file.
Definition macos.cc:724
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:575
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition macos.cc:567
void SetLinkScript(std::string script_file, std::map< std::string, std::string > &options) override
Selects a script file to use for linking.
Definition macos.cc:70
Definition macos.h:449
Definition macos.h:211
Definition macos.h:584
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1415
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1410
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1426
Definition macos.h:562
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1390
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1395
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1405
Definition macos.h:543
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1371
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1376
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1385
Definition macos.h:495
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1333
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1344
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1328
Definition macos.h:518
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1354
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1366
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1349
Definition macos.h:480
Definition macos.h:609
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1431
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1436
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1450
Definition macos.h:459
Definition macos.h:469
Definition macos.h:676
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1504
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1499
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1512
MacBinary is an alternative format to AppleSingle for representing a Macintosh file on a non-Macintos...
Definition macos.h:729
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition macos.cc:1672
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1680
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1707
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition macos.cc:1718
This is not actually a file format, but an interface to permit generating multiple binary outputs for...
Definition macos.h:799
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition macos.cc:1904
bool FormatSupportsResources() const override
Whether the format supports resources.
Definition macos.cc:1726
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1909
void SetLinkScript(std::string script_file, std::map< std::string, std::string > &options) override
Selects a script file to use for linking.
Definition macos.cc:1772
bool AddSupplementaryOutputFormat(std::string subformat) override
If the output format actually drives multiple output formats (resource file, apple double,...
Definition macos.cc:1731
void SetModel(std::string model) override
Sets the way memory is organized, typically modifying a built-in script.
Definition macos.cc:1767
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition macos.cc:1778
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition macos.cc:1762
Definition macos.h:637
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1461
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1466
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1474
Definition macos.h:654
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1479
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1494
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1484
Definition macos.h:432
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1310
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1323
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1315
Definition macos.h:341
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:938
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition macos.cc:862
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition macos.cc:866
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:876
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:967
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:778
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:790
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:783
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition macos.cc:774
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition macos.cc:770
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:857
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition macos.cc:795
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:823
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition macos.cc:799
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:811
Definition macos.h:249
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition macos.cc:753
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:758
offset_t ImageSize() const override=0
Retrieves size of stored data.
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:765
A Macintosh resource fork.
Definition macos.h:229
std::string GetDefaultExtension(Linker::Module &module) const override
Provides a default filename for the output file.
Definition macos.cc:1305
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition macos.cc:1295
offset_t ImageSize() const override
Retrieves size of stored data.
Definition macos.cc:1220
void OnNewSegment(std::shared_ptr< Linker::Segment > segment) override
Callback function when allocating a new segment When the linker script runs, it creates segments cons...
Definition macos.cc:982
void SetModel(std::string model) override
Sets the way memory is organized, typically modifying a built-in script.
Definition macos.cc:734
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition macos.cc:729
bool FormatSupportsResources() const override
Whether the format supports resources.
Definition macos.h:231
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition macos.cc:1284
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition macos.cc:1225
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
A class to encode a general file format.
Definition format.h:26
offset_t WriteFile(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
A class that provides a general interface to setting up generation for a format.
Definition format.h:61
virtual std::string GetDefaultExtension(Module &module, std::string filename) const
Appends a default extension to the filename.
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
Definition macos.h:612