The Pedigree Project 0.1
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ModuleImage Class Reference

#include <ModuleImage.h>

+ Collaboration diagram for ModuleImage:

Public Types

enum class  Result { Valid , Malformed , Unsupported , TooLarge }
 
using Header = Elf::ElfHeader_t
 
using Segment = Elf::ElfProgramHeader_t
 
using Section = Elf::ElfSectionHeader_t
 
using Symbol = Elf::ElfSymbol_t
 
using Relocation = Elf::ElfRela_t
 
using Dynamic = Elf::ElfDyn_t
 

Public Member Functions

Result preflight (const uint8_t *image, size_t length)
 
bool symbol (size_t index, Symbol &result, bool dynamic=true) const
 
const char * symbolName (const Symbol &value, bool dynamic=true) const
 
bool findSymbol (const char *name, Symbol &result, bool dynamic=false) const
 
bool relocation (size_t index, Relocation &result) const
 
bool contains (uintptr_t address, size_t length, size_t flags=PF_R) const
 
bool fileOffset (uintptr_t address, size_t length, size_t &offset) const
 
bool localPointer (uintptr_t address, uintptr_t &target) const
 
bool validateMaterialized (uintptr_t base) const
 
bool exportedSymbol (size_t index, Symbol &result) const
 

Public Attributes

const uint8_t * bytes
 
size_t byteCount
 
Segment segments [MaximumSegments]
 
size_t segmentCount
 
size_t mappedBytes
 
size_t symbolCount
 
size_t relocationCount
 
char name [NameBytes]
 
char dependencies [MaximumDependencies][NameBytes]
 
size_t dependencyCount
 
char optionalDependencies [MaximumDependencies][NameBytes]
 
size_t optionalDependencyCount
 
uintptr_t entry
 
uintptr_t exit
 
uintptr_t constructors [MaximumLifecycleFunctions]
 
size_t constructorCount
 
uintptr_t destructors [MaximumLifecycleFunctions]
 
size_t destructorCount
 

Static Public Attributes

static constexpr size_t MaximumImageBytes = 1024 * 1024
 
static constexpr size_t MaximumMappedBytes = 1024 * 1024
 
static constexpr size_t MaximumSegments = 16
 
static constexpr size_t MaximumSections = 256
 
static constexpr size_t MaximumSymbols = 4096
 
static constexpr size_t MaximumRelocations = 16384
 
static constexpr size_t MaximumDependencies = 16
 
static constexpr size_t MaximumLifecycleFunctions = 128
 
static constexpr size_t NameBytes = 56
 
static constexpr size_t SymbolNameBytes = 256
 

Private Member Functions

bool section (size_t index, Section &result) const
 
bool string (size_t tableOffset, size_t tableBytes, size_t offset, const char *&result, size_t maximum) const
 
bool mappedString (uintptr_t address, const char *&result, size_t maximum) const
 
bool namedObject (const char *name, size_t size, Symbol &result) const
 
bool dependenciesAt (const char *symbolName, char names[][NameBytes], size_t &count, bool optional) const
 
bool lifecycle (const char *startName, const char *endName, uintptr_t *targets, size_t &count) const
 
Result validateSections (const Header &header)
 
Result validateDynamic ()
 
Result validateRelocations ()
 
Result validateMetadata ()
 

Private Attributes

size_t sectionOffset
 
size_t sectionCount
 
size_t sectionStrings
 
size_t sectionStringBytes
 
size_t dynamicOffset
 
size_t dynamicBytes
 
size_t symbols
 
size_t symbolBytes
 
size_t strings
 
size_t stringBytes
 
size_t fullSymbols
 
size_t fullSymbolBytes
 
size_t fullStrings
 
size_t fullStringBytes
 
size_t relocations
 
size_t relocationBytes
 
uintptr_t symbolAddress
 
uintptr_t stringAddress
 
uintptr_t relocationAddress
 
uintptr_t constructorAddress
 
size_t constructorBytes
 
uintptr_t destructorAddress
 
size_t destructorBytes
 

Detailed Description

Allocation-free plan over an immutable, kernel-owned native module image.

Definition at line 8 of file ModuleImage.h.

Member Typedef Documentation

◆ Dynamic

Definition at line 27 of file ModuleImage.h.

◆ Header

Definition at line 22 of file ModuleImage.h.

◆ Relocation

Definition at line 26 of file ModuleImage.h.

◆ Section

Definition at line 24 of file ModuleImage.h.

◆ Segment

Definition at line 23 of file ModuleImage.h.

◆ Symbol

Definition at line 25 of file ModuleImage.h.

Member Enumeration Documentation

◆ Result

enum class ModuleImage::Result
strong

Definition at line 21 of file ModuleImage.h.

Constructor & Destructor Documentation

◆ ModuleImage()

ModuleImage::ModuleImage ( )

Definition at line 21 of file ModuleImage.cc.

Member Function Documentation

◆ contains()

bool ModuleImage::contains ( uintptr_t  address,
size_t  length,
size_t  flags = PF_R 
) const

Definition at line 33 of file ModuleImage.cc.

◆ dependenciesAt()

bool ModuleImage::dependenciesAt ( const char *  symbolName,
char  names[][NameBytes],
size_t &  count,
bool  optional 
) const
private

Definition at line 507 of file ModuleImage.cc.

◆ exportedSymbol()

bool ModuleImage::exportedSymbol ( size_t  index,
Symbol &  result 
) const

Definition at line 619 of file ModuleImage.cc.

◆ fileOffset()

bool ModuleImage::fileOffset ( uintptr_t  address,
size_t  length,
size_t &  offset 
) const

Definition at line 44 of file ModuleImage.cc.

◆ findSymbol()

bool ModuleImage::findSymbol ( const char *  name,
Symbol &  result,
bool  dynamic = false 
) const

Definition at line 83 of file ModuleImage.cc.

◆ lifecycle()

bool ModuleImage::lifecycle ( const char *  startName,
const char *  endName,
uintptr_t *  targets,
size_t &  count 
) const
private

Definition at line 540 of file ModuleImage.cc.

◆ localPointer()

bool ModuleImage::localPointer ( uintptr_t  address,
uintptr_t &  target 
) const

Definition at line 111 of file ModuleImage.cc.

◆ mappedString()

bool ModuleImage::mappedString ( uintptr_t  address,
const char *&  result,
size_t  maximum 
) const
private

Definition at line 609 of file ModuleImage.cc.

◆ namedObject()

bool ModuleImage::namedObject ( const char *  name,
size_t  size,
Symbol &  result 
) const
private

Definition at line 494 of file ModuleImage.cc.

◆ preflight()

ModuleImage::Result ModuleImage::preflight ( const uint8_t *  image,
size_t  length 
)

Definition at line 139 of file ModuleImage.cc.

◆ relocation()

bool ModuleImage::relocation ( size_t  index,
Relocation &  result 
) const

Definition at line 103 of file ModuleImage.cc.

◆ section()

bool ModuleImage::section ( size_t  index,
Section &  result 
) const
private

Definition at line 25 of file ModuleImage.cc.

◆ string()

bool ModuleImage::string ( size_t  tableOffset,
size_t  tableBytes,
size_t  offset,
const char *&  result,
size_t  maximum 
) const
private

Definition at line 55 of file ModuleImage.cc.

◆ symbol()

bool ModuleImage::symbol ( size_t  index,
Symbol &  result,
bool  dynamic = true 
) const

Definition at line 65 of file ModuleImage.cc.

◆ symbolName()

const char * ModuleImage::symbolName ( const Symbol &  value,
bool  dynamic = true 
) const

Definition at line 75 of file ModuleImage.cc.

◆ validateDynamic()

ModuleImage::Result ModuleImage::validateDynamic ( )
private

Definition at line 342 of file ModuleImage.cc.

◆ validateMaterialized()

bool ModuleImage::validateMaterialized ( uintptr_t  base) const

Definition at line 628 of file ModuleImage.cc.

◆ validateMetadata()

ModuleImage::Result ModuleImage::validateMetadata ( )
private

Definition at line 569 of file ModuleImage.cc.

◆ validateRelocations()

ModuleImage::Result ModuleImage::validateRelocations ( )
private

Definition at line 455 of file ModuleImage.cc.

◆ validateSections()

ModuleImage::Result ModuleImage::validateSections ( const Header &  header)
private

Definition at line 215 of file ModuleImage.cc.

Member Data Documentation

◆ byteCount

size_t ModuleImage::byteCount

Definition at line 43 of file ModuleImage.h.

◆ bytes

const uint8_t* ModuleImage::bytes

Definition at line 42 of file ModuleImage.h.

◆ constructorAddress

uintptr_t ModuleImage::constructorAddress
private

Definition at line 95 of file ModuleImage.h.

◆ constructorBytes

size_t ModuleImage::constructorBytes
private

Definition at line 96 of file ModuleImage.h.

◆ constructorCount

size_t ModuleImage::constructorCount

Definition at line 57 of file ModuleImage.h.

◆ constructors

uintptr_t ModuleImage::constructors[MaximumLifecycleFunctions]

Definition at line 56 of file ModuleImage.h.

◆ dependencies

char ModuleImage::dependencies[MaximumDependencies][NameBytes]

Definition at line 50 of file ModuleImage.h.

◆ dependencyCount

size_t ModuleImage::dependencyCount

Definition at line 51 of file ModuleImage.h.

◆ destructorAddress

uintptr_t ModuleImage::destructorAddress
private

Definition at line 97 of file ModuleImage.h.

◆ destructorBytes

size_t ModuleImage::destructorBytes
private

Definition at line 98 of file ModuleImage.h.

◆ destructorCount

size_t ModuleImage::destructorCount

Definition at line 59 of file ModuleImage.h.

◆ destructors

uintptr_t ModuleImage::destructors[MaximumLifecycleFunctions]

Definition at line 58 of file ModuleImage.h.

◆ dynamicBytes

size_t ModuleImage::dynamicBytes
private

Definition at line 81 of file ModuleImage.h.

◆ dynamicOffset

size_t ModuleImage::dynamicOffset
private

Definition at line 80 of file ModuleImage.h.

◆ entry

uintptr_t ModuleImage::entry

Definition at line 54 of file ModuleImage.h.

◆ exit

uintptr_t ModuleImage::exit

Definition at line 55 of file ModuleImage.h.

◆ fullStringBytes

size_t ModuleImage::fullStringBytes
private

Definition at line 89 of file ModuleImage.h.

◆ fullStrings

size_t ModuleImage::fullStrings
private

Definition at line 88 of file ModuleImage.h.

◆ fullSymbolBytes

size_t ModuleImage::fullSymbolBytes
private

Definition at line 87 of file ModuleImage.h.

◆ fullSymbols

size_t ModuleImage::fullSymbols
private

Definition at line 86 of file ModuleImage.h.

◆ mappedBytes

size_t ModuleImage::mappedBytes

Definition at line 46 of file ModuleImage.h.

◆ MaximumDependencies

constexpr size_t ModuleImage::MaximumDependencies = 16
staticconstexpr

Definition at line 16 of file ModuleImage.h.

◆ MaximumImageBytes

constexpr size_t ModuleImage::MaximumImageBytes = 1024 * 1024
staticconstexpr

Definition at line 10 of file ModuleImage.h.

◆ MaximumLifecycleFunctions

constexpr size_t ModuleImage::MaximumLifecycleFunctions = 128
staticconstexpr

Definition at line 17 of file ModuleImage.h.

◆ MaximumMappedBytes

constexpr size_t ModuleImage::MaximumMappedBytes = 1024 * 1024
staticconstexpr

Definition at line 11 of file ModuleImage.h.

◆ MaximumRelocations

constexpr size_t ModuleImage::MaximumRelocations = 16384
staticconstexpr

Definition at line 15 of file ModuleImage.h.

◆ MaximumSections

constexpr size_t ModuleImage::MaximumSections = 256
staticconstexpr

Definition at line 13 of file ModuleImage.h.

◆ MaximumSegments

constexpr size_t ModuleImage::MaximumSegments = 16
staticconstexpr

Definition at line 12 of file ModuleImage.h.

◆ MaximumSymbols

constexpr size_t ModuleImage::MaximumSymbols = 4096
staticconstexpr

Definition at line 14 of file ModuleImage.h.

◆ name

char ModuleImage::name[NameBytes]

Definition at line 49 of file ModuleImage.h.

◆ NameBytes

constexpr size_t ModuleImage::NameBytes = 56
staticconstexpr

Definition at line 18 of file ModuleImage.h.

◆ optionalDependencies

char ModuleImage::optionalDependencies[MaximumDependencies][NameBytes]

Definition at line 52 of file ModuleImage.h.

◆ optionalDependencyCount

size_t ModuleImage::optionalDependencyCount

Definition at line 53 of file ModuleImage.h.

◆ relocationAddress

uintptr_t ModuleImage::relocationAddress
private

Definition at line 94 of file ModuleImage.h.

◆ relocationBytes

size_t ModuleImage::relocationBytes
private

Definition at line 91 of file ModuleImage.h.

◆ relocationCount

size_t ModuleImage::relocationCount

Definition at line 48 of file ModuleImage.h.

◆ relocations

size_t ModuleImage::relocations
private

Definition at line 90 of file ModuleImage.h.

◆ sectionCount

size_t ModuleImage::sectionCount
private

Definition at line 77 of file ModuleImage.h.

◆ sectionOffset

size_t ModuleImage::sectionOffset
private

Definition at line 76 of file ModuleImage.h.

◆ sectionStringBytes

size_t ModuleImage::sectionStringBytes
private

Definition at line 79 of file ModuleImage.h.

◆ sectionStrings

size_t ModuleImage::sectionStrings
private

Definition at line 78 of file ModuleImage.h.

◆ segmentCount

size_t ModuleImage::segmentCount

Definition at line 45 of file ModuleImage.h.

◆ segments

Segment ModuleImage::segments[MaximumSegments]

Definition at line 44 of file ModuleImage.h.

◆ stringAddress

uintptr_t ModuleImage::stringAddress
private

Definition at line 93 of file ModuleImage.h.

◆ stringBytes

size_t ModuleImage::stringBytes
private

Definition at line 85 of file ModuleImage.h.

◆ strings

size_t ModuleImage::strings
private

Definition at line 84 of file ModuleImage.h.

◆ symbolAddress

uintptr_t ModuleImage::symbolAddress
private

Definition at line 92 of file ModuleImage.h.

◆ symbolBytes

size_t ModuleImage::symbolBytes
private

Definition at line 83 of file ModuleImage.h.

◆ symbolCount

size_t ModuleImage::symbolCount

Definition at line 47 of file ModuleImage.h.

◆ SymbolNameBytes

constexpr size_t ModuleImage::SymbolNameBytes = 256
staticconstexpr

Definition at line 19 of file ModuleImage.h.

◆ symbols

size_t ModuleImage::symbols
private

Definition at line 82 of file ModuleImage.h.


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