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 =
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...
#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 |
|
|
|
Parameter | Description |
|
|
ip_value | An address. The instruction pointer value of the requested library. |
|
|
desc | A buffer of memory allocated by the user program. The dynamic loader fills this in with |
| module information. |
|
|
desc_size | Size in bytes of the desc buffer. |
|
|
read_tgm_mem | 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. |
|
|
buffer | A buffer supplied by dlmodinfo to read into. ptr The virtual memory address to read from. |
|
|
bufsiz | The size of buffer in bytes. |
|
|
ident | The value of the ident_parm parameter to dlmodinfo. |
|
|
ident_parm | Only used to pass the fourth parameter to read_tgt_mem. |
|
|
load_map_parm | Only used when calling through read_tgt_mem. Contains the starting address of the load |
| map. |
|
|
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
160 Shared Library Management Routines