Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Nov 2013 00:20:10 -0500
From:      Mark Johnston <markj@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   dl_iterate_phdr() omits ld-elf.so
Message-ID:  <20131106052010.GB2826@raichu>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131106052010.GB2826>