Loader API is defined in the common/utils/load_module_shlib.h include file.
int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf)
- possibly initializes the loader, if it has not been already initialized
- Formats the full shared library path, using the
modname
argument and the loadershlibpath
andshlibversion
configuration parameters. - loads the shared library, using the dlopen system call
- looks for
< modname >_autoinit
symbol, using thedlsym
system call and possibly call the corresponding function. - looks for
< modname >_checkbuildver
symbol, using thedlsym
system call and possibly calls the corresponding function. If the return value of this call is-1
, program execution is stopped. It is the responsibility of the shared library developer to implement or not a< modname >_checkbuildver
function and to decide if a version mismatch is a fatal condition. The< modname >_checkbuildver
function must match thecheckverfunc_t
function type. The first argument is the main executable version, as set in thePACKAGE_VERSION
macro defined in the oai CMakeLists, around line 218. The second argument points to the shared library version which should be set by the< modname >_checkbuildver
function. - If the farray pointer is null, looks for
< modname >_getfarray
symbol, calls the corresponding function when the symbol is found.< modname >_getfarray
takes one argument, a pointer to aloader_shlibfunc_t
array, and returns the number of items in this array, as defined by thegetfarrayfunc_t
type. Theloader_shlibfunc_t
array returned by the shared library must be fully filled (bothfname
andfptr
fields). - looks for the
numf
function symbols listed in thefarray[i].fname
arguments and set the correspondingfarray[i].fptr
function pointers
void * get_shlibmodule_fptr(char *modname, char *fname)
Returns a pointer to the symbol fname
, defined in module modname
, or NULL
if the symbol is not found.