The Pedigree Project
0.1
|
Public Member Functions | |
bool | initialise (const BootstrapStruct_t &pBootstrap) INITIALISATION_ONLY |
Module * | loadModule (uint8_t *pModule, size_t len, bool silent=false) |
void | executeModules (bool silent=false, bool progress=true) |
void | unloadModule (const char *name, bool silent=false, bool progress=true) |
void | unloadModule (Module *module, bool silent=false, bool progress=true) |
void | unloadModules () |
bool | moduleIsLoaded (char *name) |
char * | getDependingModule (char *name) |
uintptr_t | globalLookupSymbol (const char *pName) |
const char * | globalLookupSymbol (uintptr_t addr, uintptr_t *startAddr=0) |
MemoryAllocator & | getModuleAllocator () |
bool | hasPendingModules () const |
void | updateModuleStatus (Module *module, bool status) |
void | waitForModulesToLoad () |
Public Member Functions inherited from Elf | |
Elf () | |
virtual | ~Elf () |
Elf (const Elf &) | |
bool | validate (uint8_t *pBuffer, size_t length) |
bool | create (uint8_t *pBuffer, size_t length) |
bool | createNeededOnly (uint8_t *pBuffer, size_t length) |
bool | loadModule (uint8_t *pBuffer, size_t length, uintptr_t &loadBase, size_t &loadSize, SymbolTable *pSymbolTableCopy=0) |
bool | finaliseModule (uint8_t *pBuffer, uintptr_t length) |
bool | allocate (uint8_t *pBuffer, size_t length, uintptr_t &loadBase, SymbolTable *pSymtab=0, bool bAllocate=true, size_t *pSize=0) |
bool | load (uint8_t *pBuffer, size_t length, uintptr_t loadBase, SymbolTable *pSymtab=0, uintptr_t nStart=0, uintptr_t nEnd=~0, bool relocate=true) |
List< char * > & | neededLibraries () |
String & | getInterpreter () |
uintptr_t | getLastAddress () |
uintptr_t | getInitFunc () |
uintptr_t | getFiniFunc () |
template<class T = ElfSymbol_t> | |
const char * | lookupSymbol (uintptr_t addr, uintptr_t *startAddr, T *symbolTable) |
const char * | lookupSymbol (uintptr_t addr, uintptr_t *startAddr) |
uintptr_t | lookupSymbol (const char *pName) |
uintptr_t | lookupDynamicSymbolAddress (const char *str, uintptr_t loadBase) |
uintptr_t | applySpecificRelocation (uintptr_t off, SymbolTable *pSymtab, uintptr_t loadBase, SymbolTable::Policy policy=SymbolTable::LocalFirst) |
uintptr_t | getGlobalOffsetTable () |
size_t | getPltSize () |
void | populateSymbolTable (SymbolTable *pSymtab, uintptr_t loadBase) |
void | preallocateSymbols (SymbolTable *pSymtabOverride=nullptr, SymbolTable *pAdditionalSymtab=nullptr) |
SymbolTable * | getSymbolTable () |
uintptr_t | getEntryPoint () |
uintptr_t | debugFrameTable () |
uintptr_t | debugFrameTableLength () |
void | setName (const String &s) |
const String & | getName () const |
Static Public Member Functions | |
static KernelElf & | instance () |
Static Public Member Functions inherited from Elf | |
static bool | extractEntryPoint (uint8_t *pBuffer, size_t length, uintptr_t &entry) |
static bool | extractInformation (uint8_t *pBuffer, size_t length, size_t &phdrCount, size_t &phdrEntrySize, uintptr_t &phdrAddress) |
Private Types | |
typedef Elf32SectionHeader_t | KernelElfSectionHeader_t |
typedef Elf32Symbol_t | KernelElfSymbol_t |
Private Member Functions | |
KernelElf () INITIALISATION_ONLY | |
KernelElf (const KernelElf &) | |
virtual | ~KernelElf () |
KernelElf & | operator= (const KernelElf &) |
bool | moduleDependenciesSatisfied (Module *module) |
bool | executeModule (Module *module) |
void | lockModules () |
void | unlockModules () |
Static Private Member Functions | |
template<class T > | |
static T * | rebase (Module *module, T *ptr) |
Private Attributes | |
MemoryRegion | m_AdditionalSectionContents |
MemoryRegion * | m_AdditionalSectionHeaders |
Vector< Module * > | m_Modules |
MemoryAllocator | m_ModuleAllocator |
Elf32SectionHeader_t * | m_pSectionHeaders |
Elf32Symbol_t * | m_pSymbolTable |
Semaphore | m_ModuleProgress |
Spinlock | m_ModuleAdjustmentLock |
Static Private Attributes | |
static KernelElf | m_Instance |
Friends | |
void | system_reset () |
Additional Inherited Members | |
Protected Attributes inherited from Elf | |
struct Elf::ElfHeader_t | PACKED |
struct Elf::ElfProgramHeader_t | PACKED |
struct Elf::ElfSectionHeader_t | PACKED |
struct Elf::Elf32SectionHeader_t | PACKED |
struct Elf::ElfSymbol_t | PACKED |
struct Elf::Elf32Symbol_t | PACKED |
struct Elf::ElfDyn_t | PACKED |
struct Elf::ElfRel_t | PACKED |
struct Elf::ElfRela_t | PACKED |
ElfSymbol_t * | m_pSymbolTable |
size_t | m_nSymbolTableSize |
char * | m_pStringTable |
size_t | m_nStringTableSize |
char * | m_pShstrtab |
size_t | m_nShstrtabSize |
uintptr_t * | m_pGotTable |
ElfRel_t * | m_pRelTable |
ElfRela_t * | m_pRelaTable |
size_t | m_nRelTableSize |
size_t | m_nRelaTableSize |
ElfRel_t * | m_pPltRelTable |
ElfRela_t * | m_pPltRelaTable |
bool | m_bUsesRela |
uint32_t * | m_pDebugTable |
size_t | m_nDebugTableSize |
ElfSymbol_t * | m_pDynamicSymbolTable |
size_t | m_nDynamicSymbolTableSize |
char * | m_pDynamicStringTable |
size_t | m_nDynamicStringTableSize |
ElfSectionHeader_t * | m_pSectionHeaders |
size_t | m_nSectionHeaders |
ElfProgramHeader_t * | m_pProgramHeaders |
size_t | m_nProgramHeaders |
size_t | m_nPltSize |
uintptr_t | m_nEntry |
List< char * > | m_NeededLibraries |
SymbolTable | m_SymbolTable |
uintptr_t | m_InitFunc |
uintptr_t | m_FiniFunc |
String | m_sInterpreter |
String | m_Name |
uintptr_t | m_LoadBase |
Definition at line 122 of file KernelElf.h.
|
private |
Default constructor does nothing
Definition at line 403 of file KernelElf.cc.
|
private |
Copy-constructor
|
privatevirtual |
Destructor does nothing
Definition at line 417 of file KernelElf.cc.
void KernelElf::executeModules | ( | bool | silent = false , |
bool | progress = true |
||
) |
Executes all modules.
Definition at line 569 of file KernelElf.cc.
References Vector< T >::begin(), Vector< T >::count(), DEBUG_LOG, loadModule(), m_Modules, NOTICE, and Vector< T >::pushBack().
char * KernelElf::getDependingModule | ( | char * | name | ) |
Returns the name of the first module that have the specified module as dependency.
Definition at line 809 of file KernelElf.cc.
References Thread::detach(), FATAL, Elf::finaliseModule(), Processor::information(), instance(), Elf::lookupSymbol(), m_Modules, NOTICE, rebase(), updateModuleStatus(), and WARNING.
|
inline |
Returns the address space allocator for modules.
Definition at line 174 of file KernelElf.h.
References INITIALISATION_ONLY.
uintptr_t KernelElf::globalLookupSymbol | ( | const char * | pName | ) |
Looks up the address of the symbol with name 'pName' globally, that is throughout all modules and the kernel itself.
Definition at line 1031 of file KernelElf.cc.
References SymbolTable::lookup().
Referenced by DisassembleCommand::execute(), LookupCommand::execute(), ThreadsCommand::execute(), SlamCommand::execute(), AllocationCommand::execute(), TraceCommand::execute(), LocksCommand::execute(), and Backtrace::performBpBacktrace().
const char * KernelElf::globalLookupSymbol | ( | uintptr_t | addr, |
uintptr_t * | startAddr = 0 |
||
) |
Definition at line 1036 of file KernelElf.cc.
References Hex, lockModules(), Elf::lookupSymbol(), m_Modules, and unlockModules().
bool KernelElf::hasPendingModules | ( | ) | const |
Do we have pending modules still?
Definition at line 1071 of file KernelElf.cc.
bool KernelElf::initialise | ( | const BootstrapStruct_t & | pBootstrap | ) |
Extracts the symbol and string tables from the given BootstrapInfo class.
Definition at line 105 of file KernelElf.cc.
References PhysicalMemoryManager::allocateRegion(), PhysicalMemoryManager::continuous, ERROR, PhysicalMemoryManager::getPageSize(), Hex, SymbolTable::insert(), PhysicalMemoryManager::instance(), VirtualAddressSpace::KernelMode, m_pSectionHeaders, NOTICE, SymbolTable::preallocate(), WARNING, and VirtualAddressSpace::Write.
|
inlinestatic |
Get the class instance
Definition at line 129 of file KernelElf.h.
References INITIALISATION_ONLY.
Referenced by Elf::applyRelocation(), DisassembleCommand::execute(), LookupCommand::execute(), AllocationCommand::execute(), SlamCommand::execute(), ThreadsCommand::execute(), TraceCommand::execute(), LocksCommand::execute(), getDependingModule(), Elf::loadModule(), Backtrace::performBacktrace(), Backtrace::performBpBacktrace(), and Backtrace::performDwarfBacktrace().
Module * KernelElf::loadModule | ( | uint8_t * | pModule, |
size_t | len, | ||
bool | silent = false |
||
) |
Treats the given pointer as an ELF partially linked object file and loads it, relocates it and links it.
pModule | A pointer to an ELF module/driver. |
len | The length of pModule, in bytes. |
silent | If true will not update the boot progress(default is false). |
Definition at line 432 of file KernelElf.cc.
References Vector< T >::count(), Elf::create(), DEBUG_LOG, Dec, Elf::Elf(), ERROR, FATAL, RangeList< T, Reversed >::free(), VirtualAddressSpace::getKernelAddressSpace(), VirtualAddressSpace::getKernelModulesEnd(), VirtualAddressSpace::getKernelModulesStart(), Hex, Elf::loadModule(), Elf::lookupSymbol(), m_ModuleAllocator, m_Modules, NOTICE, Vector< T >::pushBack(), rebase(), Elf::setName(), and UNLIKELY.
Referenced by executeModules().
|
private |
Lock for access to the module data structures.
Definition at line 1084 of file KernelElf.cc.
References Spinlock::acquire().
Referenced by globalLookupSymbol().
bool KernelElf::moduleIsLoaded | ( | char * | name | ) |
Returns true if a module with the specified name has been loaded.
Definition at line 790 of file KernelElf.cc.
References m_Modules.
Assignment operator
|
inlinestaticprivate |
Rebase a pointer for the given loaded module.
Definition at line 205 of file KernelElf.h.
Referenced by getDependingModule(), and loadModule().
void KernelElf::unloadModule | ( | const char * | name, |
bool | silent = false , |
||
bool | progress = true |
||
) |
Unloads the specified module.
Definition at line 665 of file KernelElf.cc.
References ERROR, RangeList< T, Reversed >::free(), PhysicalMemoryManager::freePage(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), Processor::information(), PhysicalMemoryManager::instance(), VirtualAddressSpace::isMapped(), Elf::lookupSymbol(), m_ModuleAllocator, m_Modules, NOTICE, and VirtualAddressSpace::unmap().
Referenced by unloadModules(), and updateModuleStatus().
void KernelElf::unloadModules | ( | ) |
Unloads all loaded modules.
Definition at line 773 of file KernelElf.cc.
References m_Modules, and unloadModule().
|
private |
Unlock access to module data structures.
Definition at line 1091 of file KernelElf.cc.
References Spinlock::release().
Referenced by globalLookupSymbol().
void KernelElf::updateModuleStatus | ( | Module * | module, |
bool | status | ||
) |
Updates the status of the given module.
Definition at line 983 of file KernelElf.cc.
References m_ModuleProgress, NOTICE, Semaphore::release(), and unloadModule().
Referenced by getDependingModule().
void KernelElf::waitForModulesToLoad | ( | ) |
Waits for all modules to complete (whether successfully or not).
Definition at line 1003 of file KernelElf.cc.
References Semaphore::acquire(), Vector< T >::count(), m_ModuleProgress, m_Modules, and NOTICE.
|
staticprivate |
Instance of the KernelElf class
Definition at line 222 of file KernelElf.h.
|
private |
Memory allocator for modules - where they can be loaded.
Definition at line 227 of file KernelElf.h.
Referenced by loadModule(), and unloadModule().
|
private |
Tracks the module loading process.
Definition at line 246 of file KernelElf.h.
Referenced by updateModuleStatus(), and waitForModulesToLoad().
List of modules
Definition at line 225 of file KernelElf.h.
Referenced by executeModules(), getDependingModule(), globalLookupSymbol(), hasPendingModules(), loadModule(), moduleIsLoaded(), unloadModule(), unloadModules(), and waitForModulesToLoad().
|
private |
Override Elf base class members.
Definition at line 231 of file KernelElf.h.
Referenced by initialise().