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

#include <DynamicLinker.h>

+ Collaboration diagram for DynamicLinker:

Classes

struct  SharedObject
 

Public Member Functions

 DynamicLinker ()
 
 DynamicLinker (const DynamicLinker &other)
 
bool checkInterpreter (File *pFile, String &actualFilename)
 
bool checkDependencies (File *pFile)
 
bool loadProgram (File *pFile, bool bDryRun=false, bool bInterpreter=false, String *sInterpreter=0)
 
bool loadObject (File *pFile, bool bDryRun=false)
 
bool trap (uintptr_t address)
 
Elf * getProgramElf ()
 
uintptr_t resolve (String name)
 

Static Public Member Functions

static uintptr_t resolvePlt (SyscallState &state)
 

Private Member Functions

DynamicLinker & operator= (const DynamicLinker &)
 
uintptr_t resolvePltSymbol (uintptr_t libraryId, uintptr_t symIdx)
 
void initPlt (Elf *pElf, uintptr_t value)
 

Static Private Member Functions

static bool loadDemandPage (Elf *pElf, uintptr_t buffer, size_t size, uintptr_t offset, SymbolTable *pSymbols, uintptr_t address)
 

Private Attributes

Elf * m_pProgramElf
 
uintptr_t m_ProgramStart
 
size_t m_ProgramSize
 
uintptr_t m_ProgramBuffer
 
RadixTree< void * > m_LoadedObjects
 
Tree< uintptr_t, SharedObject * > m_Objects
 

Detailed Description

The dynamic linker tracks instances of shared objects through an address space.

Definition at line 39 of file DynamicLinker.h.

Constructor & Destructor Documentation

◆ DynamicLinker() [1/2]

DynamicLinker::DynamicLinker ( )

Creates a new DynamicLinker object.

Definition at line 138 of file DynamicLinker.cc.

◆ ~DynamicLinker()

DynamicLinker::~DynamicLinker ( )

Definition at line 164 of file DynamicLinker.cc.

◆ DynamicLinker() [2/2]

DynamicLinker::DynamicLinker ( const DynamicLinker &  other)

Creates a new DynamicLinker from another. Copies all mappings.

Definition at line 146 of file DynamicLinker.cc.

References Tree< K, E >::begin(), and Tree< K, E >::end().

Member Function Documentation

◆ checkDependencies()

bool DynamicLinker::checkDependencies ( File *  pFile)
inline

Checks dependencies for a given program. Returns true if all dependencies are available and loadable, false if not.

Definition at line 57 of file DynamicLinker.h.

◆ checkInterpreter()

bool DynamicLinker::checkInterpreter ( File *  pFile,
String &  actualFilename 
)
inline

Checks the given program for a requested interpreter, that we should run instead of loading the binary ourselves.

Definition at line 51 of file DynamicLinker.h.

◆ getProgramElf()

Elf * DynamicLinker::getProgramElf ( )
inline

Returns the program ELF.

Definition at line 84 of file DynamicLinker.h.

◆ initPlt()

void DynamicLinker::initPlt ( Elf *  pElf,
uintptr_t  value 
)
private

◆ loadDemandPage()

bool DynamicLinker::loadDemandPage ( Elf *  pElf,
uintptr_t  buffer,
size_t  size,
uintptr_t  offset,
SymbolTable *  pSymbols,
uintptr_t  address 
)
staticprivate

Definition at line 441 of file DynamicLinker.cc.

◆ loadObject()

bool DynamicLinker::loadObject ( File *  pFile,
bool  bDryRun = false 
)

Loads a shared object into this address space (along with any dependencies.

Parameters
pFileThe ELF object to load.
Returns
True if the ELF and all dependencies was loaded successfully.

Definition at line 315 of file DynamicLinker.cc.

References Elf::allocate(), List< T, nodePoolSize >::begin(), Elf::create(), Elf::createNeededOnly(), List< T, nodePoolSize >::end(), VFS::findRetained(), Symlink::followLinkRetained(), Symlink::fromFile(), File::getName(), initPlt(), RadixTree< T >::insert(), MemoryMapManager::instance(), VFS::instance(), File::isSymlink(), loadObject(), RadixTree< T >::lookup(), MemoryMapManager::mapFile(), Elf::neededLibraries(), and MemoryMapManager::unmap().

Referenced by loadObject(), and loadProgram().

+ Here is the caller graph for this function:

◆ loadProgram()

bool DynamicLinker::loadProgram ( File *  pFile,
bool  bDryRun = false,
bool  bInterpreter = false,
String *  sInterpreter = 0 
)

◆ operator=()

DynamicLinker & DynamicLinker::operator= ( const DynamicLinker &  )
private

Operator= is unused and is therefore private.

◆ resolve()

uintptr_t DynamicLinker::resolve ( String  name)

Manually resolves a given symbol name.

Definition at line 551 of file DynamicLinker.cc.

References SymbolTable::lookup().

◆ resolvePlt()

uintptr_t DynamicLinker::resolvePlt ( SyscallState &  state)
static

Callback given to KernelCoreSyscallManager to resolve PLT relocations lazily.

Definition at line 131 of file DynamicLinker.cc.

References Process::getParent(), and ProcessorBase::information().

◆ resolvePltSymbol()

uintptr_t DynamicLinker::resolvePltSymbol ( uintptr_t  libraryId,
uintptr_t  symIdx 
)
private

Definition at line 86 of file amd64/DynamicLinker.cc.

◆ trap()

bool DynamicLinker::trap ( uintptr_t  address)

Called when a trap is handled by the DLTrapHandler.

Parameters
addressAddress of the trap.
Returns
True if the trap was handled successfully.

Definition at line 511 of file DynamicLinker.cc.

References EMIT_IF.

Referenced by DLTrapHandler::trap().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_LoadedObjects

RadixTree<void*> DynamicLinker::m_LoadedObjects
private

Definition at line 128 of file DynamicLinker.h.

◆ m_Objects

Tree<uintptr_t, SharedObject*> DynamicLinker::m_Objects
private

Definition at line 130 of file DynamicLinker.h.

◆ m_pProgramElf

Elf* DynamicLinker::m_pProgramElf
private

Definition at line 124 of file DynamicLinker.h.

◆ m_ProgramBuffer

uintptr_t DynamicLinker::m_ProgramBuffer
private

Definition at line 127 of file DynamicLinker.h.

◆ m_ProgramSize

size_t DynamicLinker::m_ProgramSize
private

Definition at line 126 of file DynamicLinker.h.

◆ m_ProgramStart

uintptr_t DynamicLinker::m_ProgramStart
private

Definition at line 125 of file DynamicLinker.h.


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