RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
formats.h
1#ifndef FORMATS_H
2#define FORMATS_H
3
4#include <cstdint>
5#include <memory>
6#include <string>
7#include <vector>
8#include "format/arch.h"
9
10namespace Linker
11{
12 class Image;
13 class Format;
14 class Reader;
15}
16
18{
19 std::string format;
20 std::shared_ptr<Linker::Format> (* produce)();
21 std::string documentation;
22};
23
24extern format_specification formats[];
25extern const size_t formats_size;
26
30enum format_type
31{
32 FORMAT_3P, // CauseWay /* TODO: not implemented */
33 FORMAT_68K, // .68k used by CP/M-68K, Concurrent DOS 68K, GEMDOS/Atari TOS, Human68k
34 FORMAT_ADAM, // Adam Seychell's DOS32 DOS extender
35 FORMAT_AIF, // ARM image format /* TODO: not implemented */
36 FORMAT_AOUT, // UNIX a.out
37 FORMAT_APPLE, // Macintosh AppleSingle/AppleDouble, used to store Macintosh files on other systems
38 FORMAT_APPLEII, // Apple ][ binary format
39 FORMAT_AR, // UNIX archive files
40 FORMAT_AS86, // Introl object file
41 FORMAT_ATARI, // Atari 8-bit binary format
42 FORMAT_BFLT, // BFLT
43 FORMAT_BW, // DOS/16M .exp file
44 FORMAT_COFF, // UNIX COFF
45 FORMAT_CMD, // CP/M-86
46 FORMAT_CPM3, // CP/M-80 Plus format
47 FORMAT_D3X, // Daniel Borca's D3X DOS extender
48 FORMAT_ELF, // UNIX ELF
49 FORMAT_ELF_MULTIPLE, // FatELF for multiple ELF binaries
50 FORMAT_FLAT, // flat unstructured file
51 FORMAT_FLEX, // FLEX .cmd (6800 or 6809 CPUs)
52 FORMAT_GEOS, // PC/GEOS Geode format
53 FORMAT_GSOS, // Apple IIgs GS/OS format
54 FORMAT_HU, // Human68k .x
55 FORMAT_HUNK, // Amiga hunk
56 FORMAT_JAVA, // Java class file
57 FORMAT_LE, // Linear executable (OS/2, DOS/4G)
58 FORMAT_LV, // CandyMan's DX64 DOS extender, LV/Float format
59 FORMAT_MACBINARY, // MacBinary
60 FORMAT_MACHO, // Mach-O format
61 FORMAT_MACHO_MULTIPLE, // Multi-architecture binary Mach-O format
62 FORMAT_MINIX, // MINIX a.out
63 FORMAT_MP, // Phar Lap executable .exp and relocatable executable, .rex
64 FORMAT_MZ, // MS-DOS .exe
65 FORMAT_NE, // 16-bit Windows .exe
66 FORMAT_O65, // 6502 binary relocation format
67 FORMAT_OMF, // (old) Intel Object file, for 8080, 8051, 8096
68 FORMAT_OMF86, // Intel Object file, for 8086 and derivatives
69 FORMAT_P3, // Phar Lap new executable .exp
70 FORMAT_PCOS, // Olivetti M20 PCOS .cmd/.sav files
71 FORMAT_PE, // 32-bit Windows .exe
72 FORMAT_PEF, // Classic Macintosh PowerPC executable
73 FORMAT_PMODEW, // PMODE/W executable
74 FORMAT_PRL, // MP/M-80 relocatable
75 FORMAT_RSRC, // Classic Macintosh resource, possibly containing an executable
76 FORMAT_RSRC_GS, // IIgs resource /* TODO: not implemented */
77 FORMAT_SOS, // Apple /// SOS interpreter
78 FORMAT_UZI280, // UZI-280 executable
79 FORMAT_WASM, // WebAssembly module format
80 FORMAT_W3, // Windows unique file
81 FORMAT_W4, // Windows unique file
82 FORMAT_XENIX, // Xenix segmented executable
83 FORMAT_XENIX_BOUT, // Xenix b.out executable
84 FORMAT_XP, // OS/286 or OS/386 executable
85 FORMAT_Z8K, // CP/M-8000
86};
87
89
90enum format_priority
91{
92 PRIORITY_DEFAULT,
93 PRIORITY_LOW = -1,
94 PRIORITY_NONE = -2,
95};
96
98{
99 std::string magic;
100 unsigned offset;
101 format_type type;
102 std::string description;
103 bool (* special_parse)(const std::shared_ptr<Linker::Reader>& in, format_description& description);
104 format_priority priority;
105};
106
108{
109 format_magic magic;
110 uint32_t offset;
111};
112
118std::shared_ptr<Linker::Format> FetchFormat(std::string text);
119
123void DetermineFormat(std::vector<format_description>& descriptions, const std::shared_ptr<Linker::Reader>& rd, uint32_t offset = 0);
124
125std::shared_ptr<Linker::Contents> ReadArchiveFile(const std::shared_ptr<Linker::Reader>& rd, offset_t size);
126std::shared_ptr<Linker::Contents> ReadLibraryFile(const std::shared_ptr<Linker::Reader>& rd, offset_t size);
127
135std::shared_ptr<Linker::Format> CreateFormat(const std::shared_ptr<Linker::Reader>& rd, format_description& file_format, Archive::ArchiveFormat::file_reader_type * file_reader = ReadArchiveFile);
136
137#endif /* FORMATS_H */
Definition formats.h:108
Definition formats.h:98
Definition formats.h:18