Parameters
Parameter |
| Definition |
|
|
|
handle | 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: | |
|
|
|
| NULL | 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 |
|
| 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",...); |
|
|
|
| PROG_HANDLE | 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. |
|
|
|
sym | A | |
|
|
|
type | The type of symbol to look for. It must be one of the following values, defined in <dl.h>: | |
|
|
|
| TYPE_PROCEDURE | Looks for a function or procedure. |
|
|
|
| TYPE_DATA | Looks for a symbol in the data segment (for example, variables). |
|
|
|
| TYPE_UNDEFINED | Looks for any symbol. |
|
|
|
| TYPE_STORAGE | Same as TYPE_DATA |
|
|
|
value | A pointer in which shl_findsym stores the address of sym, if found. | |
|
|
|
Return Value
If successful, shl_findsym returns an integer (int) value zero. If shl_findsym cannot find sym, it returns
Parameter | Definition |
|
|
ENOEXEC | A format error was detected in the specified library. |
|
|
ENOSYM | A symbol on which sym depends cannot be found. |
|
|
EINVAL | The specified handle is invalid. |
|
|
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