The Pedigree Project  0.1
Classes | Public Member Functions | Static Public Member Functions | 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 (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)
 
ElfgetProgramElf ()
 
uintptr_t resolve (String name)
 

Static Public Member Functions

static uintptr_t resolvePlt (SyscallState &state)
 

Private Member Functions

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

Private Attributes

Elfm_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 37 of file DynamicLinker.h.

Constructor & Destructor Documentation

DynamicLinker::DynamicLinker ( )

Creates a new DynamicLinker object.

Definition at line 53 of file DynamicLinker.cc.

DynamicLinker::DynamicLinker ( DynamicLinker other)

Creates a new DynamicLinker from another. Copies all mappings.

Definition at line 59 of file DynamicLinker.cc.

Member Function Documentation

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.

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 50 of file DynamicLinker.h.

Referenced by PosixSubsystem::invoke().

+ Here is the caller graph for this function:

Elf* DynamicLinker::getProgramElf ( )
inline

Returns the program ELF.

Definition at line 86 of file DynamicLinker.h.

void DynamicLinker::initPlt ( Elf pElf,
uintptr_t  value 
)
private
Todo:
ARMify
Todo:
Change this to use the size of the elf!
Todo:
Page size here.
Todo:
Page size here.

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

References PhysicalMemoryManager::allocatePage(), ERROR, VirtualAddressSpace::Execute, Elf::getGlobalOffsetTable(), Processor::information(), PhysicalMemoryManager::instance(), NOTICE, WARNING, and VirtualAddressSpace::Write.

Referenced by loadObject(), and loadProgram().

+ Here is the caller graph for this function:

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 246 of file DynamicLinker.cc.

References Elf::allocate(), List< T, nodePoolSize >::begin(), Elf::create(), Elf::createNeededOnly(), List< T, nodePoolSize >::end(), ERROR, VFS::find(), Symlink::followLink(), Symlink::fromFile(), File::getName(), initPlt(), RadixTree< T >::insert(), VFS::instance(), MemoryMapManager::instance(), File::isSymlink(), RadixTree< T >::lookup(), MemoryMapManager::mapFile(), Elf::neededLibraries(), NOTICE, and WARNING.

Referenced by loadProgram().

+ Here is the caller graph for this function:

bool DynamicLinker::loadProgram ( File pFile,
bool  bDryRun = false,
bool  bInterpreter = false,
String sInterpreter = 0 
)
DynamicLinker& DynamicLinker::operator= ( const DynamicLinker )
private

Operator= is unused and is therefore private.

uintptr_t DynamicLinker::resolve ( String  name)

Manually resolves a given symbol name.

Definition at line 439 of file DynamicLinker.cc.

References SymbolTable::lookup().

uintptr_t DynamicLinker::resolvePlt ( SyscallState &  state)
static

Callback given to KernelCoreSyscallManager to resolve PLT relocations lazily.

Definition at line 44 of file DynamicLinker.cc.

References Processor::information(), and resolvePltSymbol().

Referenced by DLTrapHandler::trap().

+ Here is the caller graph for this function:

uintptr_t DynamicLinker::resolvePltSymbol ( uintptr_t  libraryId,
uintptr_t  symIdx 
)
private
Todo:
Why is there a /4 here?

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

References Elf::applySpecificRelocation(), ERROR, Hex, NOTICE, and SymbolTable::NotOriginatingElf.

Referenced by resolvePlt().

+ Here is the caller graph for this function:

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 367 of file DynamicLinker.cc.

References PhysicalMemoryManager::allocatePage(), ERROR, VirtualAddressSpace::Execute, PhysicalMemoryManager::getPageSize(), Processor::information(), PhysicalMemoryManager::instance(), Elf::load(), VirtualAddressSpace::map(), WARNING, and VirtualAddressSpace::Write.

Referenced by DLTrapHandler::trap().

+ Here is the caller graph for this function:


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