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

A class that provides a general interface to setting up generation for a format. More...

#include <format.h>

Inheritance diagram for Linker::OutputFormat:
Linker::Format AOut::AOutFormat Amiga::HunkFormat Apple::AppleSingleDouble Apple::MacDriver Apple::OMFFormat Apple::PEFFormat Apple::ResourceFork Apple::ResourceFork::Resource Binary::GenericBinaryFormat COFF::COFFFormat DOS16M::BWFormat DigitalResearch::CPM68KFormat DigitalResearch::CPM86Format DigitalResearch::CPM8KFormat ELF::ELFFormat Ergo::XPFormat GEOS::GeodeFormat MINIX::MINIXFormat MachO::MachOFormat Microsoft::LEFormat Microsoft::MZFormat Microsoft::NEFormat PMODE::PMW1Format PharLap::MPFormat PharLap::P3Format SeychellDOS32::AdamFormat X68000::HUFormat Xenix::BOutFormat Xenix::XOutFormat

Public Member Functions

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 SetLinkScript (std::string script_file, std::map< std::string, std::string > &options)
 Selects a script file to use for linking.
 
virtual void ProcessModule (Linker::Module &object)
 Processes the module object and initializes format fields.
 
virtual void CalculateValues ()
 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 GenerateFile (std::string filename, Linker::Module &module)
 The main function that handles processing, calculating and generating the final image.
 
virtual std::string GetDefaultExtension (Linker::Module &module, std::string filename)
 Appends a default extension to the filename.
 
virtual std::string GetDefaultExtension (Linker::Module &module)
 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 Member Functions inherited from Linker::Format
 Format (offset_t file_offset=0)
 
virtual void Clear ()
 Resets all fields to their default values, deallocate memory.
 
virtual void ReadFile (Reader &in)=0
 Loads file into memory.
 
virtual void WriteFile (Writer &out)=0
 Stores data in memory to file.
 
virtual void Dump (Dumper::Dumper &dump)
 Display file contents in a nice manner.
 

Additional Inherited Members

- Public Attributes inherited from Linker::Format
offset_t file_offset
 

Detailed Description

A class that provides a general interface to setting up generation for a format.

Member Function Documentation

◆ AddSupplementaryOutputFormat()

bool OutputFormat::AddSupplementaryOutputFormat ( std::string subformat)
virtual

If the output format actually drives multiple output formats (resource file, apple double, etc.), specify multiple types, return false if unknown.

Reimplemented in Apple::MacDriver.

◆ CalculateValues()

void OutputFormat::CalculateValues ( )
virtual

◆ FormatIs16bit()

bool OutputFormat::FormatIs16bit ( ) const
virtual

Whether the format is 16-bit or not.

This is needed for the ELF parser which can not distinguish between the 8086 and 80386 backends.

Reimplemented in Binary::BinaryFormat, DOS16M::BWFormat, DigitalResearch::CPM86Format, MINIX::MINIXFormat, Microsoft::MZFormat, and Microsoft::NEFormat.

◆ FormatIsLinear()

bool OutputFormat::FormatIsLinear ( ) const
virtual

Whether the address space is linear or segmented.

This is needed to determine whether symbol relocations are absolute addresses or offsets within their own segments. Typically, Intel 8086 backends are non-linear, the others are linear.

◆ FormatSupportsLibraries()

bool OutputFormat::FormatSupportsLibraries ( ) const
virtual

Whether the format supports libraries.

Reimplemented in Microsoft::LEFormat, and Microsoft::NEFormat.

◆ FormatSupportsResources()

bool OutputFormat::FormatSupportsResources ( ) const
virtual

Whether the format supports resources.

Formats such as NE, LE/LX, PE and the Macintosh classic support including resources in the final binary. To simplify writing resources, the ELF parser permits incorporating them directly in the binary image as $$RSRC$_<type>$<id>.

Reimplemented in Apple::AppleSingleDouble, Apple::ResourceFork, and Apple::MacDriver.

◆ FormatSupportsSegmentation()

bool OutputFormat::FormatSupportsSegmentation ( ) const
virtual

Whether the format supports multiple segments.

This is typically true for Intel 8086 targets and false for non-Intel targets. The ELF parser uses this to provide extended relocations, including the following:

  • $$SEG$<section name>
  • $$SEGOF$<symbol name>
  • $$SEGAT$<symbol name>
  • $$WRTSEG$<symbol name>$<section name>
  • $$SEGDIF$<section name>$<section name>

Reimplemented in Binary::BinaryFormat, DOS16M::BWFormat, DigitalResearch::CPM86Format, DigitalResearch::CPM8KFormat, Microsoft::LEFormat, Microsoft::MZFormat, Microsoft::NEFormat, and PharLap::P3Format.

◆ GenerateFile()

void OutputFormat::GenerateFile ( std::string filename,
Linker::Module & module )
virtual

◆ GetDefaultExtension() [1/2]

virtual std::string Linker::OutputFormat::GetDefaultExtension ( Linker::Module & module)
virtual

Provides a default filename for the output file.

Typically a.out or some other extension, such as a.exe.

Reimplemented in Binary::UZIFormat, Binary::UZI280Format, AOut::AOutFormat, Amiga::HunkFormat, Apple::AppleSingleDouble, Apple::ResourceFork, and MINIX::MINIXFormat.

◆ GetDefaultExtension() [2/2]

virtual std::string Linker::OutputFormat::GetDefaultExtension ( Linker::Module & module,
std::string filename )
virtual

◆ ProcessModule()

void OutputFormat::ProcessModule ( Linker::Module & object)
virtual

◆ SetLinkScript()

void OutputFormat::SetLinkScript ( std::string script_file,
std::map< std::string, std::string > & options )
virtual

Selects a script file to use for linking.

Reimplemented in Apple::AppleSingleDouble, and Apple::MacDriver.

◆ SetModel()

void OutputFormat::SetModel ( std::string model)
virtual

Sets the way memory is organized, typically modifying a built-in script.

Reimplemented in Binary::BinaryFormat, DigitalResearch::CPM86Format, Apple::AppleSingleDouble, Apple::ResourceFork, Apple::MacDriver, Microsoft::MZFormat, and Microsoft::NEFormat.

◆ SetOptions()

void OutputFormat::SetOptions ( std::map< std::string, std::string > & options)
virtual

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