Index of Section 3 Manual Pages
| Interix / SUA | dlsym.3 | Interix / SUA |
dlsym(3) dlsym(3)
dlsym()
NAME
dlsym() - get the address of a symbol from a dynamically-linked object
SYNOPSIS
#include
void *dlsym(void *handle, const char *name)
DESCRIPTION
The dlsym(3) call retrieves the address of a symbol defined in the object
referenced by handle. The object must have already been opened by a call
to dlopen(3). The symbol is stored in name as a character string.
If loading the object referenced by handle caused other objects to be
automatically loaded, all of those objects are searched by the dlsym(3)
call. Dlsym(3) operations on the global symbol object use load ordering.
However, the symbols are resolved in dependency order (see the dlopen(3)
reference page).
RETURN VALUES
The dlsym(3) call returns NULL if the handle doesn't refer to a valid
object, or if the symbol can't be found in any of the objects associated
with handle. For more detailed information, use dlerror(3).
EXAMPLE
Here's a brief example of using dlopen(3) and dlsym(3):
void *handle;
int *iptr, (*fptr)(int);
/* open the object */
handle = dlopen("/usr/lib/libc.so", RTLD_LAZY);
/* find the address of a data object */
iptr = (int *)dlsym(handle, "an_object");
/* find the address of a function */
fptr = (int (*)(int))dlsym(handle, "a_function");
NOTES
There is a special purpose value for handle, RTLD_NEXT, that is reserved
for future use.
SEE ALSO
dlclose(3)
dlerror(3)
dlopen(3)
USAGE NOTES
The dlsym function is thread safe.
The dlsym function is not async-signal safe.