RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
|
Helper class that collects object files and libraries, and includes library objects for required symbols. More...
#include <module_collector.h>
Classes | |
struct | definition |
Description of a symbol definition in some module. More... | |
Public Member Functions | |
void | SetupOptions (char special_char, std::shared_ptr< OutputFormat > output_format) |
Initializes the reader for linking purposes. | |
std::shared_ptr< Module > | CreateModule (std::shared_ptr< const InputFormat > input_format, std::string file_name="") |
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 additional modules need to be included. | |
void | AddLibraryModule (std::shared_ptr< Module > module) |
Convenience method to add a library. | |
void | CombineModulesInto (Module &output_module) |
Appends all the modules that have been determined to be included, into a resulting object. | |
Public Attributes | |
bool | generate_got = false |
Set to true when Global Offset Table generation is requested. | |
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 binary. | |
std::set< std::string > | required_symbols |
Symbols that are referenced but have not yet been defined among the included modules. | |
std::map< std::string, definition > | symbol_definitions |
Collection of symbols defined thus far. | |
Helper class that collects object files and libraries, and includes library objects for required symbols.
Object and library modules can both be added to the collector, which determines which ones need to be part of the final binary object.
void ModuleCollector::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 additional modules need to be included.
Non-library modules are automatically included in the final binary, library modules are only included on demand.
void ModuleCollector::SetupOptions | ( | char | special_char, |
std::shared_ptr< OutputFormat > | output_format ) |
Initializes the reader for linking purposes.
special_char | Most input formats do not provide support for the special requirements of the output format (such as segmentation for ELF). We work around this by introducing special name prefixes $$SEGOF$ where $ is the value of special_char. |
output_format | The output format that will be used. This is required to know which extra special features need to be implemented (such as segmentation). |
std::set<std::string> Linker::ModuleCollector::required_symbols |
Symbols that are referenced but have not yet been defined among the included modules.
When a symbol that appears in this collection is defined in a module, that modules gets included automatically.
std::map<std::string, definition> Linker::ModuleCollector::symbol_definitions |
Collection of symbols defined thus far.
When a module gets added to the collector, its definition is stored in this collection.