HP-UX Linker and Libraries User's Guide

Parameters
DefinitionParameter
A pointer to a shared library handle of the library to search for the symbol name sym. This handle
can be obtained from the shl_get routine (“The shl_get and shl_get_r Routines (page 175)). The
handle parameter can also point to:
handle
If a pointer to NULL is specified, shl_findsym searches all loaded
libraries for sym. If sym is found, shl_findsym sets handle to a
NULL
pointer to the handle of the shared library containing sym. This is useful
for determining which library a symbol resides in. For example, the
following code sets handle to a pointer to the handle of the library
containing symbol_foo
shl_t handle;
handle = NULL;
shl_findsym(&handle,"_foo",...);
This constant, defined in dl.h, tells shl_findsym to search for the
symbol in the program itself. This way, any symbols exported from the
program can be accessed explicitly.
PROG_HANDLE
A null-terminated character string containing the name of the symbol to search for.sym
The type of symbol to look for. It must be one of the following values, defined in <dl.h>:type
Looks for a function or procedure.TYPE_PROCEDURE
Looks for a symbol in the data segment (for example, variables).TYPE_DATA
Looks for any symbol.TYPE_UNDEFINED
Same as TYPE_DATATYPE_STORAGE
A pointer in which shl_findsym stores the address of sym, if found.value
Return Value
If successful, shl_findsym returns an integer (int) value zero. If shl_findsym cannot find sym,
it returns -1 and sets errno to zero. If any other errors occur, shl_findsym returns -1 and sets
errno to one of these values (defined in <errno.h>):
DefinitionParameter
A format error was detected in the specified library.ENOEXEC
A symbol on which sym depends cannot be found.ENOSYM
The specified handle is invalid.EINVAL
Description
To call a routine or access data in an explicitly loaded library, first get the address of the routine
or data with shl_findsym. To call a routine in an explicitly loaded library:
1. Declare a pointer to a function of the same type as the function in the shared library
2. Using shl_findsym with the type parameter set to TYPE_PROCEDURE, find the symbol in
the shared library and assign its address to the function pointer declared in Step 1
3. Call the pointer to the function obtained in Step 2, with the correct number and type of
arguments
To access data in an explicitly loaded library:
The shl_load Shared Library Management Routines 173