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::OUTPUT_CON)
22 {
23 LEFormat::module_flags = LEFormat::GUIAware | LEFormat::NoInternalFixup;
24 LEFormat::signature[1] = 'X';
25 }
26
27 bool bound_image = false;
28 uint32_t aout_header_offset = 0;
29 std::array<char, 64> dos_options;
30 /* patch area inside the LX data object */
31 uint32_t text_base = 0;
32 uint32_t text_end = 0;
33 uint32_t data_base = 0;
34 uint32_t data_end = 0;
35 uint32_t bss_base = 0;
36 uint32_t bss_end = 0;
37 uint32_t heap_base = 0;
38 uint32_t heap_end = 0;
39 uint32_t heap_brk = 0;
40 uint32_t heap_off = 0;
41 uint32_t os2_dll = 0;
42 uint32_t stack_base = 0;
43 uint32_t stack_end = 0;
44 uint32_t flags = 0;
45 std::array<char, 64> os2_options;
46
47 void ReadFile(Linker::Reader& rd) override;
48
49 offset_t ImageSize() const override;
50
52 offset_t WriteFile(Linker::Writer& wr) const override;
53
54 void Dump(Dumper::Dumper& dump) const override;
55
56 /* * * Reader members * * */
57
59 void GenerateModule(Linker::Module& module) const override;
60
61 /* * * Writer members * * */
62
64 {
65 public:
66 Linker::Option<std::string> stub{"stub", "Filename for stub that gets prepended to executable"};
67
69 {
70 InitializeFields(stub);
71 }
72 };
73
74 using LEFormat::stub;
75
76 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
77 std::vector<Linker::OptionDescription<void> *> GetLinkerScriptParameterNames() override;
78
79 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
80 void SetOptions(std::map<std::string, std::string>& options) override;
81
82 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
83
84 void ProcessModule(Linker::Module& module) override;
85
86 void CalculateValues() override;
87
88 void GenerateFile(std::string filename, Linker::Module& module) override;
89
91 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
92 std::string GetDefaultExtension(Linker::Module& module) const override;
93 };
94}
95
96#endif /* EMXAOUT_H */
UNIX/Linux a.out binary file format.
Definition aout.h:48
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:773
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:221
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:474
Documents and handles command line options.
Definition options.h:306
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, encapsulating functionality needed to export binary data.
Definition writer.h:15
LE/LX .EXE linear executable file format.
Definition leexe.h:30