10#include "relocation.h"
11#include "symbol_definition.h"
12#include "symbol_name.h"
67 std::vector<std::shared_ptr<Section>> sections;
68 std::map<std::string, std::shared_ptr<Section>> section_names;
70 std::map<std::string, SymbolDefinition> global_symbols;
72 std::map<std::string, SymbolDefinition> local_symbols;
73 std::vector<SymbolName> imported_symbols;
74 std::map<ExportedSymbolName, Location> exported_symbols;
100 void SetupOptions(
char special_char, std::shared_ptr<OutputFormat> output_format, std::shared_ptr<const InputFormat> input_format);
104 char special_prefix_char =
'$';
105 std::weak_ptr<OutputFormat> output_format;
106 std::weak_ptr<const InputFormat> input_format;
109 std::string segment_prefix();
110 std::string segment_of_prefix();
111 std::string segment_at_prefix();
112 std::string with_respect_to_segment_prefix();
113 std::string segment_difference_prefix();
114 std::string import_prefix();
115 std::string segment_of_import_prefix();
116 std::string export_prefix();
117 std::string fix_byte_prefix();
120 std::string resource_prefix();
122 bool parse_imported_name(std::string reference_name,
SymbolName& symbol);
206 void AddSection(std::shared_ptr<Section> section);
209 void _AddSection(std::shared_ptr<Section> section);
215 const std::vector<std::shared_ptr<Section>>&
Sections()
const;
230 std::shared_ptr<Section>
FindSection(std::string name);
235 std::shared_ptr<Section>
FetchSection(std::string name,
unsigned default_flags);
245 void Append(std::shared_ptr<Section> dst, std::shared_ptr<Section> src);
Represents a symbol to be exported from the module.
Definition symbol_name.h:119
Represents a single offset within a section, or an absolute location in memory if the section is null...
Definition location.h:17
Helper class that collects object files and libraries, and includes library objects for required symb...
Definition module_collector.h:19
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
std::shared_ptr< Section > FindSection(std::string name)
Searches for a section with a specific name.
Definition module.cc:821
const std::vector< SymbolName > & GetImportedSymbols() const
Retrieves list of all imported symbols.
Definition module.cc:724
bool AddUndefinedSymbol(std::string symbol_name)
Processes undefined symbol for extended syntax.
Definition module.cc:504
bool AddGlobalSymbol(std::string name, Location location)
Adds and processes exported symbol for extended syntax.
Definition module.cc:235
std::vector< SymbolDefinition > symbol_sequence
Sorted collection of all symbols appearing in the module, duplicates removed.
Definition module.h:65
void Append(std::shared_ptr< Section > dst, std::shared_ptr< Section > src)
Appends two sections by shifting all symbols locations and relocation targets in the second one.
Definition module.cc:855
bool is_included
Set to true if module is included in the linking process, relevant for libraries.
Definition module.h:92
const std::vector< std::shared_ptr< Section > > & Sections() const
Retrieves list of all sections.
Definition module.cc:804
std::shared_ptr< Section > FetchSection(std::string name, unsigned default_flags)
Searches or creates a section with a specific name, with the assigned flags.
Definition module.cc:827
bool AddLocalSymbol(std::string name, Location location)
Adds an internal symbol.
Definition module.cc:203
const std::map< ExportedSymbolName, Location > & GetExportedSymbols() const
Retrieves map of all exported symbols and their locations.
Definition module.cc:729
void AddSection(std::shared_ptr< Section > section)
Adds a new section.
Definition module.cc:756
bool FindGlobalSymbol(std::string name, Location &location)
Searches for a global or weak symbol.
Definition module.cc:743
bool AddWeakSymbol(std::string name, Location location)
Adds a weakly bound symbol.
Definition module.cc:322
void RemoveSections()
Removes all sections from internal list, without deleting them.
Definition module.cc:815
void ResolveLocalRelocations()
Attempts to resolve the local targets of all relocations.
Definition module.cc:838
void AddImportedSymbol(SymbolName name)
Adds an imported symbol (Microsoft format: library name + symbol name + ordinal/hint)
Definition module.cc:491
void SetupOptions(char special_char, std::shared_ptr< OutputFormat > output_format, std::shared_ptr< const InputFormat > input_format)
Initializes the reader for linking purposes.
Definition module.cc:72
void AllocateSymbols(std::string default_section_name=".comm")
All common symbols are converted to global symbols and assigned addresses within a their section (usu...
Definition module.cc:934
cpu_type
Supported CPU types.
Definition module.h:38
bool FindLocalSymbol(std::string name, Location &location)
Searches for a local symbol.
Definition module.cc:734
void AddExportedSymbol(ExportedSymbolName name, Location symbol)
Adds an exported symbol (Microsoft format: library name + symbol name + ordinal/hint)
Definition module.cc:499
void DeleteSection(size_t index)
Deletes a specific sections.
Definition module.cc:809
std::string file_name
Stores source/destination file name.
Definition module.h:27
cpu_type cpu
Encodes the CPU for the target.
Definition module.h:63
bool AddLocalCommonSymbol(SymbolDefinition symbol)
Adds a local common symbol.
Definition module.cc:453
std::vector< Relocation > relocations
List of relocations within the module.
Definition module.h:89
void AddRelocation(Relocation relocation)
Adds and processes relocation for extended syntax.
Definition module.cc:580
bool AddCommonSymbol(SymbolDefinition symbol)
Adds a common symbol.
Definition module.cc:384
A representation of a value within some binary data that has to be fixed up once the exact position o...
Definition relocation.h:27
Represents a symbol definition.
Definition symbol_definition.h:16
Represents an (imported or internal) symbol name, which can be more complex than a string.
Definition symbol_name.h:18