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_68K, // .68k used by CP/M-68K, Concurrent DOS 68K, GEMDOS/Atari TOS, Human68k
33 FORMAT_ADAM, // Adam Seychell's DOS32 DOS extender
34 FORMAT_AIF, // ARM image format /* TODO: not implemented */
35 FORMAT_AOUT, // UNIX a.out
36 FORMAT_APPLE, // Macintosh AppleSingle/AppleDouble, used to store Macintosh files on other systems
37 FORMAT_APPLEII, // Apple ][ binary format
38 FORMAT_AR, // UNIX archive files
39 FORMAT_AS86, // Introl object file
40 FORMAT_ATARI, // Atari 8-bit binary format
41 FORMAT_BFLT, // BFLT
42 FORMAT_BW, // DOS/16M .exp file
43 FORMAT_COFF, // UNIX COFF
44 FORMAT_CMD, // CP/M-86
45 FORMAT_CPM3, // CP/M-80 Plus format
46 FORMAT_D3X, // Daniel Borca's D3X DOS extender
47 FORMAT_ELF, // UNIX ELF
48 FORMAT_ELF_MULTIPLE, // FatELF for multiple ELF binaries
49 FORMAT_FLAT, // flat unstructured file
50 FORMAT_FLEX, // FLEX .cmd (6800 or 6809 CPUs)
51 FORMAT_GEOS, // PC/GEOS Geode format
52 FORMAT_GSOS, // Apple IIgs GS/OS format
53 FORMAT_HU, // Human68k .x
54 FORMAT_HUNK, // Amiga hunk
55 FORMAT_JAVA, // Java class file
56 FORMAT_LE, // Linear executable (OS/2, DOS/4G)
57 FORMAT_LV, // CandyMan's DX64 DOS extender, LV/Float format
58 FORMAT_MACHO, // Mach-O format
59 FORMAT_MACHO_MULTIPLE, // Multi-architecture binary Mach-O format
60 FORMAT_MINIX, // MINIX a.out
61 FORMAT_MP, // Phar Lap executable .exp and relocatable executable, .rex
62 FORMAT_MZ, // MS-DOS .exe
63 FORMAT_NE, // 16-bit Windows .exe
64 FORMAT_O65, // 6502 binary relocation format
65 FORMAT_OMF, // Intel Object file
66 FORMAT_P3, // Phar Lap new executable .exp
67 FORMAT_PCOS, // Olivetti M20 PCOS .cmd/.sav files
68 FORMAT_PE, // 32-bit Windows .exe
69 FORMAT_PEF, // Classic Macintosh PowerPC executable
70 FORMAT_PMODEW, // PMODE/W executable
71 FORMAT_PRL, // MP/M-80 relocatable
72 FORMAT_RSRC, // Classic Macintosh resource, possibly containing an executable
73 FORMAT_UZI280, // UZI-280 executable
74 FORMAT_W3, // Windows unique file
75 FORMAT_W4, // Windows unique file
76 FORMAT_XENIX, // Xenix segmented executable
77 FORMAT_XENIX_BOUT, // Xenix b.out executable
78 FORMAT_XP, // OS/286 or OS/386 executable
79 FORMAT_Z8K, // CP/M-8000
80};
81
83
84enum format_priority
85{
86 PRIORITY_DEFAULT,
87 PRIORITY_LOW = -1,
88 PRIORITY_NONE = -2,
89};
90
92{
93 std::string magic;
94 unsigned offset;
95 format_type type;
96 std::string description;
97 bool (* special_parse)(Linker::Reader& in, format_description& description);
98 format_priority priority;
99};
100
102{
103 format_magic magic;
104 uint32_t offset;
105};
106
112std::shared_ptr<Linker::Format> FetchFormat(std::string text);
113
117void DetermineFormat(std::vector<format_description>& descriptions, Linker::Reader& rd, uint32_t offset = 0);
118
119std::shared_ptr<Linker::Image> ReadArchiveFile(Linker::Reader& rd, offset_t size);
120std::shared_ptr<Linker::Image> ReadLibraryFile(Linker::Reader& rd, offset_t size);
121
129std::shared_ptr<Linker::Format> CreateFormat(Linker::Reader& rd, format_description& file_format, Archive::ArchiveFormat::file_reader_type * file_reader = ReadArchiveFile);
130
131#endif /* FORMATS_H */
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
Definition formats.h:102
Definition formats.h:92
Definition formats.h:18