FreeNOS
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
ExecutableFormat Class Referenceabstract

Abstraction class of various executable formats. More...

#include <ExecutableFormat.h>

Inheritance diagram for ExecutableFormat:
ELF

Data Structures

struct  Region
 Memory region. More...
 

Public Types

enum  Result { Success, NotFound, InvalidFormat, OutOfMemory }
 Result code. More...
 
typedef struct ExecutableFormat::Region Region
 Memory region. More...
 

Public Member Functions

 ExecutableFormat (const u8 *image, const Size size)
 Class constructor. More...
 
virtual ~ExecutableFormat ()
 Class destructor. More...
 
virtual Result regions (Region *regions, Size *count) const =0
 Memory regions a program needs at runtime. More...
 
virtual Result entry (Address *entry) const =0
 Lookup the program entry point. More...
 

Static Public Member Functions

static Result find (const u8 *image, const Size size, ExecutableFormat **fmt)
 Find a ExecutableFormat which can handle the given format. More...
 

Protected Attributes

const u8m_image
 Input image raw data. More...
 
const Size m_size
 Input image size in bytes. More...
 

Detailed Description

Abstraction class of various executable formats.

Definition at line 48 of file ExecutableFormat.h.

Member Typedef Documentation

◆ Region

Memory region.

Member Enumeration Documentation

◆ Result

Result code.

Enumerator
Success 
NotFound 
InvalidFormat 
OutOfMemory 

Definition at line 68 of file ExecutableFormat.h.

Constructor & Destructor Documentation

◆ ExecutableFormat()

ExecutableFormat::ExecutableFormat ( const u8 image,
const Size  size 
)

Class constructor.

Parameters
imagePointer to program image.
sizeSize of the program image.

Definition at line 22 of file ExecutableFormat.cpp.

◆ ~ExecutableFormat()

ExecutableFormat::~ExecutableFormat ( )
virtual

Class destructor.

Definition at line 28 of file ExecutableFormat.cpp.

Member Function Documentation

◆ entry()

virtual Result ExecutableFormat::entry ( Address entry) const
pure virtual

Lookup the program entry point.

Parameters
entryEntry point on output.
Returns
Result code.

Implemented in ELF.

Referenced by CoreServer::prepareCoreInfo(), BootImageCreate::readBootSymbols(), RecoveryServer::rewriteProgram(), and spawn().

◆ find()

ExecutableFormat::Result ExecutableFormat::find ( const u8 image,
const Size  size,
ExecutableFormat **  fmt 
)
static

Find a ExecutableFormat which can handle the given format.

Parameters
imageProgram image to read.
sizeProgram image size.
fmtExecutableFormat object pointer on output.
Returns
Result code.
Todo:
Invoke Lz4Decompressor inside this function so that the various callers do not need to anymore

Definition at line 32 of file ExecutableFormat.cpp.

References ELF::detect().

Referenced by CoreServer::loadKernel(), BootImageCreate::readBootSymbols(), RecoveryServer::rewriteProgram(), and spawn().

◆ regions()

virtual Result ExecutableFormat::regions ( Region regions,
Size count 
) const
pure virtual

Memory regions a program needs at runtime.

Parameters
regionsMemory regions to fill.
countOn input, the maximum number of regions to read. On output, the actual number of regions read.
Returns
Result code.

Implemented in ELF.

Referenced by CoreServer::loadKernel(), BootImageCreate::readBootSymbols(), RecoveryServer::rewriteProgram(), and spawn().

Field Documentation

◆ m_image

const u8* ExecutableFormat::m_image
protected

Input image raw data.

Definition at line 126 of file ExecutableFormat.h.

Referenced by ELF::entry(), and ELF::regions().

◆ m_size

const Size ExecutableFormat::m_size
protected

Input image size in bytes.

Definition at line 129 of file ExecutableFormat.h.


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