Base Framework
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
DynamicLinker Class Reference

Dynamic linker loader. More...

#include <base/dl/DynamicLinker.h>

Classes

struct  StaticFunctionDescriptor
 
class  SymbolInfo
 

Public Types

enum  Options { LAZY = 1, GLOBAL = 2 }
 
enum  Flags { CONTINUE = 1 }
 
typedef void(* Function) ()
 

Public Member Functions

 DynamicLinker (const String &module, unsigned int options=LAZY)
 
void * getSymbol (const String &symbol) const
 
void * getSymbol (const Literal &symbol) const
 
void * getUncertainSymbol (const String &symbol) const noexcept
 
void * getUncertainSymbol (const Literal &symbol) const noexcept
 
bool import (StaticFunctionDescriptor *functions, unsigned int numberOfFunctions, bool flags=0) noexcept
 
 ~DynamicLinker () noexcept(false)
 

Static Public Member Functions

template<class TYPE >
static TYPE getGlobalSymbol (const String &symbol)
 
static void * getGlobalSymbol (const char *symbol) noexcept
 
static void * getModule (const char *path) noexcept
 
static void * getProcessImage () noexcept
 
static void * getBaseFrameworkImage () noexcept
 
static void * getImageAddress (const void *address) noexcept
 
static String getImagePath (const void *address)
 
static void * getSymbolAddress (const void *address) noexcept
 
static String getSymbolName (const void *address)
 
static SymbolInfo getSymbolInfo (const void *address) noexcept
 

Detailed Description

Dynamic linker loader.

This class provides on-demand loading of (shared) objects.

Version
1.2

Member Enumeration Documentation

◆ Flags

Flags for use with import method.

Enumerator
CONTINUE 

Continue to import symbols when symbol is not available.

◆ Options

Linker options.

Enumerator
LAZY 

Resolve symbols during execution of module.

GLOBAL 

Include symbols of the module in the global symbol pool.

Constructor & Destructor Documentation

◆ DynamicLinker()

DynamicLinker::DynamicLinker ( const String module,
unsigned int  options = LAZY 
)

Opens a Dynamic Shared Object (DSO) with the specified options. LACY relocations may not be supported the particular platform in which case all relocations will be resolved during object initialization.

Parameters
moduleThe path of the module to open.
optionsThe linking options. Default is LAZY.

◆ ~DynamicLinker()

DynamicLinker::~DynamicLinker ( )
noexcept

Closes the module.

Member Function Documentation

◆ getBaseFrameworkImage()

static void* DynamicLinker::getBaseFrameworkImage ( )
staticnoexcept

Returns the image address of the Base Framework model (can be the executable module for static linking).

◆ getGlobalSymbol() [1/2]

static void* DynamicLinker::getGlobalSymbol ( const char *  symbol)
staticnoexcept

Returns address of symbol.

◆ getGlobalSymbol() [2/2]

template<class TYPE >
static TYPE DynamicLinker::getGlobalSymbol ( const String symbol)
inlinestatic

Returns address of symbol.

◆ getImageAddress()

static void* DynamicLinker::getImageAddress ( const void *  address)
staticnoexcept

Returns the image address for the given process address.

◆ getImagePath()

static String DynamicLinker::getImagePath ( const void *  address)
static

Returns the path of the image for the given process address.

◆ getModule()

static void* DynamicLinker::getModule ( const char *  path)
staticnoexcept

Returns the module handle if already loaded.

◆ getProcessImage()

static void* DynamicLinker::getProcessImage ( )
staticnoexcept

Returns the image address of the executable.

◆ getSymbol() [1/2]

void* DynamicLinker::getSymbol ( const Literal symbol) const

Returns the address of the specified symbol.

Parameters
symbolThe symbol to be resolved.
Returns
The address of the symbol.

◆ getSymbol() [2/2]

void* DynamicLinker::getSymbol ( const String symbol) const

Returns the address of the specified symbol.

Parameters
symbolThe symbol to be resolved.
Returns
The address of the symbol.

◆ getSymbolAddress()

static void* DynamicLinker::getSymbolAddress ( const void *  address)
staticnoexcept

Returns the closest symbol for the given process address.

◆ getSymbolInfo()

static SymbolInfo DynamicLinker::getSymbolInfo ( const void *  address)
staticnoexcept

Returns the closest symbol for the given process address.

◆ getSymbolName()

static String DynamicLinker::getSymbolName ( const void *  address)
static

Returns the closest symbol for the given process address.

◆ getUncertainSymbol() [1/2]

void* DynamicLinker::getUncertainSymbol ( const Literal symbol) const
noexcept

Returns the address of the specified symbol.

Parameters
symbolThe symbol to be resolved.
Returns
The address of the symbol (0 is not available).

◆ getUncertainSymbol() [2/2]

void* DynamicLinker::getUncertainSymbol ( const String symbol) const
noexcept

Returns the address of the specified symbol.

Parameters
symbolThe symbol to be resolved.
Returns
The address of the symbol (0 is not available).

◆ import()

bool DynamicLinker::import ( StaticFunctionDescriptor functions,
unsigned int  numberOfFunctions,
bool  flags = 0 
)
noexcept

Imports the addresses of the specified symbols/functions.

Parameters
functionsThe desired functions.
numberOfFunctionsThe number of functions.
flagsThe flags.
Returns
True if all functions are available.