RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
aif.h
1#ifndef AIF_H
2#define AIF_H
3
4#include "../common.h"
5#include "../dumper/dumper.h"
6#include "../linker/reader.h"
7#include "../linker/segment_manager.h"
8#include "../linker/writer.h"
9
10/* TODO: unimplemented */
11
12namespace ARM
13{
17 class AIFFormat : public virtual Linker::SegmentManager
18 {
19 public:
20 static constexpr uint32_t ARM_NOP = 0xE1A00000; // mov r0, r0
21 static constexpr uint32_t ARM_BLNV = 0xFB;
22 static constexpr uint32_t ARM_BL = 0xEB000000;
23 static constexpr uint32_t ARM_BL_OP = ARM_BL >> 24;
24
25 ::EndianType endiantype = ::LittleEndian;
26
27 offset_t file_size;
28
29 bool compressed = false;
30 uint32_t decompression_code = 0; // relative to image start
31
32 bool relocatable = false;
33 uint32_t relocation_code = 0; // relative to image start
34
35 bool has_zero_init = false;
36 uint32_t zero_init_code = 0; // relative to image start
37
38 bool executable = true;
39 uint32_t entry = 0; // relative to code start
40
41 static constexpr uint32_t ARM_SWI_0x11 = 0xEF000011;
42 uint32_t exit_instruction = ARM_SWI_0x11;
43
44 uint32_t text_size = 0;
45 uint32_t data_size = 0;
46 uint32_t debug_size = 0;
47 uint32_t bss_size = 0;
48 enum debug_type : uint32_t
49 {
50 NoDebugData = 0,
51 LowLevelDebugData = 1,
52 SourceLevelDebugData = 2,
53 BothDebugData = 3,
54 };
55 debug_type image_debut_type = NoDebugData;
56 uint32_t image_base = 0;
57 uint32_t workspace = 0;
58 enum address_mode_type : uint32_t
59 {
60 OldAifHeader = 0,
61 AifHeader26 = 26,
62 AifHeader32 = 32,
63 SeparateCodeData = 0x00000100,
64 };
65 address_mode_type address_mode = AifHeader32;
66 uint32_t data_base = 0;
67
68 void Clear() override;
69 void CalculateValues() override;
70 void ReadFile(Linker::Reader& rd) override;
71 offset_t ImageSize() const override;
73 offset_t WriteFile(Linker::Writer& wr) const override;
74 void Dump(Dumper::Dumper& dump) const override;
75 /* TODO */
76
78 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
79 };
80}
81
82#endif /* AIF_H */
ARM Image Format.
Definition aif.h:18
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition aif.cc:182
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition aif.cc:12
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition aif.cc:17
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition aif.cc:115
void Clear() override
Resets all fields to their default values, deallocate memory.
Definition aif.cc:7
offset_t ImageSize() const override
Retrieves size of stored data.
Definition aif.cc:110
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition aif.cc:171
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
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
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