RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
Linker::Module Class Reference

Encodes an object module file as a collection of sections, symbols and relocations. More...

#include <module.h>

Public Types

enum  cpu_type {
  NONE , I80 , I86 , I386 ,
  X86_64 , M6800 , M6809 , M68K ,
  MOS6502 , W65K , Z8K , PPC ,
  PPC64 , ARM , ARM64 , PDP11 ,
  MIPS , SPARC , SH
}
 Supported CPU types.
 

Public Member Functions

void SetupOptions (char special_char, std::shared_ptr< OutputFormat > output_format, std::shared_ptr< InputFormat > input_format)
 Initializes the reader for linking purposes.
 
void AddLocalSymbol (std::string name, Location location)
 Adds an internal symbol.
 
void AddGlobalSymbol (std::string name, Location location)
 Adds and processes exported symbol for extended syntax.
 
void AddCommonSymbol (std::string name, CommonSymbol symbol)
 Adds a common symbol.
 
void AddImportedSymbol (SymbolName name)
 Adds an imported symbol.
 
void AddExportedSymbol (ExportedSymbol name, Location symbol)
 Adds an exported symbol.
 
void AddUndefinedSymbol (std::string symbol_name)
 Processes undefined symbol for extended syntax.
 
void AddRelocation (Relocation relocation)
 Adds and processes relocation for extended syntax.
 
const std::vector< SymbolName > & GetImportedSymbols () const
 Retrieves list of all imported symbols.
 
const std::map< ExportedSymbol, Location > & GetExportedSymbols () const
 Retrieves map of all exported symbols and their locations.
 
bool FindLocalSymbol (std::string name, Location &location)
 Searches for a local symbol.
 
bool FindGlobalSymbol (std::string name, Location &location)
 Searches for a global symbol.
 
void AddSection (std::shared_ptr< Section > section)
 Adds a new section.
 
const std::vector< std::shared_ptr< Section > > & Sections () const
 Retrieves list of all sections.
 
void DeleteSection (size_t index)
 Deletes a specific sections.
 
void RemoveSections ()
 Removes all sections from internal list, without deleting them.
 
std::shared_ptr< SectionFindSection (std::string name)
 Searches for a section with a specific name.
 
std::shared_ptr< SectionFetchSection (std::string name, unsigned default_flags)
 Searches or creates a section with a specific name, with the assigned flags.
 
void ResolveRelocations ()
 Attempts to resolve the targets of all relocations.
 
void Append (std::shared_ptr< Section > dst, std::shared_ptr< Section > src)
 Appends two of its sections.
 
void Append (Module &other)
 Appends another module object, merging identically named sections.
 
void AllocateSymbols (std::shared_ptr< Section > section)
 All common symbols are converted to global symbols and assigned addresses within a section.
 
void AllocateSymbols ()
 All common symbols are converted to global symbols and assigned addresses within a ".comm" section.
 

Public Attributes

cpu_type cpu = NONE
 Encodes the CPU for the target.
 
std::vector< Relocationrelocations
 List of relocations within the module.
 

Detailed Description

Encodes an object module file as a collection of sections, symbols and relocations.

Member Function Documentation

◆ SetupOptions()

void Module::SetupOptions ( char special_char,
std::shared_ptr< OutputFormat > output_format,
std::shared_ptr< InputFormat > input_format )

Initializes the reader for linking purposes.

Parameters
special_charMost 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_formatThe output format that will be used. This is required to know which extra special features need to be implemented (such as segmentation).
input_formatThe input format that will be used. This is required to know which extra special features need to be implemented (such as segmentation).

The documentation for this class was generated from the following files: