RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
emxaout.h
1#ifndef EMXAOUT_H
2#define EMXAOUT_H
3
4#include "mzexe.h"
5#include "aout.h"
6#include "leexe.h"
7#include "../common.h"
8#include "../dumper/dumper.h"
9#include "../linker/module.h"
10#include "../linker/options.h"
11#include "../linker/segment.h"
12#include "../linker/segment_manager.h"
13#include "../linker/writer.h"
14
15namespace EMX
16{
17 class EMXAOutFormat : public virtual AOut::AOutFormat, protected virtual Microsoft::LEFormat
18 {
19 public:
21 : AOutFormat(AOutFormat::EMX, AOutFormat::ZMAGIC), LEFormat(LEFormat::OS2, LEFormat::GUIAware | LEFormat::NoInternalFixup, true)
22 {
23 }
24
25 bool bound_image = false;
26 uint32_t aout_header_offset = 0;
27 std::array<char, 64> dos_options;
28 /* patch area inside the LX data object */
29 uint32_t text_base = 0;
30 uint32_t text_end = 0;
31 uint32_t data_base = 0;
32 uint32_t data_end = 0;
33 uint32_t bss_base = 0;
34 uint32_t bss_end = 0;
35 uint32_t heap_base = 0;
36 uint32_t heap_end = 0;
37 uint32_t heap_brk = 0;
38 uint32_t heap_off = 0;
39 uint32_t os2_dll = 0;
40 uint32_t stack_base = 0;
41 uint32_t stack_end = 0;
42 uint32_t flags = 0;
43 std::array<char, 64> os2_options;
44
45 void ReadFile(Linker::Reader& rd) override;
46
47 offset_t ImageSize() const override;
48
50 offset_t WriteFile(Linker::Writer& wr) const override;
51
52 void Dump(Dumper::Dumper& dump) const override;
53
54 /* * * Reader members * * */
55
57 void GenerateModule(Linker::Module& module) const override;
58
59 /* * * Writer members * * */
60
62 {
63 public:
64 Linker::Option<std::string> stub{"stub", "Filename for stub that gets prepended to executable"};
65
67 {
68 InitializeFields(stub);
69 }
70 };
71
72 using LEFormat::stub;
73
74 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
75 std::vector<Linker::OptionDescription<void> *> GetLinkerScriptParameterNames() override;
76
77 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
78 void SetOptions(std::map<std::string, std::string>& options) override;
79
80 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
81
82 void ProcessModule(Linker::Module& module) override;
83
84 void CalculateValues() override;
85
86 void GenerateFile(std::string filename, Linker::Module& module) override;
87
89 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
90 std::string GetDefaultExtension(Linker::Module& module) const override;
91 };
92}
93
94#endif /* EMXAOUT_H */
UNIX/Linux a.out binary file format.
Definition aout.h:50
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
Definition emxaout.h:18
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition emxaout.cc:6
void GenerateModule(Linker::Module &module) const override
Loads the information into a module object, a convenience method when there is a single module genera...
Definition emxaout.cc:117
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition emxaout.cc:138
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition emxaout.cc:231
std::vector< Linker::OptionDescription< void > * > GetLinkerScriptParameterNames() override
Returns a list of the parameters used in the linker scripts, used for documentation.
Definition emxaout.cc:128
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition emxaout.cc:157
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition emxaout.cc:65
offset_t ImageSize() const override
Retrieves size of stored data.
Definition emxaout.cc:59
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition emxaout.cc:95
std::shared_ptr< Linker::OptionCollector > GetOptions() override
Returns object containing a sequence of option fields provided with the -S command line flag.
Definition emxaout.cc:133
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition emxaout.cc:152
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition emxaout.cc:207
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 emxaout.cc:147
offset_t WriteFile(Writer &wr) const override=0
Stores data in memory to file.
virtual void GenerateModule(ModuleCollector &linker, std::string file_name, bool is_library=false) const
Loads the information into a module object.
Definition format.cc:215
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
Helper class that contains the options interpreted by the format.
Definition options.h:467
Documents and handles command line options.
Definition options.h:303
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, encapsulating functionality needed to export binary data.
Definition writer.h:15
LE/LX .EXE linear executable file format.
Definition leexe.h:29