RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
huexe.h
1#ifndef HUEXE_H
2#define HUEXE_H
3
4#include "../common.h"
5#include "../dumper/dumper.h"
6#include "../linker/module.h"
7#include "../linker/segment.h"
8#include "../linker/segment_manager.h"
9#include "../linker/writer.h"
10
11namespace X68000
12{
16 class HUFormat : public virtual Linker::SegmentManager
17 {
18 public:
19 void ReadFile(Linker::Reader& rd) override;
20
21 enum load_mode_type
22 {
23 MODE_NORMAL,
24 MODE_SMALLEST,
25 MODE_HIGHEST,
26 };
27 load_mode_type load_mode = MODE_NORMAL; /* TODO: make parameter */
28 uint32_t entry_address = 0;
29 bool option_no_relocation = false; /* TODO: make parameter */
30
31 uint32_t base_address = 0;
32 uint32_t code_size = 0;
33 uint32_t data_size = 0;
34 uint32_t bss_size = 0;
35 uint32_t symbol_table_size = 0; // TODO
36 uint32_t debug_line_number_table_size = 0; // TODO
37 uint32_t debug_symbol_table_size = 0; // TODO
38 uint32_t debug_string_table_size = 0; // TODO
39 uint32_t bound_module_list_offset = 0; // TODO
40
42 {
43 public:
44 bool is16bit = false;
45 bool absolute_displacement = false;
46 uint32_t displacement = 0;
47 };
48
49 /* filled in automatically */
50 std::shared_ptr<Linker::Image> code, data, bss;
51 uint32_t relocation_size = 0;
52 std::map<uint32_t, uint8_t> relocations;
53 std::vector<Relocation> relocation_sequence;
54
55 std::shared_ptr<Linker::Segment> GetCodeSegment();
56 std::shared_ptr<const Linker::Segment> GetCodeSegment() const;
57 std::shared_ptr<Linker::Segment> GetDataSegment();
58 std::shared_ptr<const Linker::Segment> GetDataSegment() const;
59 std::shared_ptr<Linker::Segment> GetBssSegment();
60 std::shared_ptr<const Linker::Segment> GetBssSegment() const;
61
62 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
63 std::vector<Linker::OptionDescription<void> *> GetLinkerScriptParameterNames() override;
64
65 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
66
67 void CreateDefaultSegments();
68
69 std::unique_ptr<Script::List> GetScript(Linker::Module& module);
70
71 void Link(Linker::Module& module);
72
73 void ProcessModule(Linker::Module& module) override;
74
75 void CalculateValues() override;
76
78 offset_t WriteFile(Linker::Writer& wr) const override;
79 void Dump(Dumper::Dumper& dump) const override;
80
81 void GenerateFile(std::string filename, Linker::Module& module) override;
82
84 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
85 };
86
87}
88
89#endif /* HUEXE_H */
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:773
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:20
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
Human68k "HU" .X file.
Definition huexe.h:17
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition huexe.cc:196
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition huexe.cc:329
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 huexe.cc:117
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition huexe.cc:247
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition huexe.cc:285
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition huexe.cc:406
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition huexe.cc:416
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition huexe.cc:11
std::vector< Linker::OptionDescription< void > * > GetLinkerScriptParameterNames() override
Returns a list of the parameters used in the linker scripts, used for documentation.
Definition huexe.cc:112
Definition huexe.h:42