The shl_gethandle and shl_gethandle_r Routines

The shl_gethandle and shl_gethandle_r routines return descriptor information about a loaded shared library.

Syntax

int shl_gethandle( shl_t handle,

struct shl_descriptor **desc )

Parameters

handle The handle of the shared library you want information about. This handle is the same as that returned by shl_load. desc Points to shared library descriptor information - the same information returned by the shl_get routine. The buffer used to store this desc information is static, meaning that subsequent calls to shl_gethandle overwrites the same area with new data. Therefore, if you need to save the desc information, copy it elsewhere before calling shl_gethandle again.

Return Value

If handle is not valid, the routine returns -1 and sets errno to EINVAL. Otherwise, shl_gethandle returns 0.

Description

The shl_gethandle routine returns descriptor information about a loaded shared library. If you are programming in a threaded environment, use the thread-safe version shl_gethandle_r which is the same as shl_gethandle in all other respects. (See Programming with Threads on HP-UXfor more information about threads.)

Example

The following function named show_lib_info displays information about a shared library, given the library's handle.

show_lib_info - Display Information for a Shared Library

#include <stdio.h> #include <dl.h>

int show_lib_info(shl_t libH)

{

struct shl_descriptor *desc;

if (shl_gethandle(libH, &desc) == -1)

{

fprintf(stderr, "Invalid library handle.\\n"); return -1;

}

 

printf("library path:

%s\\n", desc->filename);

printf("text start:

%#10lx\\n", desc->tstart);

printf("text end:

%#10lx\\n", desc->tend);

printf("data start:

%#10lx\\n", desc->dstart);

printf("data end:

%#10lx\\n", desc->dend);

return 0;

 

}

The shl_definesym Routine

The shl_definesym routine adds new symbols to the global shared library symbol table.

The shl_load Shared Library Management Routines 177