RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
|
ELF object and executable format. More...
#include <elf.h>
Classes | |
class | Array |
class | Block |
class | DynamicObject |
class | DynamicSection |
class | HashTable |
struct | HobbitBeOSResource |
Resources for the prototype BeOS Development Release for the AT&T Hobbit. More... | |
class | IBMExportEntry |
class | IBMExportTable |
class | IBMImportEntry |
class | IBMImportTable |
class | IBMResource |
class | IBMResourceCollection |
class | IBMSystemInfo |
class | IndexArray |
class | Note |
class | NotesSection |
class | Relocation |
class | Relocations |
class | Section |
class | SectionContents |
class | SectionGroup |
class | Segment |
class | StringTable |
class | Symbol |
class | SymbolTable |
class | VersionRequirement |
class | VersionRequirements |
Public Member Functions | |
void | ReadFile (Linker::Reader &rd) override |
Loads file into memory. | |
offset_t | WriteFile (Linker::Writer &wr) const override |
Stores data in memory to file. | |
void | Dump (Dumper::Dumper &dump) const override |
Display file contents in a nice manner. | |
bool | IsOldOS2Format () const |
Attempts to heuristically determine if it is in a beta OS/2 format. | |
void | SetupOptions (std::shared_ptr< Linker::OutputFormat > format) override |
Initializes the reader for linking purposes. | |
void | GenerateModule (Linker::Module &module) const override |
Loads the information into a module object, a convenience method when there is a single module generated. | |
void | CalculateValues () override |
Intermediate step between processing module and generating output file to set up headers and management sections It is expected that after a module is processed, additional steps are required to evaluate the final values of the fields. | |
![]() | |
virtual void | ProduceModule (ModuleCollector &linker, Reader &rd, std::string file_name) |
Reads a file and loads the information into a module object. | |
virtual void | ProduceModule (Module &module, Reader &rd) |
Reads a file and loads the information into a module object, a convenience method when there is a single module generated. | |
virtual void | GenerateModule (ModuleCollector &linker, std::string file_name, bool is_library=false) const |
Loads the information into a module object. | |
virtual bool | FormatProvidesSegmentation () const |
Whether the format enables multiple x86 segments. | |
virtual bool | FormatRequiresDataStreamFix () const |
Whether the generated file might contain bugs that require fixing. | |
virtual bool | FormatProvidesResources () const |
Whether the format supports resources. | |
virtual bool | FormatProvidesLibraries () const |
Whether the format enables importing/exporting libraries. | |
![]() | |
Format (offset_t file_offset=0) | |
virtual void | Clear () |
Resets all fields to their default values, deallocate memory. | |
offset_t | ImageSize () const override |
Retrieves size of stored data. | |
offset_t | WriteFile (Writer &wr, offset_t count, offset_t offset=0) const override |
Writes data of non-zero filled sections. | |
![]() | |
virtual std::shared_ptr< const ActualImage > | AsImage () const |
Retrieves a randomly accessible image. | |
std::shared_ptr< ActualImage > | AsImage () |
Retrieves a randomly accessible image. | |
![]() | |
void | ClearSegmentManager () |
void | SetLinkScript (std::string script_file, std::map< std::string, std::string > &options) override |
Sets up the linker script and linker parameters. | |
std::unique_ptr< Script::List > | GetScript (Module &module) |
Compiles the linker script into an internal format. | |
offset_t | GetCurrentAddress () const |
Retrieves current address pointer. | |
void | SetCurrentAddress (offset_t address) |
Moves the current address pointer further, and if the current segment already contains data, fill it up to the point. | |
void | AlignCurrentAddress (offset_t align) |
Aligns current address to alignment, using SetCurrentAddress. | |
void | SetLatestBase (offset_t address) |
Sets the base of the current section (the value from which offsets are counted from) | |
void | FinishCurrentSegment () |
Closes the current segment, sets current_segment to null. | |
virtual void | OnNewSegment (std::shared_ptr< Segment > segment) |
Callback function when allocating a new segment When the linker script runs, it creates segments consecutively. Overriding this method permits the output format to handle the allocated segment. | |
std::shared_ptr< Segment > | AppendSegment (std::string name) |
Terminates the current segment (if there is one), creates a new segment and attaches it to the image. | |
std::shared_ptr< Segment > | FetchSegment (std::string name) |
Attempts to fetch a segment, returns null if not found. | |
void | AppendSection (std::shared_ptr< Section > section) |
Adds a new section to the current segment, sets the base to the same as the segment. | |
void | ProcessScript (std::unique_ptr< Script::List > &directives, Module &module) |
Executes a parsed linker script on a module and collects segments The function OnNewSegment can be defined to handle each newly allocated segment. | |
void | ProcessAction (std::unique_ptr< Script::Node > &action, Module &module) |
void | PostProcessAction (std::unique_ptr< Script::Node > &action, Module &module) |
void | ProcessCommand (std::unique_ptr< Script::Node > &command, Module &module) |
bool | CheckPredicate (std::unique_ptr< Script::Node > &predicate, std::shared_ptr< Section > section, Module &module) |
offset_t | EvaluateExpression (std::unique_ptr< Script::Node > &expression, Module &module) |
![]() | |
virtual bool | AddSupplementaryOutputFormat (std::string subformat) |
If the output format actually drives multiple output formats (resource file, apple double, etc.), specify multiple types, return false if unknown. | |
virtual void | SetOptions (std::map< std::string, std::string > &options) |
Passes command line parameters as settings over to format object. | |
std::optional< std::string > | FetchOption (std::map< std::string, std::string > &options, std::string name) |
Convenience method to look up option by name. | |
std::string | FetchOption (std::map< std::string, std::string > &options, std::string name, std::string default_value) |
Convenience method to look up option by name, returning default value if name is missing. | |
std::optional< offset_t > | FetchIntegerOption (std::map< std::string, std::string > &options, std::string name) |
Convenience method to look up option by name and convert it to integer. | |
virtual void | SetModel (std::string model) |
Sets the way memory is organized, typically modifying a built-in script. | |
virtual void | ProcessModule (Module &object) |
Processes the module object and initializes format fields. | |
virtual void | GenerateFile (std::string filename, Module &module) |
The main function that handles processing, calculating and generating the final image. | |
virtual std::string | GetDefaultExtension (Module &module, std::string filename) const |
Appends a default extension to the filename. | |
virtual std::string | GetDefaultExtension (Module &module) const |
Provides a default filename for the output file. | |
virtual bool | FormatSupportsSegmentation () const |
Whether the format supports multiple segments. | |
virtual bool | FormatIs16bit () const |
Whether the format is 16-bit or not. | |
virtual bool | FormatIsLinear () const |
Whether the address space is linear or segmented. | |
virtual bool | FormatSupportsResources () const |
Whether the format supports resources. | |
virtual bool | FormatSupportsLibraries () const |
Whether the format supports libraries. | |
virtual unsigned | FormatAdditionalSectionFlags (std::string section_name) const |
Public Attributes | |
offset_t | file_offset = 0 |
uint8_t | file_class = 0 |
EndianType | endiantype = ::LittleEndian |
uint8_t | data_encoding = 0 |
size_t | wordbytes = 4 |
cpu_type | cpu = EM_NONE |
uint8_t | header_version = 0 |
uint8_t | osabi = 0 |
uint8_t | abi_version = 0 |
file_type | object_file_type = ET_NONE |
uint16_t | file_version = 0 |
offset_t | entry = 0 |
offset_t | program_header_offset = 0 |
offset_t | section_header_offset = 0 |
uint32_t | flags = 0 |
uint16_t | elf_header_size = 0 |
uint16_t | program_header_entry_size = 0 |
uint16_t | section_header_entry_size = 0 |
uint16_t | section_name_string_table = 0 |
std::vector< Section > | sections |
std::vector< Segment > | segments |
std::vector< Block > | blocks |
Collection of blocks of data that do not belong to any section. | |
offset_t | hobbit_beos_resource_offset = 0 |
std::vector< HobbitBeOSResource > | hobbit_beos_resources |
bool | option_16bit = true |
bool | option_linear = false |
![]() | |
offset_t | file_offset |
![]() | |
offset_t | current_base = 0 |
The base address of the current section. | |
std::vector< std::shared_ptr< Segment > > | segment_vector |
Ordered sequence of segments. | |
std::map< std::string, std::shared_ptr< Segment > > | segment_map |
Map of segments from their names. | |
std::shared_ptr< Segment > | current_segment |
Currently processed segment. | |
std::map< std::string, Location > | linker_parameters |
Parameters that permit customizing the linker script. | |
std::string | linker_script |
Contents of the linker script. | |
Static Public Attributes | |
static constexpr uint8_t | EI_OSABI = 7 |
static constexpr uint8_t | EI_ABIVERSION = 8 |
static constexpr uint8_t | EI_CLASS = 4 |
static constexpr uint8_t | EI_DATA = 5 |
static constexpr uint8_t | ELFCLASSNONE = 0 |
static constexpr uint8_t | ELFCLASS32 = 1 |
static constexpr uint8_t | ELFCLASS64 = 2 |
static constexpr uint8_t | ELFDATANONE = 0 |
static constexpr uint8_t | ELFDATA2LSB = 1 |
static constexpr uint8_t | ELFDATA2MSB = 2 |
static constexpr uint8_t | EV_NONE = 0 |
static constexpr uint8_t | EV_CURRENT = 1 |
static constexpr uint8_t | ELFOSABI_NONE = 0 |
static constexpr offset_t | SHF_WRITE = 0x0001 |
static constexpr offset_t | SHF_ALLOC = 0x0002 |
static constexpr offset_t | SHF_EXECINSTR = 0x0004 |
static constexpr offset_t | SHF_MERGE = 0x0010 |
static constexpr offset_t | SHF_STRINGS = 0x0020 |
static constexpr offset_t | SHF_INFO_LINK = 0x0040 |
static constexpr offset_t | SHF_LINK_ORDER = 0x0080 |
static constexpr offset_t | SHF_OS_NONCONFORMING = 0x0100 |
static constexpr offset_t | SHF_GROUP = 0x0200 |
static constexpr offset_t | SHF_TLS = 0x0400 |
static constexpr offset_t | SHF_COMPRESSED = 0x0800 |
static constexpr offset_t | SHF_GNU_RETAIN = 0x00200000 |
static constexpr offset_t | SHF_GNU_MBIND = 0x01000000 |
static constexpr offset_t | SHF_EXCLUDE = 0x80000000 |
static constexpr offset_t | SHF_BEGIN = 0x01000000 |
static constexpr offset_t | SHF_END = 0x02000000 |
static constexpr uint16_t | SHN_UNDEF = 0 |
static constexpr uint16_t | SHN_LORESERVE = 0xFF00 |
static constexpr uint16_t | SHN_ABS = 0xFFF1 |
static constexpr uint16_t | SHN_COMMON = 0xFFF2 |
static constexpr uint16_t | SHN_XINDEX = 0xFFFF |
static constexpr uint8_t | STB_LOCAL = 0 |
static constexpr uint8_t | STB_GLOBAL = 1 |
static constexpr uint8_t | STB_WEAK = 2 |
static constexpr uint8_t | STB_ENTRY = 12 |
static constexpr uint8_t | STT_NOTYPE = 0 |
static constexpr uint8_t | STT_OBJECT = 1 |
static constexpr uint8_t | STT_FUNC = 2 |
static constexpr uint8_t | STT_SECTION = 3 |
static constexpr uint8_t | STT_FILE = 4 |
static constexpr uint8_t | STT_COMMON = 5 |
static constexpr uint8_t | STT_TLS = 6 |
static constexpr uint8_t | STT_IMPORT = 11 |
static constexpr uint8_t | STV_DEFAULT = 0 |
static constexpr uint8_t | STV_INTERNAL = 1 |
static constexpr uint8_t | STV_HIDDEN = 2 |
static constexpr uint8_t | STV_PROTECTED = 3 |
static constexpr offset_t | R_386_8 = 22 |
static constexpr offset_t | R_386_PC8 = 23 |
static constexpr offset_t | R_386_16 = 20 |
static constexpr offset_t | R_386_PC16 = 21 |
static constexpr offset_t | R_386_32 = 1 |
static constexpr offset_t | R_386_PC32 = 2 |
static constexpr offset_t | R_386_SEG16 = 45 |
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup.md (not yet implemented) | |
static constexpr offset_t | R_386_SUB16 = 46 |
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup.md (not yet implemented) | |
static constexpr offset_t | R_386_SUB32 = 47 |
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup.md (not yet implemented) | |
static constexpr offset_t | R_386_SEGRELATIVE = 48 |
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup.md (not yet implemented) | |
static constexpr offset_t | R_386_OZSEG16 = 80 |
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup.md (not yet implemented) | |
static constexpr offset_t | R_386_OZRELSEG16 = 81 |
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup.md (not yet implemented) | |
static constexpr offset_t | R_68K_8 = 3 |
static constexpr offset_t | R_68K_PC8 = 6 |
static constexpr offset_t | R_68K_16 = 2 |
static constexpr offset_t | R_68K_PC16 = 5 |
static constexpr offset_t | R_68K_32 = 1 |
static constexpr offset_t | R_68K_PC32 = 4 |
static constexpr offset_t | R_ARM_ABS8 = 8 |
static constexpr offset_t | R_ARM_ABS16 = 16 |
static constexpr offset_t | R_ARM_ABS32 = 2 |
static constexpr offset_t | R_ARM_REL32 = 3 |
static constexpr offset_t | R_ARM_CALL = 28 |
static constexpr offset_t | R_ARM_JUMP24 = 29 |
static constexpr offset_t | R_ARM_PC24 = 1 |
static constexpr offset_t | R_ARM_V4BX = 40 |
static constexpr offset_t | DT_NULL = 0 |
static constexpr offset_t | DT_NEEDED = 1 |
static constexpr offset_t | DT_PLTRELSZ = 2 |
static constexpr offset_t | DT_PLTGOT = 3 |
static constexpr offset_t | DT_HASH = 4 |
static constexpr offset_t | DT_STRTAB = 5 |
static constexpr offset_t | DT_SYMTAB = 6 |
static constexpr offset_t | DT_RELA = 7 |
static constexpr offset_t | DT_RELASZ = 8 |
static constexpr offset_t | DT_RELAENT = 9 |
static constexpr offset_t | DT_STRSZ = 10 |
static constexpr offset_t | DT_SYMENT = 11 |
static constexpr offset_t | DT_INIT = 12 |
static constexpr offset_t | DT_FINI = 13 |
static constexpr offset_t | DT_SONAME = 14 |
static constexpr offset_t | DT_RPATH = 15 |
static constexpr offset_t | DT_SYMBOLIC = 16 |
static constexpr offset_t | DT_REL = 17 |
static constexpr offset_t | DT_RELSZ = 18 |
static constexpr offset_t | DT_RELENT = 19 |
static constexpr offset_t | DT_PLTREL = 20 |
static constexpr offset_t | DT_DEBUG = 21 |
static constexpr offset_t | DT_TEXTREL = 22 |
static constexpr offset_t | DT_JMPREL = 23 |
static constexpr offset_t | DT_BIND_NOW = 24 |
static constexpr offset_t | DT_INIT_ARRAY = 25 |
static constexpr offset_t | DT_FINI_ARRAY = 26 |
static constexpr offset_t | DT_INIT_ARRAYSZ = 27 |
static constexpr offset_t | DT_FINI_ARRAYSZ = 28 |
static constexpr offset_t | DT_RUNPATH = 29 |
static constexpr offset_t | DT_FLAGS = 30 |
static constexpr offset_t | DT_ENCODING = 31 |
static constexpr offset_t | DT_PREINIT_ARRAY = 32 |
static constexpr offset_t | DT_PREINIT_ARRAYSZ = 33 |
static constexpr offset_t | DT_SYMTAB_SHNDX = 34 |
static constexpr offset_t | DT_RELRSZ = 35 |
static constexpr offset_t | DT_RELR = 36 |
static constexpr offset_t | DT_RELRENT = 37 |
static constexpr offset_t | DT_EXPORT = 0x60000001 |
static constexpr offset_t | DT_EXPORTSZ = 0x60000002 |
static constexpr offset_t | DT_EXPENT = 0x60000003 |
static constexpr offset_t | DT_IMPORT = 0x60000004 |
static constexpr offset_t | DT_IMPORTSZ = 0x60000005 |
static constexpr offset_t | DT_IMPENT = 0x60000006 |
static constexpr offset_t | DT_IT = 0x60000007 |
static constexpr offset_t | DT_ITPRTY = 0x60000008 |
static constexpr offset_t | DT_INITTERM = 0x60000009 |
static constexpr offset_t | DT_STACKSZ = 0x6000000A |
static constexpr offset_t | DT_GNU_FLAGS1 = 0x6FFFFDF4 |
static constexpr offset_t | DT_GNU_PRELINKED = 0x6FFFFDF5 |
static constexpr offset_t | DT_GNU_CONFLICTSZ = 0x6FFFFDF6 |
static constexpr offset_t | DT_GNU_LIBLISTSZ = 0x6FFFFDF7 |
static constexpr offset_t | DT_CHECKSUM = 0x6FFFFDF8 |
static constexpr offset_t | DT_PLTPADSZ = 0x6FFFFDF9 |
static constexpr offset_t | DT_MOVEENT = 0x6FFFFDFA |
static constexpr offset_t | DT_MOVESZ = 0x6FFFFDFB |
static constexpr offset_t | DT_FEATURE = 0x6FFFFDFC |
static constexpr offset_t | DT_POSTFLAG_1 = 0x6FFFFDFD |
static constexpr offset_t | DT_SYMINSZ = 0x6FFFFDFE |
static constexpr offset_t | DT_SYMINENT = 0x6FFFFDFF |
static constexpr offset_t | DT_GNU_HASH = 0x6FFFFEF5 |
static constexpr offset_t | DT_TLSDESC_PLT = 0x6FFFFEF6 |
static constexpr offset_t | DT_TLSDESC_GOT = 0x6FFFFEF7 |
static constexpr offset_t | DT_GNU_CONFLICT = 0x6FFFFFEF8 |
static constexpr offset_t | DT_GNU_LIBLIST = 0x6FFFFEF9 |
static constexpr offset_t | DT_CONFIG = 0x6FFFFEFA |
static constexpr offset_t | DT_DEPAUDIT = 0x6FFFFEFB |
static constexpr offset_t | DT_AUDIT = 0x6FFFFEFC |
static constexpr offset_t | DT_PLTPAD = 0x6FFFFEFD |
static constexpr offset_t | DT_MOVETAB = 0x6FFFFEFE |
static constexpr offset_t | DT_SYMINFO = 0x6FFFFEFF |
static constexpr offset_t | DT_VERSYM = 0x6FFFFFF0 |
static constexpr offset_t | DT_RELACOUNT = 0x6FFFFFF9 |
static constexpr offset_t | DT_RELCOUNT = 0x6FFFFFFA |
static constexpr offset_t | DT_FLAGS_1 = 0x6FFFFFFB |
static constexpr offset_t | DT_VERDEF = 0x6FFFFFFC |
static constexpr offset_t | DT_VERDEFNUM = 0x6FFFFFFD |
static constexpr offset_t | DT_VERNEED = 0x6FFFFFFE |
static constexpr offset_t | DT_VERNEEDNUM = 0x6FFFFFFF |
static constexpr offset_t | DT_AUXILIARY = 0x7FFFFFFD |
static constexpr offset_t | DT_USED = 0x7FFFFFFE |
static constexpr offset_t | DT_FILTER = 0x7FFFFFFFF |
Additional Inherited Members | |
![]() | |
offset_t | current_address = 0 |
Holds the current address value when there is no current_segment. | |
bool | current_is_template = false |
bool | current_is_template_head = false |
offset_t | template_counter = 0 |
std::string | current_template_name |
ELF object and executable format.
The latest and most widespread file format, developed for the UNIX operating system.
|
overridevirtual |
Intermediate step between processing module and generating output file to set up headers and management sections It is expected that after a module is processed, additional steps are required to evaluate the final values of the fields.
Reimplemented from Linker::OutputFormat.
|
overridevirtual |
Display file contents in a nice manner.
Reimplemented from Linker::Format.
|
overridevirtual |
Loads the information into a module object, a convenience method when there is a single module generated.
Reimplemented from Linker::InputFormat.
|
overridevirtual |
Loads file into memory.
Implements Linker::Format.
|
overridevirtual |
Initializes the reader for linking purposes.
format | The output format that will be used. This is required to know which extra special features need to be implemented (such as segmentation). |
Reimplemented from Linker::InputFormat.
|
overridevirtual |
Stores data in memory to file.
Implements Linker::Format.