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
Apple::MacDriver Class Reference

This is not actually a file format, but an interface to permit generating multiple binary outputs for Macintosh executables. More...

#include <macos.h>

Inheritance diagram for Apple::MacDriver:
Linker::OutputFormat Linker::Format

Public Types

enum  target_format_t { TARGET_NONE , TARGET_DATA_FORK , TARGET_RESOURCE_FORK , TARGET_APPLE_SINGLE }
 
enum  produce_format_t { PRODUCE_RESOURCE_FORK = 1 << 0 , PRODUCE_FINDER_INFO = 1 << 1 , PRODUCE_APPLE_DOUBLE = 1 << 2 , PRODUCE_MAC_BINARY = 1 << 3 }
 

Public Member Functions

 MacDriver (target_format_t target=TARGET_DATA_FORK)
 
 MacDriver (target_format_t target, int produce)
 
bool FormatSupportsResources () const override
 Whether the format supports resources.
 
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.
 
void SetOptions (std::map< std::string, std::string > &options) override
 Passes command line parameters as settings over to format object.
 
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 ReadFile (Linker::Reader &rd) override
 Loads file into memory.
 
void WriteFile (Linker::Writer &wr) override
 Stores data in memory to file.
 
- Public Member Functions inherited from Linker::OutputFormat
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 (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 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 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 Dump (Dumper::Dumper &dump)
 Display file contents in a nice manner.
 

Public Attributes

target_format_t target
 
produce_format_t produce
 
unsigned apple_single_double_version = 2
 
AppleSingleDouble::hfs_type home_file_system = 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
 

Detailed Description

This is not actually a file format, but an interface to permit generating multiple binary outputs for Macintosh executables.

This class is needed because Macintosh executables require utilization of the resource fork, a part of the filesystem which is generally unavailable on other platforms. There are multiple ways to represent the resource fork on a non-Macintosh file system, including a separate file, an AppleSingle/AppleDouble container or a MacBinary file. This driver permits generation of one or more of these different formats for the same executable.

Member Function Documentation

◆ AddSupplementaryOutputFormat()

bool MacDriver::AddSupplementaryOutputFormat ( std::string subformat)
overridevirtual

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

Reimplemented from Linker::OutputFormat.

◆ FormatSupportsResources()

bool MacDriver::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.

◆ GenerateFile()

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

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

Reimplemented from Linker::OutputFormat.

◆ ReadFile()

void MacDriver::ReadFile ( Linker::Reader & in)
overridevirtual

Loads file into memory.

Implements Linker::Format.

◆ SetLinkScript()

void MacDriver::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 MacDriver::SetModel ( std::string model)
overridevirtual

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

Reimplemented from Linker::OutputFormat.

◆ SetOptions()

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

Passes command line parameters as settings over to format object.

Reimplemented from Linker::OutputFormat.

◆ WriteFile()

void MacDriver::WriteFile ( Linker::Writer & out)
overridevirtual

Stores data in memory to file.

Implements Linker::Format.


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