Dynamic shared object handling¶
mm_dl_fileext¶
#include <mmdlfcn.h>
-
const char*
mm_dl_fileext
(void)¶ get usual shared library extension
Parameters: - void – no arguments
Return¶
the usual shared library extension of the platform.
mm_dlopen¶
#include <mmdlfcn.h>
-
mm_dynlib_t*
mm_dlopen
(const char* path, int flags)¶ Load library dynamically
Parameters: - path (const char*) – path of the library to load
- flags (int) – flags controlling how the library is loaded
Description¶
This function makes the symbols (function identifiers and data object
identifiers) in the shared library specified by path
available to the
calling process. A successful mm_dlopen()
returns an handle which the
caller may use on subsequent calls to mm_dlsym()
and mm_dlclose()
.
If path
is NULL, this will return a handle to the main program.
The behavior of the function can be controlled by flags
which must be a
OR-combination of the following flags:
- MM_LD_LAZY
- Relocations shall be performed at an implementation-defined time,
ranging from the time of the
mm_dlopen()
call until the first reference to a given symbol occurs. Currently, this has no effect on Windows platform. - MM_LD_NOW
- All necessary relocations shall be performed when shared library is
first loaded. This may waste some processing if relocations are
performed for symbols that are never referenced. This behavior may be
useful for applications that need to know that all symbols referenced
during execution will be available before
mm_dlopen()
returns. Currently this is the only possible behavior for Windows platform. - MM_LD_APPEND_EXT
- If set,
mm_dlopen()
append automatically the usual file extension of a shared library (OS dependent) topath
and load this file instead. This flag allows to write code that is fully platform independent.
Return¶
In case of success, mm_dlopen()
return a non-NULL handle.
Otherwise NULL is returned and error state is set accordingly.
See also¶
mm_dlclose¶
#include <mmdlfcn.h>
-
void
mm_dlclose
(mm_dynlib_t* handle)¶ Close an handle of an dynamic library
Parameters: - handle (mm_dynlib_t*) – handle of library to close
Description¶
this informs the system that the library specified by handle is no longer
needed by the application. Once the handle has been closed, an
application should assume that any symbols (function identifiers and data
object identifiers) made visible using handle
, are no longer available
to the process.
Return¶
0 in case of success, -1 otherwise with error state set accordingly
mm_dlsym¶
#include <mmdlfcn.h>
-
void*
mm_dlsym
(mm_dynlib_t* handle, const char* symbol)¶ get the address of a symbol from library handle
Parameters: - handle (mm_dynlib_t*) – handle of library
- symbol (const char*) – function or a data object identifier
Description¶
This obtain the address of a symbol (a function identifier or a data object identifier) defined in the symbol table identified by the handle argument.
Return¶
pointer to the symbol if found, NULL otherwise with error state set acccordingly