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

An automatically generated section that stores a table of equally sized entries. More...

#include <table_section.h>

Inheritance diagram for Linker::TableSection< TableEntryType >:
Linker::Section Linker::Buffer Linker::ActualImage Linker::Image

Public Member Functions

 TableSection (::EndianType endian_type, std::string name, int flags=Readable)
 
 TableSection (std::string name, int flags=Readable)
 
offset_t Size () const override
 
offset_t SetZeroFilled (bool is_zero_filled) override
 
void ReadFile (std::istream &in) override
 Overwrites section data with contents of input stream.
 
void ReadFile (Reader &rd) override
 Overwrites section data with contents of input stream.
 
template<typename OutputType >
offset_t WriteTable (OutputType &out, offset_t bytes, offset_t offset) const
 Generic function to handle writing entries.
 
offset_t WriteFile (std::ostream &out, offset_t bytes, offset_t offset=0) const override
 Writes data into file.
 
offset_t WriteFile (Writer &wr, offset_t bytes, offset_t offset=0) const override
 Writes data of non-zero filled sections.
 
void Reset () override
 Clear the section.
 
virtual offset_t WriteFile (std::ostream &out, offset_t bytes, offset_t offset=0) const
 Writes data into file.
 
offset_t WriteFile (std::ostream &out) const
 Writes data into file.
 
offset_t WriteFile (Writer &wr, offset_t count, offset_t offset=0) const override
 Writes data of non-zero filled sections.
 
virtual offset_t WriteFile (Writer &wr, offset_t count, offset_t offset=0) const=0
 Writes data of non-zero filled sections.
 
virtual offset_t WriteFile (Writer &wr) const
 Writes data of non-zero filled sections.
 
- Public Member Functions inherited from Linker::Section
 Section (std::string name, int flags=Readable)
 
void SetFlag (unsigned newflags)
 Sets the flags of the section.
 
unsigned GetFlags () const
 
bool IsReadable () const
 
void SetReadable (bool state)
 
bool IsWritable () const
 
void SetWritable (bool state)
 
bool IsExecutable () const
 
void SetExecutable (bool state)
 
bool IsMergeable () const
 
void SetMergeable (bool state)
 
bool IsFixed () const
 
bool IsZeroFilled () const
 
offset_t GetAlign () const
 
void SetAlign (offset_t new_align)
 
offset_t GetStartAddress () const
 
offset_t GetEndAddress () const
 Returns end address (GetStartAddress() + Size())
 
offset_t SetAddress (offset_t new_address)
 For non-fixed segments, sets the starting address and makes the fixed.
 
void ResetAddress (offset_t new_address)
 Forcibly alters the starting address.
 
offset_t Expand (offset_t new_size)
 Increases the size of the section by the specified amount.
 
offset_t RealignEnd (offset_t align)
 Expands the section to a size such that its end is at a specified alignment.
 
size_t ReadData (size_t bytes, offset_t offset, void *buffer) const override
 Attempts to fill a buffer with data.
 
void WriteWord (size_t bytes, offset_t offset, uint64_t value, EndianType endiantype)
 
void WriteWord (size_t bytes, offset_t offset, uint64_t value)
 
void WriteWord (size_t bytes, uint64_t value, EndianType endiantype)
 Writes value at the current end of the section.
 
void WriteWord (size_t bytes, uint64_t value)
 Writes value at the current end of the section.
 
offset_t Append (const void *new_data, size_t length)
 Appends data at the end of a section.
 
offset_t Append (const char *new_data)
 Appends data at the end of a section.
 
offset_t Append (const Section &other)
 Appends (or merges) another section.
 
offset_t Append (Buffer &buffer)
 Appends (or merges) another writable buffer.
 
Position Start () const
 Retrieves the address of the first byte of the section.
 
Position Base () const
 Retrieves the address of the start of the segment of the section.
 
offset_t WriteFile (std::ostream &out) const
 Writes data into file.
 
void ReadFile (Reader &rd, offset_t count)
 
- Public Member Functions inherited from Linker::Buffer
 Buffer (size_t size)
 
offset_t ImageSize () const override
 Retrieves size of stored data.
 
void ReadFile (Reader &rd, offset_t count)
 
- Public Member Functions inherited from Linker::ActualImage
std::shared_ptr< const ActualImageAsImage () const override
 Retrieves a randomly accessible image.
 
uint64_t ReadUnsigned (size_t bytes, offset_t offset, EndianType endiantype) const
 Reads an unsigned number at a specific offset.
 
uint64_t ReadUnsigned (size_t bytes, offset_t offset) const
 Reads an unsigned number at a specific offset with the default endianness.
 
int64_t ReadSigned (size_t bytes, offset_t offset, EndianType endiantype) const
 Reads a signed number at a specific offset.
 
int64_t ReadSigned (size_t bytes, offset_t offset) const
 Reads a signed number at a specific offset with the default endianness.
 
int GetByte (offset_t offset) const
 Retrieve byte at a certain offset (optional, might not be defined)
 
- Public Member Functions inherited from Linker::Image
std::shared_ptr< ActualImageAsImage ()
 Retrieves a randomly accessible image.
 

Public Attributes

::EndianType endian_type = ::UndefinedEndian
 Endianness of table entries.
 
std::vector< TableEntryType > entries
 List of entries to be stored in the table.
 
- Public Attributes inherited from Linker::Section
std::string name
 Name of the section.
 
section_flags flags
 The type of the section.
 
offset_t bias = 0
 Difference between the first byte of the section and the zero address associated with the section.
 
std::variant< std::string, uint16_t > resource_type = " "
 The resource type and ID for a resource section.
 
std::variant< std::string, uint16_t > resource_id = uint16_t(0)
 
std::weak_ptr< Segmentsegment
 The segment a section belongs to.
 
std::string collection_name
 Section name that collects sections.
 

Additional Inherited Members

- Public Types inherited from Linker::Section
enum  section_flags {
  Readable = 1 << 0 , Writable = 1 << 1 , Executable = 1 << 2 , Mergeable = 1 << 3 ,
  ZeroFilled = 1 << 4 , Fixed = 1 << 5 , Resource = 1 << 6 , Optional = 1 << 7 ,
  Stack = 1 << 8 , Heap = 1 << 9 , CustomFlag = 1 << 10
}
 Possible flags for the section. More...
 
- Static Public Member Functions inherited from Linker::Section
static std::shared_ptr< SectionReadFromFile (Reader &rd, std::string name, int flags=Readable)
 
static std::shared_ptr< SectionReadFromFile (Reader &rd, offset_t count, std::string name, int flags=Readable)
 
- Static Public Member Functions inherited from Linker::Buffer
static std::shared_ptr< BufferReadFromFile (Reader &rd)
 
static std::shared_ptr< BufferReadFromFile (Reader &rd, offset_t count)
 
- Protected Attributes inherited from Linker::Buffer
std::vector< uint8_t > data
 

Detailed Description

template<typename TableEntryType>
class Linker::TableSection< TableEntryType >

An automatically generated section that stores a table of equally sized entries.

To permit zero padding the end, the data from the base class is appended to the end of the table.

Member Function Documentation

◆ ReadFile() [1/2]

template<typename TableEntryType >
void Linker::TableSection< TableEntryType >::ReadFile ( Reader & rd)
inlineoverridevirtual

Overwrites section data with contents of input stream.

Note that only as many bytes are read in as the size of the section.

Reimplemented from Linker::Section.

◆ ReadFile() [2/2]

template<typename TableEntryType >
void Linker::TableSection< TableEntryType >::ReadFile ( std::istream & in)
inlineoverridevirtual

Overwrites section data with contents of input stream.

Note that only as many bytes are read in as the size of the section.

Reimplemented from Linker::Section.

◆ Reset()

template<typename TableEntryType >
void Linker::TableSection< TableEntryType >::Reset ( )
inlineoverridevirtual

Clear the section.

Reimplemented from Linker::Section.

◆ SetZeroFilled()

template<typename TableEntryType >
offset_t Linker::TableSection< TableEntryType >::SetZeroFilled ( bool is_zero_filled)
inlineoverridevirtual

Reimplemented from Linker::Section.

◆ Size()

template<typename TableEntryType >
offset_t Linker::TableSection< TableEntryType >::Size ( ) const
inlineoverridevirtual

Reimplemented from Linker::Section.

◆ WriteFile() [1/7]

template<typename TableEntryType >
offset_t Section::WriteFile ( std::ostream & out) const

Writes data into file.

Note that zero filled sections do not write anything.

Parameters
outOutput stream
Returns
Count of actual number of bytes written

◆ WriteFile() [2/7]

template<typename TableEntryType >
offset_t Section::WriteFile ( std::ostream & out,
offset_t bytes,
offset_t offset = 0 ) const
virtual

Writes data into file.

Note that zero filled sections do not write anything.

Parameters
outOutput stream
bytesMaximum number of bytes to write
Returns
Count of actual number of bytes written

Reimplemented from Linker::Section.

◆ WriteFile() [3/7]

template<typename TableEntryType >
offset_t Linker::TableSection< TableEntryType >::WriteFile ( std::ostream & out,
offset_t bytes,
offset_t offset = 0 ) const
inlineoverridevirtual

Writes data into file.

Note that zero filled sections do not write anything.

Parameters
outOutput stream
bytesMaximum number of bytes to write
Returns
Count of actual number of bytes written

Reimplemented from Linker::Section.

◆ WriteFile() [4/7]

template<typename TableEntryType >
offset_t Image::WriteFile ( Writer & wr) const
virtual

Writes data of non-zero filled sections.

Reimplemented from Linker::Section.

◆ WriteFile() [5/7]

template<typename TableEntryType >
offset_t Linker::TableSection< TableEntryType >::WriteFile ( Writer & wr,
offset_t count,
offset_t offset = 0 ) const
inlineoverridevirtual

Writes data of non-zero filled sections.

Reimplemented from Linker::Section.

◆ WriteFile() [6/7]

template<typename TableEntryType >
offset_t Buffer::WriteFile ( Writer & wr,
offset_t count,
offset_t offset = 0 ) const
overridevirtual

Writes data of non-zero filled sections.

Reimplemented from Linker::Section.

◆ WriteFile() [7/7]

template<typename TableEntryType >
virtual offset_t Linker::Image::WriteFile ( Writer & wr,
offset_t count,
offset_t offset = 0 ) const
virtual

Writes data of non-zero filled sections.

Reimplemented from Linker::Section.


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