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

Handles generation of a PEF binary and other files, such as a resource file. More...

#include <pefexe.h>

Inheritance diagram for Apple::PEFOutputDriver:
Apple::MacintoshOutputDriver Apple::OutputDriver Linker::OutputFormat Linker::Format Linker::Contents

Classes

class  CodeFragment
 
class  DataFork
 
class  DriverOptionCollector
 

Public Member Functions

 PEFOutputDriver (target_format_t target=TARGET_DATA_FORK)
 
 PEFOutputDriver (target_format_t target, int produce)
 
bool FormatSupportsLibraries () const override
 Whether the format supports libraries.
 
bool FormatSupportsResources () const override
 Whether the format supports resources.
 
bool FormatSupportsEntryTable () const override
 Whether the format supports a structure containing addresses of methods.
 
bool FormatSupportsTransitionVectors () const override
 Whether the format supports generating transition vectors.
 
std::shared_ptr< Linker::OptionCollector > GetOptions () override
 Returns object containing a sequence of option fields provided with the -S command line flag.
 
void SetOptions (std::map< std::string, std::string > &options) override
 Passes command line parameters as settings over to format object.
 
std::vector< Linker::OptionDescription< void > > GetMemoryModelNames () override
 Returns a list of the supported memory models, used for documentation.
 
void SetModel (std::string model) override
 Sets the way memory is organized, typically modifying a built-in script.
 
void SetLinkScript (std::string script_file, std::map< std::string, std::string > &options) override
 Selects a script file to use for linking.
 
void GenerateFile (std::string filename, Linker::Module &module) override
 The main function that handles processing, calculating and generating the final image.
 
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.
 
void ReadFile (const std::shared_ptr< Linker::Reader > &rd) override
 Loads file into memory.
 
std::string GetDefaultExtension (Linker::Module &module) const override
 Provides a default filename for the output file.
 
std::string GetDefaultExtension (Linker::Module &module, std::string filename) const override
 Appends a default extension to the filename.
 
- Public Member Functions inherited from Apple::MacintoshOutputDriver
 MacintoshOutputDriver (target_format_t target=TARGET_DATA_FORK)
 
 MacintoshOutputDriver (target_format_t target, int produce)
 
- Public Member Functions inherited from Apple::OutputDriver
void SetAppleSingleDoubleVersion (offset_t version)
 
bool AddSupplementaryOutputFormat (std::string subformat) override
 If the output format actually drives multiple output formats (resource file, apple double, etc.), specify multiple types, return false if unknown.
 
offset_t WriteFile (const std::shared_ptr< 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.
 
- Public Member Functions inherited from Linker::OutputFormat
virtual std::vector< OptionDescription< void > * > GetLinkerScriptParameterNames ()
 Returns a list of the parameters used in the linker scripts, used for documentation.
 
virtual std::vector< OptionDescription< void > > GetSpecialSymbolNames ()
 Returns a list of special symbol names recognized by the format, used for documentation.
 
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 ProcessModule (Module &object)
 Processes the module object and initializes format fields.
 
virtual bool FormatSupportsSegmentation () const
 Whether the format supports multiple segments.
 
virtual bool FormatIs16bit () const
 Whether the format is 16-bit or not.
 
virtual bool FormatIsProtectedMode () const
 Whether the format is in protected mode or not (x86 only)
 
virtual bool FormatIsLinear () const
 Whether the address space is linear or segmented.
 
virtual unsigned FormatAdditionalSectionFlags (std::string section_name) const
 
virtual void AllocateSymbols (Module &module) const
 Instructs the module to allocate any unallocated local symbols.
 
- 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 SetFileOffset (offset_t new_offset)
 Attempts to alter the offset to the first byte of the format from the beginning of the file.
 
offset_t ImageSize () const override
 Retrieves the offset of the byte after the last one belonging to this format from the first one.
 
- Public Member Functions inherited from Linker::Contents
virtual std::shared_ptr< const Image > AsImage () const
 Retrieves a randomly accessible image.
 
std::shared_ptr< Image > AsImage ()
 Retrieves a randomly accessible image.
 

Protected Member Functions

void OnContainerCreated () override
 Called after the container is created.
 
void OnReadFile (const std::shared_ptr< Linker::Reader > &rd) override
 Called if there is no container allocated.
 
offset_t OnWriteFile (const std::shared_ptr< Linker::Writer > &wr) const override
 Called if there is no container allocated.
 
void OnDump (Dumper::Dumper &dump) const override
 Called if there is no container allocated.
 
- Protected Member Functions inherited from Apple::MacintoshOutputDriver
bool SupportedSupplementaryFormat (OutputDriver::produce_format_t produce) override
 
void GenerateFiles (std::string filename, std::shared_ptr< Contents > data_fork, std::shared_ptr< Contents > resource_fork)
 Tasked to create all the requested files.
 
- Protected Member Functions inherited from Apple::OutputDriver
 OutputDriver (target_format_t target=TARGET_DATA_FORK, produce_format_t produce=produce_format_t(0))
 
void GenerateFiles (std::string filename, std::shared_ptr< Contents > data_fork, std::shared_ptr< Contents > resource_fork, uint8_t file_type, uint16_t auxiliary_file_type)
 Tasked to create all the requested files.
 

Additional Inherited Members

- Public Types inherited from Apple::MacintoshOutputDriver
enum  target_format_t {
  TARGET_NONE = OutputDriver::TARGET_NONE , TARGET_DATA_FORK = OutputDriver::TARGET_DATA_FORK , TARGET_RESOURCE_FORK = OutputDriver::TARGET_RESOURCE_FORK , TARGET_APPLE_SINGLE = OutputDriver::TARGET_APPLE_SINGLE ,
  TARGET_APPLE_DOUBLE = OutputDriver::TARGET_APPLE_DOUBLE , TARGET_MAC_BINARY = OutputDriver::TARGET_MAC_BINARY
}
 Represents the file type of the main file. More...
 
enum  produce_format_t { PRODUCE_RESOURCE_FORK = OutputDriver::PRODUCE_RESOURCE_FORK , PRODUCE_FINDER_INFO = OutputDriver::PRODUCE_FINDER_INFO , PRODUCE_APPLE_DOUBLE = OutputDriver::PRODUCE_APPLE_DOUBLE , PRODUCE_MAC_BINARY = OutputDriver::PRODUCE_MAC_BINARY }
 Represents what additional files should be generated. More...
 
- Public Types inherited from Apple::OutputDriver
enum  file_type_t : uint8_t {
  FILE_TYPE_BIN = 0x06 , FILE_TYPE_SOS = 0x0C , FILE_TYPE_S16 = 0xB3 , FILE_TYPE_EXE = 0xB5 ,
  FILE_TYPE_SYS = 0xFF
}
 
- Public Attributes inherited from Apple::MacintoshOutputDriver
std::shared_ptr< MacintoshResourceFileFormat > resource_fork
 
- Public Attributes inherited from Apple::OutputDriver
target_format_t target
 Format of "filename".
 
produce_format_t produce
 Bitset of other files to produce.
 
unsigned apple_single_double_version = 2
 
Apple::AppleSingleDouble::hfs_type home_file_system = Apple::AppleSingleDouble::HFS_UNDEFINED
 
MacBinary::version_t macbinary_version = MacBinary::MACBIN3
 
MacBinary::version_t macbinary_minimum_version = MacBinary::MACBIN2
 
- Public Attributes inherited from Linker::Format
offset_t file_offset
 The offset of the first byte used by this format in the file it is stored in.
 
- Protected Types inherited from Apple::OutputDriver
enum  target_format_t {
  TARGET_NONE , TARGET_DATA_FORK , TARGET_RESOURCE_FORK , TARGET_APPLE_SINGLE ,
  TARGET_APPLE_DOUBLE , TARGET_MAC_BINARY
}
 Represents the file type of the main file. More...
 
enum  produce_format_t {
  PRODUCE_RESOURCE_FORK = 1 << 0 , PRODUCE_FINDER_INFO = 1 << 1 , PRODUCE_APPLE_DOUBLE = 1 << 2 , PRODUCE_MAC_BINARY = 1 << 3 ,
  PRODUCE_NAPS_SUFFIX = 1 << 4
}
 Represents what additional files should be generated. More...
 
enum  container_format_t { CONTAINER_NONE , CONTAINER_APPLE_SINGLE , CONTAINER_MAC_BINARY }
 Format of container stored in memory. More...
 
- Protected Attributes inherited from Apple::OutputDriver
container_format_t container = CONTAINER_NONE
 The container type used to store metainformation while processing.
 
std::shared_ptr< Apple::AppleSingleDouble > apple_single
 Container for all the necessary additional information.
 
std::shared_ptr< MacBinary > mac_binary
 Container for MacBinary (Macintosh only)
 

Detailed Description

Handles generation of a PEF binary and other files, such as a resource file.

Member Function Documentation

◆ CalculateValues()

void PEFOutputDriver::CalculateValues ( )
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 Apple::OutputDriver.

◆ FormatSupportsEntryTable()

bool PEFOutputDriver::FormatSupportsEntryTable ( ) const
overridevirtual

Whether the format supports a structure containing addresses of methods.

Formats such as NE, LE/LX and the Macintosh classic support an ordinal table or jump table that contains the addresses of certain methods.

Reimplemented from Linker::OutputFormat.

◆ FormatSupportsLibraries()

bool PEFOutputDriver::FormatSupportsLibraries ( ) const
overridevirtual

Whether the format supports libraries.

Reimplemented from Linker::OutputFormat.

◆ FormatSupportsResources()

bool PEFOutputDriver::FormatSupportsResources ( ) const
overridevirtual

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 from Linker::OutputFormat.

◆ FormatSupportsTransitionVectors()

bool PEFOutputDriver::FormatSupportsTransitionVectors ( ) const
overridevirtual

Whether the format supports generating transition vectors.

Transition vectors are a structure containing the address of a procedure alongside the address of the start of a data area. 68K based software calls this the A5 world, accessed via the A5 register, PowerPC based software calls this the TOC or Table of Contents, accessed via GPR2.

Reimplemented from Linker::OutputFormat.

◆ GenerateFile()

void PEFOutputDriver::GenerateFile ( std::string  filename,
Linker::Module &  module 
)
overridevirtual

The main function that handles processing, calculating and generating the final image.

Reimplemented from Linker::OutputFormat.

◆ GetDefaultExtension() [1/2]

std::string PEFOutputDriver::GetDefaultExtension ( Linker::Module &  module) const
overridevirtual

Provides a default filename for the output file.

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

Reimplemented from Linker::OutputFormat.

◆ GetDefaultExtension() [2/2]

std::string PEFOutputDriver::GetDefaultExtension ( Linker::Module &  module,
std::string  filename 
) const
overridevirtual

Appends a default extension to the filename.

A typical behavior would be to append .exe at the end of the filename. The default action is to leave it intact.

Reimplemented from Linker::OutputFormat.

◆ GetMemoryModelNames()

std::vector< Linker::OptionDescription< void > > PEFOutputDriver::GetMemoryModelNames ( )
overridevirtual

Returns a list of the supported memory models, used for documentation.

Reimplemented from Linker::OutputFormat.

◆ GetOptions()

std::shared_ptr< Linker::OptionCollector > PEFOutputDriver::GetOptions ( )
overridevirtual

Returns object containing a sequence of option fields provided with the -S command line flag.

Reimplemented from Linker::OutputFormat.

◆ OnContainerCreated()

void PEFOutputDriver::OnContainerCreated ( )
overrideprotectedvirtual

Called after the container is created.

Reimplemented from Apple::OutputDriver.

◆ OnDump()

void PEFOutputDriver::OnDump ( Dumper::Dumper &  dump) const
overrideprotectedvirtual

Called if there is no container allocated.

Reimplemented from Apple::OutputDriver.

◆ OnReadFile()

void PEFOutputDriver::OnReadFile ( const std::shared_ptr< Linker::Reader > &  rd)
overrideprotectedvirtual

Called if there is no container allocated.

Reimplemented from Apple::OutputDriver.

◆ OnWriteFile()

offset_t PEFOutputDriver::OnWriteFile ( const std::shared_ptr< Linker::Writer > &  wr) const
overrideprotectedvirtual

Called if there is no container allocated.

Reimplemented from Apple::OutputDriver.

◆ ReadFile()

void PEFOutputDriver::ReadFile ( const std::shared_ptr< Linker::Reader > &  rd)
overridevirtual

Loads file into memory.

Reimplemented from Apple::OutputDriver.

◆ SetLinkScript()

void PEFOutputDriver::SetLinkScript ( std::string  script_file,
std::map< std::string, std::string > &  options 
)
overridevirtual

Selects a script file to use for linking.

Reimplemented from Linker::OutputFormat.

◆ SetModel()

void PEFOutputDriver::SetModel ( std::string  model)
overridevirtual

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

Reimplemented from Linker::OutputFormat.

◆ SetOptions()

void PEFOutputDriver::SetOptions ( std::map< std::string, std::string > &  options)
overridevirtual

Passes command line parameters as settings over to format object.

Reimplemented from Linker::OutputFormat.


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