[PATCH v5 15/22] elf: Run constructors if executable has a soname of a dependency
Florian Weimer
fweimer@redhat.com
Thu Nov 11 12:30:48 GMT 2021
* Adhemerval Zanella:
> The DSO constructor should not be ignored if the main executable
> has the SONAME set to a dependency. It fixes the case where
> (using the scripts/dso-ordering-test.py definition):
>
> {}->a->b->c;soname({})=c
>
> Where the constructors should return
>
> c>b>a>{}<a<b<c
>
> Checked on x86_64-linux-gnu.
> ---
> elf/dl-load.c | 9 +++++++--
> elf/dso-sort-tests-1.def | 5 ++++-
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index 4a0ff9d010..d585e1795d 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -1998,13 +1998,18 @@ _dl_map_object (struct link_map *loader, const char *name,
> assert (nsid >= 0);
> assert (nsid < GL(dl_nns));
>
> + /* Special case: trying to map itself. */
> + if (name[0] == '\0')
> + return GL(dl_ns)[nsid]._ns_loaded;
Can you expand the comment a bit? As far as I can see, "" corresponds
to a NULL argument for dlopen, and we interpret that as returning the
head object of the namespace. The head link map must exist because the
dlopen call with NULL/"" has to come from some.
Do you know if we have explict tests for this behavior?
The change itself looks okay. The reference count is updated by the
caller in elf/dl-open.c.
Thanks,
Florian
More information about the Libc-alpha
mailing list