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 OutputFormat;
14 class Reader;
15}
16
18{
19 std::string format;
20 std::shared_ptr<Linker::OutputFormat> (* produce)();
21 std::string documentation;
22};
23
24extern output_format_type 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_BW, // DOS/16M .exp file
42 FORMAT_COFF, // UNIX COFF
43 FORMAT_CMD, // CP/M-86
44 FORMAT_CPM3, // CP/M-80 Plus format
45 FORMAT_D3X, // Daniel Broca's D3X DOS extender
46 FORMAT_ELF, // UNIX ELF
47 FORMAT_ELF_MULTIPLE, // FatELF for multiple ELF binaries
48 FORMAT_FLAT, // flat unstructured file
49 FORMAT_FLEX, // FLEX .cmd (6800 or 6809 CPUs)
50 FORMAT_GEOS, // PC/GEOS Geode format
51 FORMAT_GSOS, // Apple IIgs GS/OS format
52 FORMAT_HU, // Human68k .x
53 FORMAT_HUNK, // Amiga hunk
54 FORMAT_JAVA, // Java class file
55 FORMAT_LE, // Linear executable (OS/2, DOS/4G)
56 FORMAT_LV, // CandyMan's DX64 DOS extender, LV/Float format
57 FORMAT_MACHO, // Mach-O format
58 FORMAT_MACHO_MULTIPLE, // Multi-architecture binary Mach-O format
59 FORMAT_MINIX, // MINIX a.out
60 FORMAT_MP, // Phar Lap executable .exp and relocatable executable, .rex
61 FORMAT_MZ, // MS-DOS .exe
62 FORMAT_NE, // 16-bit Windows .exe
63 FORMAT_O65, // 6502 binary relocation format
64 FORMAT_OMF, // Intel Object file
65 FORMAT_P3, // Phar Lap new executable .exp
66 FORMAT_PCOS, // Olivetti M20 PCOS .cmd/.sav files
67 FORMAT_PE, // 32-bit Windows .exe
68 FORMAT_PEF, // Classic Macintosh PowerPC executable
69 FORMAT_PMODEW, // PMODE/W executable
70 FORMAT_PRL, // MP/M-80 relocatable
71 FORMAT_RSRC, // Classic Macintosh resource, possibly containing an executable
72 FORMAT_UZI280, // UZI-280 executable
73 FORMAT_W3, // Windows unique file
74 FORMAT_W4, // Windows unique file
75 FORMAT_XENIX, // Xenix segmented executable
76 FORMAT_XENIX_BOUT, // Xenix b.out executable
77 FORMAT_XP, // OS/286 or OS/386 executable
78 FORMAT_Z8K, // CP/M-8000
79};
80
82
84{
85 std::string magic;
86 unsigned offset;
87 format_type type;
88 std::string description;
89 bool (* special_parse)(Linker::Reader& in, format_description& description);
90};
91
93{
94 format_magic magic;
95 uint32_t offset;
96};
97
103std::shared_ptr<Linker::OutputFormat> FetchFormat(std::string text);
104
108void DetermineFormat(std::vector<format_description>& descriptions, Linker::Reader& rd, uint32_t offset = 0);
109
110std::shared_ptr<Linker::Image> ReadArchiveFile(Linker::Reader& rd, offset_t size);
111std::shared_ptr<Linker::Image> ReadLibraryFile(Linker::Reader& rd, offset_t size);
112
120std::shared_ptr<Linker::Format> CreateFormat(Linker::Reader& rd, format_description& file_format, Archive::ArchiveFormat::file_reader_type * file_reader = ReadArchiveFile);
121
122#endif /* FORMATS_H */
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
Definition formats.h:93
Definition formats.h:84
Definition formats.h:18