#define _GNU_SOURCE
#include
#include
#include
static int callback (struct dl_phdr_info *info, size_t size, void *data)
{
int j;
printf("name=%s (%d segments)\n", info->dlpi_name, info->dlpi_phnum);
printf("obj base: %10p\n",(void*)info->dlpi_addr);
for (j = 0; j < info->dlpi_phnum; j++) {
void* addr = (void *) (info->dlpi_addr + info->dlpi_phdr[j].p_vaddr);
printf ("\t header %2d: address=%10p", j, addr);
Dl_info dlinfo;
dladdr(addr, &dlinfo);
printf("\t %s:%s\n", dlinfo.dli_fname, dlinfo.dli_sname);
}
return 0;
}
int main (int argc,char *argv[])
{
dl_iterate_phdr (callback, NULL);
pause();
return 0;
}
阅读(1370) | 评论(0) | 转发(0) |