dl_iterate_phdr() omits ld-elf.so
Mark Johnston
markj at freebsd.org
Wed Nov 6 05:20:14 UTC 2013
Hello,
While experimenting with dl_iterate_phdr(3), I noticed that it doesn't
include the runtime linker itself in the list of objects. This is
inconsistent with related interfaces such as <pid>/map in procfs, and
kinfo_getvmmap(3), so it seems incorrect to me that rtld is excluded
from the list of callback arguments.
Is there a reason for this behaviour? If not, does anyone have thoughts
on the diff below which fixes this?
Thanks,
-Mark
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index fa6dc2a..b55effa 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -3269,6 +3269,11 @@ dl_iterate_phdr(__dl_iterate_hdr_callback callback, void *param)
break;
}
+ if (error == 0) {
+ rtld_fill_dl_phdr_info(&obj_rtld, &phdr_info);
+ error = callback(&phdr_info, sizeof(phdr_info), param);
+ }
+
lock_release(rtld_bind_lock, &bind_lockstate);
lock_release(rtld_phdr_lock, &phdr_lockstate);
More information about the freebsd-hackers
mailing list