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
This commit is contained in:
Konstantin Belousov 2020-05-22 17:52:09 +00:00
parent 48e9fb855b
commit c8ad15b6ff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361398
3 changed files with 15 additions and 1 deletions

View File

@ -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 memory */
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

View File

@ -1207,6 +1207,9 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
*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_Dyn **dyn_rpath,
}
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

View File

@ -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 {