RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
module_collector.h
1#ifndef MODULE_COLLECTOR_H
2#define MODULE_COLLECTOR_H
3
4#include <map>
5#include <memory>
6#include <set>
7#include <string>
8#include <vector>
9#include "symbol_definition.h"
10#include "table_section.h"
11#include "target.h"
12
13namespace Linker
14{
15 class Module;
16 class InputFormat;
17 class OutputFormat;
18
25 {
26 public:
32 void SetupOptions(char special_char, std::shared_ptr<OutputFormat> output_format);
33
35 bool generate_got = false;
36 std::shared_ptr<Module> CreateModule(std::shared_ptr<const InputFormat> input_format, std::string file_name = "");
37 private:
38 /* GNU assembler can use '$', NASM must use '?' */
39 char special_prefix_char = '$';
40 std::weak_ptr<OutputFormat> output_format;
41
42 public:
45 {
49 std::weak_ptr<Module> module;
50 };
52 std::vector<std::shared_ptr<Module>> modules;
58 std::set<std::string> required_symbols;
64 std::map<std::string, definition> symbol_definitions;
65
71 void AddModule(std::shared_ptr<Module> module, bool is_library = false);
75 void AddLibraryModule(std::shared_ptr<Module> module);
79 void CombineModulesInto(Module& output_module);
80
81 private:
85 void IncludeModule(std::shared_ptr<Module> module);
86 };
87}
88
89#endif /* MODULE_COLLECTOR_H */
Helper class that collects object files and libraries, and includes library objects for required symb...
Definition module_collector.h:25
std::vector< std::shared_ptr< Module > > modules
A list of all modules to be considered, not all of which will be included in the final generated bina...
Definition module_collector.h:52
std::set< std::string > required_symbols
Symbols that are referenced but have not yet been defined among the included modules.
Definition module_collector.h:58
void CombineModulesInto(Module &output_module)
Appends all the modules that have been determined to be included, into a resulting object.
Definition module_collector.cc:82
void SetupOptions(char special_char, std::shared_ptr< OutputFormat > output_format)
Initializes the reader for linking purposes.
Definition module_collector.cc:8
bool generate_got
Set to true when Global Offset Table generation is requested.
Definition module_collector.h:35
void AddModule(std::shared_ptr< Module > module, bool is_library=false)
Adds a module to the modules vector, also registers all the non-local symbols, and determines if any ...
Definition module_collector.cc:21
void AddLibraryModule(std::shared_ptr< Module > module)
Convenience method to add a library.
Definition module_collector.cc:77
std::map< std::string, definition > symbol_definitions
Collection of symbols defined thus far.
Definition module_collector.h:64
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
binding_type
Definition symbol_definition.h:20
Description of a symbol definition in some module.
Definition module_collector.h:45
SymbolDefinition::binding_type binding
The binding type of the symbol where it is defined.
Definition module_collector.h:47