about summary refs log tree commit diff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-03-15 10:33:43 +0100
committerFlorian Weimer <fweimer@redhat.com>2021-03-15 14:43:13 +0100
commit4e6db99c665d3b82a70a3e218860ef087b1555b4 (patch)
tree45764ae3d3a84cb15e2a2efcf28ff0779c2acd86 /elf/dl-load.c
parentf53ffc9b90cbd92fa5518686daf4091bdd1d4889 (diff)
downloadglibc-4e6db99c665d3b82a70a3e218860ef087b1555b4.tar.gz
glibc-4e6db99c665d3b82a70a3e218860ef087b1555b4.tar.xz
glibc-4e6db99c665d3b82a70a3e218860ef087b1555b4.zip
elf: ld.so --help calls _dl_init_paths without a main map [BZ #27577]
In this case, use the link map of the dynamic loader itself as
a replacement.  This is more than just a hack: if we ever support
DT_RUNPATH/DT_RPATH for the dynamic loader, reporting it for
ld.so --help (without further command line arguments) would be the
right thing to do.

Fixes commit 332421312576bd7095e70589154af99b124dd2d1 ("elf: Always
set l in _dl_init_paths (bug 23462)").
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 376a2e64d6..2f760503c5 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -758,8 +758,14 @@ _dl_init_paths (const char *llp, const char *source,
   max_dirnamelen = SYSTEM_DIRS_MAX_LEN;
   *aelem = NULL;
 
-  /* This points to the map of the main object.  */
+  /* This points to the map of the main object.  If there is no main
+     object (e.g., under --help, use the dynamic loader itself as a
+     stand-in.  */
   l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+#ifdef SHARED
+  if (l == NULL)
+    l = &GL (dl_rtld_map);
+#endif
   assert (l->l_type != lt_loaded);
 
   if (l->l_info[DT_RUNPATH])