User's Manual
Using dlget to retrieve information about loaded modules
The following code sequence shows how to use dlget to retrieve information about loaded
modules. The code sequence prints the text base of all loaded modules:
void* handle;
int index;
struct load_module_desc desc;
for (index = -2; ; i++) { handle = dlget(i, &desc, sizeof(struct load_module_desc));
if (handle = NULL) {
printf("%s\n", dlerror());
break;
}
else {
printf("library %d text base = %lx\n", index,
desc.text_base);
}
}
The dlmodinfo Routine
The dlmodinfo routine retrieves information about a loaded module (program or shared library).
Syntax
cc [flag...] file... -ldl [library]...
#include <dlfcn.h> unsigned long dlmodinfo(unsigned long ip_value,
struct load_module_desc *desc,
size_t desc_size,
void *(*read_tgt_mem)(void* buffer,
unsigned long ptr,
size_t bufsiz,
int ident),
int ident_parm,
uint64_t load_map_parm);
Table 27 Parameters
DescriptionParameter
An address. The instruction pointer value of the requested library.ip_value
A buffer of memory allocated by the user program. The dynamic loader fills this in with
module information.
desc
Size in bytes of the desc buffer.desc_size
A pointer to a function used by dlmodinfo to retrieve needed information. If the value is
NULL, the dynamic loader uses its own internal data structures to find the correct load
module and ignore the ident_parm and load_map_parm parameters.
read_tgm_mem
A buffer supplied by dlmodinfo to read into. ptr The virtual memory address to read from.buffer
The size of buffer in bytes.bufsiz
The value of the ident_parm parameter to dlmodinfo.ident
Only used to pass the fourth parameter to read_tgt_mem.ident_parm
Only used when calling through read_tgt_mem. Contains the starting address of the load
map.
load_map_parm
Return Values
If successful, dlmodinfo returns a handle for the shared library as defined by the return value
from dlopen(). NULL is returned otherwise. The return values are type-converted to unsigned
long
160 Shared Library Management Routines