This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFE: dl_iterate_phdr, r_debug.r_brk usability for introspection
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Rich Felker <dalias at libc dot org>
- Cc: John Reiser <jreiser at bitwagon dot com>, libc-alpha at sourceware dot org
- Date: Wed, 23 Sep 2015 13:33:04 -0700 (PDT)
- Subject: Re: RFE: dl_iterate_phdr, r_debug.r_brk usability for introspection
- Authentication-results: sourceware.org; auth=none
- References: <55F5A822 dot 1050609 at bitwagon dot com> <20150923190438 dot GD17773 at brightrain dot aerifal dot cx>
> I just remembered: there's already an equivalent API from one or more
> of the BSDs (I'd have to look back to see which) that was adopted in
> musl. See:
>
> http://git.musl-libc.org/cgit/musl/tree/include/link.h#n27
>
> Rather than inventing something new and gratuitously incompatible it
> would be nice if glibc could adopt the same member names (and layout).
> We also have the TLS module id (for use with __tls_get_addr) and image
> pointer available there.
Your musl source link shows:
struct dl_phdr_info {
ElfW(Addr) dlpi_addr;
const char *dlpi_name;
const ElfW(Phdr) *dlpi_phdr;
ElfW(Half) dlpi_phnum;
unsigned long long int dlpi_adds;
unsigned long long int dlpi_subs;
size_t dlpi_tls_modid;
void *dlpi_tls_data;
};
while the glibc definition reads:
struct dl_phdr_info
{
ElfW(Addr) dlpi_addr;
const char *dlpi_name;
const ElfW(Phdr) *dlpi_phdr;
ElfW(Half) dlpi_phnum;
/* Note: Following members were introduced after the first
version of this structure was available. Check the SIZE
argument passed to the dl_iterate_phdr callback to determine
whether or not each later member is available. */
/* Incremented when a new object may have been added. */
__extension__ unsigned long long int dlpi_adds;
/* Incremented when an object may have been removed. */
__extension__ unsigned long long int dlpi_subs;
/* If there is a PT_TLS segment, its module ID as used in
TLS relocations, else zero. */
size_t dlpi_tls_modid;
/* The address of the calling thread's instance of this module's
PT_TLS segment, if it has one and it has been allocated
in the calling thread, otherwise a null pointer. */
void *dlpi_tls_data;
};
I think I invented dlpi_tls_{modid,data} in commit
d78efd9f369a8fc46229fc9224e10e3781eecc43 (2006-02-28 in ChangeLog.16).
dlip_{adds,subs} were added in commit bed12f78fab86b2349cab6e7f4c0e46bde5e9711
(2004-01-23 in ChangeLog.14).
I suspect all of that was before any BSD had dl_iterate_phdr.
So, I guess the answer is, "You're welcome."
Thanks,
Roland