int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void *data), void *data) { struct dso *current; Ehdr *ehdr; struct dl_phdr_info info; int ret = 0; for(current = head; current; current = current->next) { ehdr = (Ehdr *)current->map; info.dlpi_addr = (ehdr->e_type == ET_EXEC) ? 0 : current->map; info.dlpi_name = current->shortname; info.dlpi_phdr = (Phdr *)(current->map + ehdr->e_phoff); info.dlpi_phnum = ehdr->e_phnum; ret = (callback)(&info, sizeof (info), data); if (ret != 0) break; } return ret; }