LLVM API Documentation

llvm::sys::DynamicLibrary Class Reference

#include <DynamicLibrary.h>

Collaboration diagram for llvm::sys::DynamicLibrary:

Collaboration graph
[legend]

List of all members.

Implementation

void * handle
 DynamicLibrary (const DynamicLibrary &)
 Do not implement.
DynamicLibraryoperator= (const DynamicLibrary &)

Public Member Functions

Constructors
 DynamicLibrary ()
 Open program as dynamic library.
 ~DynamicLibrary ()
 Closes the DynamicLibrary.

Static Public Member Functions

Functions
static bool LoadLibraryPermanently (const char *filename, std::string *ErrMsg=0)
 Open a dynamic library permanently.
static void * SearchForAddressOfSymbol (const char *symbolName)
 Search through libraries for address of a symbol.
static void * SearchForAddressOfSymbol (const std::string &symbolName)
 Convenience function for C++ophiles.
static void AddSymbol (const char *symbolName, void *symbolValue)
 Add searchable symbol/value pair.
static void AddSymbol (const std::string &symbolName, void *symbolValue)
 Convenience function for C++ophiles.


Detailed Description

This class provides a portable interface to dynamic libraries which also might be known as shared libraries, shared objects, dynamic shared objects, or dynamic link libraries. Regardless of the terminology or the operating system interface, this class provides a portable interface that allows dynamic libraries to be loaded and and searched for externally defined symbols. This is typically used to provide "plug-in" support. It also allows for symbols to be defined which don't live in any library, but rather the main program itself, useful on Windows where the main executable cannot be searched.

Definition at line 32 of file DynamicLibrary.h.


Constructor & Destructor Documentation

DynamicLibrary::DynamicLibrary (  ) 

Open program as dynamic library.

Construct a DynamicLibrary that represents the currently executing program. The program must have been linked with -export-dynamic or -dlopen self for this to work.

Exceptions:
std::string indicating why the program couldn't be opened.

Definition at line 54 of file DynamicLibrary.cpp.

DynamicLibrary::~DynamicLibrary (  ) 

Closes the DynamicLibrary.

After destruction, the symbols of the library will no longer be available to the program.

Definition at line 56 of file DynamicLibrary.cpp.

References H, and OpenedHandles.

llvm::sys::DynamicLibrary::DynamicLibrary ( const DynamicLibrary  )  [protected]

Do not implement.


Member Function Documentation

bool DynamicLibrary::LoadLibraryPermanently ( const char *  filename,
std::string *  ErrMsg = 0 
) [static]

Open a dynamic library permanently.

This function allows a library to be loaded without instantiating a DynamicLibrary object. Consequently, it is marked as being permanent and will only be unloaded when the program terminates. This returns false on success or returns true and fills in *ErrMsg on failure.

Definition at line 63 of file DynamicLibrary.cpp.

References H, and OpenedHandles.

Referenced by llvm::ExecutionEngine::create(), llvm::ExecutionEngine::createJIT(), and llvm::PluginLoader::operator=().

void * DynamicLibrary::SearchForAddressOfSymbol ( const char *  symbolName  )  [static]

Search through libraries for address of a symbol.

This function will search through all previously loaded dynamic libraries for the symbol symbolName. If it is found, the addressof that symbol is returned. If not, null is returned. Note that this will search permanently loaded libraries (LoadLibraryPermanently) as well as ephemerally loaded libraries (constructors).

Exceptions:
std::string on error.

Definition at line 75 of file DynamicLibrary.cpp.

References E, EXPLICIT_SYMBOL, g_symbols, I, and OpenedHandles.

Referenced by llvm::ExecutionEngine::emitGlobals(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToNamedFunction(), and SearchForAddressOfSymbol().

static void* llvm::sys::DynamicLibrary::SearchForAddressOfSymbol ( const std::string &  symbolName  )  [inline, static]

Convenience function for C++ophiles.

Definition at line 70 of file DynamicLibrary.h.

References SearchForAddressOfSymbol().

void llvm::sys::DynamicLibrary::AddSymbol ( const char *  symbolName,
void *  symbolValue 
) [static]

Add searchable symbol/value pair.

This functions permanently adds the symbol symbolName with the value symbolValue. These symbols are searched before any libraries.

Definition at line 23 of file DynamicLibrary.cpp.

References g_symbols.

Referenced by AddSymbol().

static void llvm::sys::DynamicLibrary::AddSymbol ( const std::string &  symbolName,
void *  symbolValue 
) [inline, static]

Convenience function for C++ophiles.

Definition at line 81 of file DynamicLibrary.h.

References AddSymbol().

DynamicLibrary& llvm::sys::DynamicLibrary::operator= ( const DynamicLibrary  )  [protected]

Do not implement


Member Data Documentation

Definition at line 89 of file DynamicLibrary.h.


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



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.