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

Stores as 68K code segment, found in 'CODE' resources. More...

#include <macos.h>

Inheritance diagram for Apple::MacintoshResourceFileFormat::CodeResource:
Apple::MacintoshResourceFileFormat::Resource Linker::Format Linker::Contents

Classes

struct  TransitionVector
 Convenience structure to handle transition vectors belonging to this segment. More...
 

Public Types

enum  HeaderFormat { Near , Far , CFM_68K }
 

Public Member Functions

 CodeResource (uint16_t id, std::shared_ptr< JumpTableCodeResource > jump_table=nullptr)
 
void StoreNearSegmentEntries (std::shared_ptr< JumpTableCodeResource > jump_table, uint32_t &jump_table_offset, std::optional< uint32_t > starting_entry={})
 For near segments, stores all entries into the jump table.
 
void StoreFarSegmentNearEntries (std::shared_ptr< JumpTableCodeResource > jump_table, uint32_t &jump_table_offset, std::optional< uint32_t > starting_entry={})
 For far segments, stores all near entries into the jump table.
 
void StoreFarSegmentFarEntries (std::shared_ptr< JumpTableCodeResource > jump_table, uint32_t &jump_table_offset)
 For far segments, stores all far entries into the jump table.
 
void StoreTransitionVectorEntries (std::shared_ptr< JumpTableCodeResource > jump_table, uint32_t &jump_table_offset, Location seg_loader, std::optional< TransitionVector > starting_tvector={})
 For CFM-68K applications, stores all transition vectors into the jump table.
 
void CalculateValues () override
 
offset_t ImageSize () const override
 Retrieves the offset of the byte after the last one belonging to this format from the first one.
 
void ReadFile (const std::shared_ptr< Linker::Reader > &rd) override
 Loads file into memory.
 
void ReadFile (const std::shared_ptr< Linker::Reader > &rd, offset_t length) override
 
uint32_t MeasureRelocations (std::set< uint32_t > &relocations) const
 
void ReadRelocations (const std::shared_ptr< Linker::Reader > &rd, std::set< uint32_t > &relocations) const
 
void WriteRelocations (const std::shared_ptr< Linker::Writer > &wr, const std::set< uint32_t > &relocations) const
 
offset_t WriteFile (const std::shared_ptr< Linker::Writer > &wr) const override
 Stores data in memory to file.
 
int GetDisplayOptions () const override
 
void Dump (Dumper::Dumper &dump, offset_t file_offset) const override
 
void AddFields (Dumper::Dumper &dump, Dumper::Region &region, offset_t file_offset) const override
 
- Public Member Functions inherited from Apple::MacintoshResourceFileFormat::Resource
void Dump (Dumper::Dumper &dump) const override
 Display file contents in a nice manner.
 
virtual std::unique_ptr< Dumper::Region > CreateRegion (std::string name, offset_t offset, offset_t length, unsigned display_width) const
 
virtual void EffectFormat (MacintoshResourceFileFormat &format, const std::shared_ptr< Linker::Reader > &rd)
 Apply some changes to the format after parsing.
 
- 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.
 
- 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.
 

Public Attributes

std::shared_ptr< JumpTableCodeResource > jump_table
 
std::shared_ptr< Linker::Contents > image
 
uint32_t zero_fill = 0
 
HeaderFormat header_format = Near
 
uint32_t a5_address = 0
 
uint32_t base_address = 0
 
std::set< uint32_t > near_entries
 
uint16_t near_entry_count = 0
 
std::set< uint32_t > far_entries
 
uint16_t far_entry_count = 0
 
std::set< uint32_t > a5_relocations
 
std::set< uint32_t > segment_relocations
 
std::set< TransitionVector > transition_vectors
 
uint32_t transition_vector_count = 0
 
std::map< uint32_t, std::vector< Linker::Relocation > > entry_relocations
 
std::map< TransitionVector, std::vector< Linker::Relocation > > tvector_relocations
 
uint32_t first_near_entry_offset
 
uint32_t first_far_entry_offset
 
uint32_t first_transition_vector_offset
 
uint32_t a5_relocation_offset
 
uint32_t segment_relocation_offset
 
uint32_t resource_size
 
- Public Attributes inherited from Apple::MacintoshResourceFileFormat::Resource
char type [4]
 
uint16_t id
 
std::optional< std::string > name
 
uint8_t attributes
 
- 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.
 

Static Public Attributes

static constexpr uint32_t OSType = OSTypeToUInt32('C', 'O', 'D', 'E')
 
static constexpr uint32_t NearSegmentHeaderSize = 0x4
 
static constexpr uint32_t FarSegmentHeaderSize = 0x28
 

Additional Inherited Members

- Protected Member Functions inherited from Apple::MacintoshResourceFileFormat::Resource
 Resource (const char type[4], uint16_t id, uint8_t attributes=0)
 
 Resource (const char type[4], uint16_t id, std::optional< std::string > name, uint8_t attributes=0)
 

Detailed Description

Stores as 68K code segment, found in 'CODE' resources.

Member Enumeration Documentation

◆ HeaderFormat

Enumerator
Near 

Near model segment, segment starts with a 4-byte header.

Far 

Far model segment, segment starts with a 40-byte header and potentially followed by segment based and A5 based relocations.

CFM_68K 

CFM-68K segment, segment starts with a 40-byte header.

Member Function Documentation

◆ AddFields()

void MacintoshResourceFileFormat::CodeResource::AddFields ( Dumper::Dumper &  dump,
Dumper::Region &  region,
offset_t  file_offset 
) const
overridevirtual

◆ CalculateValues()

void MacintoshResourceFileFormat::CodeResource::CalculateValues ( )
overridevirtual

◆ Dump()

void MacintoshResourceFileFormat::CodeResource::Dump ( Dumper::Dumper &  dump,
offset_t  file_offset 
) const
overridevirtual

◆ GetDisplayOptions()

int MacintoshResourceFileFormat::CodeResource::GetDisplayOptions ( ) const
overridevirtual

◆ ImageSize()

offset_t MacintoshResourceFileFormat::CodeResource::ImageSize ( ) const
overridevirtual

Retrieves the offset of the byte after the last one belonging to this format from the first one.

Returns
The size of the image, or offset_t(-1) if it cannot be determined before writing to the file

Implements Apple::MacintoshResourceFileFormat::Resource.

◆ ReadFile() [1/2]

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

Loads file into memory.

Implements Linker::Format.

◆ ReadFile() [2/2]

void MacintoshResourceFileFormat::CodeResource::ReadFile ( const std::shared_ptr< Linker::Reader > &  rd,
offset_t  length 
)
overridevirtual

◆ StoreFarSegmentFarEntries()

void MacintoshResourceFileFormat::CodeResource::StoreFarSegmentFarEntries ( std::shared_ptr< JumpTableCodeResource >  jump_table,
uint32_t &  jump_table_offset 
)

For far segments, stores all far entries into the jump table.

Parameters
jump_tablePointer to jump table resource
jump_table_offsetLatest offset into the jump table where the entries must start, gets updated

◆ StoreFarSegmentNearEntries()

void MacintoshResourceFileFormat::CodeResource::StoreFarSegmentNearEntries ( std::shared_ptr< JumpTableCodeResource >  jump_table,
uint32_t &  jump_table_offset,
std::optional< uint32_t >  starting_entry = {} 
)

For far segments, stores all near entries into the jump table.

Parameters
jump_tablePointer to jump table resource
jump_table_offsetLatest offset into the jump table where the entries must start, gets updated
starting_entryIf this segment contains a dedicated entry point, places it as the first entry

◆ StoreNearSegmentEntries()

void MacintoshResourceFileFormat::CodeResource::StoreNearSegmentEntries ( std::shared_ptr< JumpTableCodeResource >  jump_table,
uint32_t &  jump_table_offset,
std::optional< uint32_t >  starting_entry = {} 
)

For near segments, stores all entries into the jump table.

Parameters
jump_tablePointer to jump table resource
jump_table_offsetLatest offset into the jump table where the entries must start, gets updated
starting_entryIf this segment contains a dedicated entry point, places it as the first entry

◆ StoreTransitionVectorEntries()

void MacintoshResourceFileFormat::CodeResource::StoreTransitionVectorEntries ( std::shared_ptr< JumpTableCodeResource >  jump_table,
uint32_t &  jump_table_offset,
Location  seg_loader,
std::optional< TransitionVector >  starting_tvector = {} 
)

For CFM-68K applications, stores all transition vectors into the jump table.

Parameters
jump_tablePointer to jump table resource
jump_table_offsetLatest offset into the jump table where the entries must start, gets updated
seg_loaderThe location of the segment loader, must be a sectioned location
starting_tvectorAn optional starting transition vector

◆ WriteFile()

offset_t MacintoshResourceFileFormat::CodeResource::WriteFile ( const std::shared_ptr< Linker::Writer > &  wr) const
overridevirtual

Stores data in memory to file.

Implements Linker::Format.


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