summaryrefslogtreecommitdiff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-05-04 04:30:13 +0000
committerUlrich Drepper <drepper@redhat.com>2003-05-04 04:30:13 +0000
commitf866314b89d56845f55e6f365e18b31ec978ec3a (patch)
tree24177a21031b2cc13c60cbf6901c9b652dc2ea99 /elf/rtld.c
parent003f9e7223a13d1c482424deb294647d35dbec92 (diff)
Update.
2003-04-22 Roland McGrath <roland@redhat.com> * elf/elf.h (AT_SYSINFO_EHDR): New macro, replaces AT_SYSINFO_EH_FRAME. * sysdeps/generic/ldsodefs.h (struct rtld_global): Remove dl_sysinfo_eh_frame member, add dl_sysinfo_dso member instead. * elf/dl-support.c: Update defn. * sysdeps/generic/libc-start.c: Don't call __register_frame_info_bases. * sysdeps/generic/dl-sysdep.c (_dl_sysdep_start) [NEED_DL_SYSINFO]: Set GL(dl_sysinfo_dso) from AT_SYSINFO_EHDR. (_dl_show_auxv): Grok AT_SYSINFO_EHDR, not AT_SYSINFO_EH_FRAME. * elf/rtld.c (dl_main) [NEED_DL_SYSINFO]: If GL(dl_sysinfo_dso) is set, set up a link_map for the preloaded, prelinked object.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 9d2a94c492..e9e781aa95 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1069,6 +1069,48 @@ of this helper program; chances are you did not intend to run this program.\n\
assert (i == npreloads);
}
+#ifdef NEED_DL_SYSINFO
+ if (GL(dl_sysinfo_dso) != NULL)
+ {
+ /* We have a prelinked DSO preloaded by the system. */
+ GL(dl_sysinfo) = GL(dl_sysinfo_dso)->e_entry;
+
+ /* Do an abridged version of the work _dl_map_object_from_fd would do
+ to map in the object. It's already mapped and prelinked (and
+ better be, since it's read-only and so we couldn't relocate it).
+ We just want our data structures to describe it as if we had just
+ mapped and relocated it normally. */
+ struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL);
+ if (__builtin_expect (l != NULL, 1))
+ {
+ l->l_phdr = ((const void *) GL(dl_sysinfo_dso)
+ + GL(dl_sysinfo_dso)->e_phoff);
+ l->l_phnum = GL(dl_sysinfo_dso)->e_phnum;
+ for (uint_fast16_t i = 0; i < l->l_phnum; ++i)
+ {
+ const ElfW(Phdr) *const ph = &l->l_phdr[i];
+ if (ph->p_type == PT_DYNAMIC)
+ {
+ l->l_ld = (void *) ph->p_vaddr;
+ l->l_ldnum = ph->p_memsz / sizeof (ElfW(Dyn));
+ break;
+ }
+ if (ph->p_type == PT_LOAD)
+ assert ((void *) ph->p_vaddr == GL(dl_sysinfo_dso));
+ }
+ elf_get_dynamic_info (l);
+ _dl_setup_hash (l);
+ l->l_relocated = 1;
+
+ /* Now that we have the info handy, use the DSO image's soname
+ so this object can be looked up by name. */
+ if (l->l_info[DT_SONAME] != NULL)
+ l->l_libname->name = ((char *) D_PTR (l, l_info[DT_STRTAB])
+ + l->l_info[DT_SONAME]->d_un.d_val);
+ }
+ }
+#endif
+
/* Load all the libraries specified by DT_NEEDED entries. If LD_PRELOAD
specified some libraries to load, these are inserted before the actual
dependencies in the executable's searchlist for symbol resolution. */