HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)

d
dlsym(3C) dlsym(3C)
/* invoke function, passing value of integer as a parameter */
i = (*fptr)(*iptr);
The next example shows how one can use
dlsym with RTLD_NEXT to add functionality to an existing
interface. Again, error checking has been omitted.
extern void record_malloc(void *, size_t);
void *
malloc(size_t sz)
{
void *ptr;
void *(*real_malloc)(size_t);
real_malloc = (void * (*) (size_t))
dlsym(RTLD_NEXT, "malloc");
ptr = (*real_malloc)(sz);
record_malloc(ptr, sz);
return ptr;
}
SEE ALSO
dlclose(3C), dlerror(3C), dlopen(3C).
Texts and Tutorials
HP-UX Linker and Libraries Online User Guide
(See the
+help option)
HP-UX Linker and Libraries User’s Guide
(See manuals(5) for ordering information)
Section 3224 Hewlett-Packard Company 2 HP-UX 11i Version 2: September 2004