Date: Fri, 22 May 2020 17:52:09 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361398 - in head: lib/libc/gen libexec/rtld-elf sys/sys Message-ID: <202005221752.04MHq9cv050207@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri May 22 17:52:09 2020 New Revision: 361398 URL: https://svnweb.freebsd.org/changeset/base/361398 Log: Implement Solaris-like link_map l_refname member. The implementation is based on the public documentation, in particular dlinfo(3) from Solaris. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/lib/libc/gen/dlinfo.3 head/libexec/rtld-elf/rtld.c head/sys/sys/link_elf.h Modified: head/lib/libc/gen/dlinfo.3 ============================================================================== --- head/lib/libc/gen/dlinfo.3 Fri May 22 17:45:07 2020 (r361397) +++ head/lib/libc/gen/dlinfo.3 Fri May 22 17:52:09 2020 (r361398) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 19, 2020 +.Dd May 21, 2020 .Dt DLINFO 3 .Os .Sh NAME @@ -111,6 +111,7 @@ const void *l_ld; /* Pointer to .dynamic in m struct link_map *l_next, /* linked list of mapped libs */ *l_prev; caddr_t l_addr; /* Load Offset of library */ +const char *l_refname; /* Object this one filters for */ .Ed .Bl -tag -width ".Va l_addr" .It Va l_base @@ -133,6 +134,11 @@ structure on the link-map list. The load offset of the object, that is, the difference between the actual load address and the base virtual address the object was linked at. +.It Va l_refname +A name of the object this object filters for, if any. +If there are more then one filtee, a name from the first +.Dv DT_FILTER +dynamic entry is supplied. .El .It Dv RTLD_DI_SERINFO Retrieve the library search paths associated with the given Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Fri May 22 17:45:07 2020 (r361397) +++ head/libexec/rtld-elf/rtld.c Fri May 22 17:52:09 2020 (r361398) @@ -1207,6 +1207,9 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_D *needed_filtees_tail = nep; needed_filtees_tail = &nep->next; + + if (obj->linkmap.l_refname == NULL) + obj->linkmap.l_refname = (char *)dynp->d_un.d_val; } break; @@ -1402,6 +1405,10 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_D } obj->dynsymcount += obj->symndx_gnu; } + + if (obj->linkmap.l_refname != NULL) + obj->linkmap.l_refname = obj->strtab + (unsigned long)obj-> + linkmap.l_refname; } static bool Modified: head/sys/sys/link_elf.h ============================================================================== --- head/sys/sys/link_elf.h Fri May 22 17:45:07 2020 (r361397) +++ head/sys/sys/link_elf.h Fri May 22 17:52:09 2020 (r361398) @@ -65,6 +65,7 @@ typedef struct link_map { const void *l_ld; /* Pointer to .dynamic in memory */ struct link_map *l_next, *l_prev; /* linked list of of mapped libs */ caddr_t l_addr; /* Load Offset of library */ + const char *l_refname; /* object we are filtering for */ } Link_map; struct r_debug {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005221752.04MHq9cv050207>