Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

Guardian Native C Library Calls (a - e) dlsym(3)
NAME
dlsym - Obtains the address of an external symbol in a dynamic-link library
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZRLDSRL
G-series native OSS processes: /G/system/sysnn/zrldsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZRLDDLL
H-series and J-series OSS processes: /G/system/zdllnnn/zrlddll
SYNOPSIS
#include <dlfcn.h>
void *dlsym (
dlHandle dlopen_handle,
const char *symbol_name
);
PARAMETERS
dlopen_handle Species a currently valid library handle previously returned by a call to the
dlopen( ) function
symbol_name Species a pointer to a null-terminated character string for a symbol represented
in the dynamic symbol table
The symbol name must be in the form used by the linker, and is always case-
sensitive. C++ function identifiers are "mangled" to include template, class, and
parameter information. For simple function names, avoid mangled names by
using the optional extern "C" declarator in the C++ compilation of the loadle
exporting the symbol, when the function is not a class member, a template ela-
boration, or overloaded.
DESCRIPTION
The dlsym() function allows a process to obtain the address of an external symbol defined within
any loadle currently loaded in the process.
A dlopen_handle returned by a call of the form dlopen(0, mode) causes the symbol search to
occur on the cumulative loadList (that is, on the main program and all the explicit libraries
currently loaded in the process, in the order they were loaded initially by rld and subsequently by
calls to dlopen()). Otherwise, the symbol search is done on the loadList of the library designated
by the object_pathname value in the dlopen() invocation that returned the dlopen_handle (that
is, starting with that library followed by the breadth-first transitive closure of its libList). Import
and re-export controls are ignored.
NOTES
The rld dynamic loader is an unprivileged interface; it cannot be invoked from a program or
DLL that is licensed or has callable functions, or from a program with a priv entry point. Process
creation fails if such a file refers to dlopen(), dlsym(), dlclose(), dlerror(),ordlresultcode().
Depending upon the circumstances, process-creation error/detail value combinations of 77,11 or
78,7 can result.
EXAMPLES
The dlsym() function is typically used to declare pointers of the appropriate function or data
types, and to assign the typecast addresses returned by dlsym() to those pointers. For example:
typedef int (*someFunction_p) (int); // pointer to function
// of int returning int
typedef struct someData { ... } someData; // structure
someFunction_p theFunction; // pointer to function
// "theFunction" in "mydll"
527192-018 Hewlett-Packard Company 1171