summaryrefslogtreecommitdiff
path: root/src/ldso/dynlink.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-07-26 14:41:12 -0400
committerRich Felker <dalias@aerifal.cx>2013-07-26 14:41:12 -0400
commita97a050eca5167404667f38ad3b5bbc86f987e69 (patch)
tree09b9f0b30a9028e6d69eb4a85295138cc53a10d2 /src/ldso/dynlink.c
parent876748ead3de7798623c09af835a4b56dcc28e0f (diff)
downloadmusl-a97a050eca5167404667f38ad3b5bbc86f987e69.tar.gz
musl-a97a050eca5167404667f38ad3b5bbc86f987e69.tar.bz2
musl-a97a050eca5167404667f38ad3b5bbc86f987e69.tar.xz
musl-a97a050eca5167404667f38ad3b5bbc86f987e69.zip
make ldd report the libc/dynamic linker itself
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r--src/ldso/dynlink.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index ff416838..1ef981ae 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -458,6 +458,18 @@ static struct dso *load_library(const char *name)
size_t l = z-name;
for (rp=reserved; *rp && memcmp(name+3, rp, l-3); rp+=strlen(rp)+1);
if (*rp) {
+ if (ldd_mode) {
+ /* Track which names have been resolved
+ * and only report each one once. */
+ static unsigned reported;
+ unsigned mask = 1U<<(rp-reserved);
+ if (!(reported & mask)) {
+ reported |= mask;
+ dprintf(1, "\t%s => %s (%p)\n",
+ name, ldso->name,
+ ldso->base);
+ }
+ }
if (!ldso->prev) {
tail->next = ldso;
ldso->prev = tail;
@@ -941,6 +953,16 @@ void *__dynlink(int argc, char **argv)
lib->name = ldname;
app->name = argv[0];
aux[AT_ENTRY] = (size_t)app->base + ehdr->e_entry;
+ /* Find the name that would have been used for the dynamic
+ * linker had ldd not taken its place. */
+ if (ldd_mode) {
+ for (i=0; i<app->phnum; i++) {
+ if (app->phdr[i].p_type == PT_INTERP)
+ lib->name = (void *)(app->base
+ + app->phdr[i].p_vaddr);
+ }
+ dprintf(1, "\t%s (%p)\n", lib->name, lib->base);
+ }
}
if (app->tls_size) {
app->tls_id = tls_cnt = 1;