This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] dlfcn: Add dlinfo_sname to obtain the soname for a handle
- From: Yann Droneaud <ydroneaud at opteya dot com>
- To: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Mon, 07 Oct 2019 15:13:00 +0200
- Subject: Re: [PATCH] dlfcn: Add dlinfo_sname to obtain the soname for a handle
- References: <87tv8klnpq.fsf@oldenburg2.str.redhat.com>
Hi,
commit title contains a typo.
Le lundi 07 octobre 2019 à 14:55 +0200, Florian Weimer a écrit :
> A separate function (as opposed to enhancing dlinfo) provides type
> safety.
>
> -----
> Note: Not posting a ChangeLog entry, on the assumption that we will
> switch to automatic generation.
>
> diff --git a/NEWS b/NEWS
> index 2ea7378d10..543791b6ab 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -24,6 +24,8 @@ Major new features:
> * The dladdr1 function accepts a new flag, RTLD_DL_HANDLE, to obtain a
> handle (as used with dlsym and other functions) based on an address.
>
> +* The dlinfo_soname function has been added to the <dlfcn.h> header file.
> +
What about using name dlfname() to match Dl_info::dli_fname field ?
> Deprecated and removed features, and other changes affecting compatibility:
>
> * The totalorder and totalordermag functions, and the corresponding
[...]
> diff --git a/dlfcn/dlfcn.h b/dlfcn/dlfcn.h
> index b657f2762f..31c4ff7082 100644
> --- a/dlfcn/dlfcn.h
> +++ b/dlfcn/dlfcn.h
> @@ -199,6 +199,13 @@ typedef struct
> Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */
> # endif
> } Dl_serinfo;
> +
> +/* Return a string with the soname for the object identified by HANDLE
> + (which must have been obtained from dlopen or dlmopen). The result
> + is NULL if the object does not have a soname (either an explicit or
> + an implied one). */
> +extern const char *dlinfo_soname (void *handle) __THROW __nonnull ((1));
> +
>
How will it behave with pseudo handle RTLD_DEFAULT and RTLD_NEXT ?
RTLD_DEFAULT being equal to 0, the compiler could show a warning, but
dlinfo_soname() would crash trying to derefence it. Same for RTLD_NEXT.
It should also be noted the returned string is only valid during the
lifetime of the handle.
Regards.
--
Yann Droneaud
OPTEYA