[PATCH v2] elf: Make more functions available for binding during dlclose (bug 30425)

Florian Weimer fweimer@redhat.com
Thu May 25 19:06:16 GMT 2023


* Carlos O'Donell:

> On 5/22/23 07:32, Florian Weimer via Libc-alpha wrote:
>> Previously, after destructors for a DSO have been invoked, ld.so refused
>> to bind against that DSO in all cases.  Relax this restriction somewhat
>> if the referencing object is itself a DSO that is being unloaded.  This
>> assumes that the symbol reference is not going to be stored anywhere.
>
> The truth here is that the example has a circular reference due to the
> interposition which makes it have an undefined load and unload
> order. You wrote a very specific test that *avoids* needing anything
> from mod1 during mod2's initialization.

It's possible to create this situation with C++ code due to vague
linkage.  No explicit interposition is needed.  I didn't want to
incorporate the C++ test case because it's brittle: it depends on which
functions the compiler emits.  (It has some leeway because of vague
linkage.)

> Having said all that we should *choose* an unload order that is the
> opposite of the load order and make it consistent, and if we could
> load it we should not fail to unload it because of a limitation of the
> dynamic loader. We might still fail due to some logical dependency in
> user code though.
>
> The DT_NEEDED in mod1 ensures we load: mod2 then mod1.  The closing of
> mod1 should unload: mod1 then mod2 (opposite order).
>
> This consistent order should make it easier for users to debug other
> problems in their library designs.

Yeah, sure?  But that's how it's always been?

>> The situation in the test case can arise fairly easily with C++ and
>> objects that are built with different optimization levels and therefore
>> define different functions with vague linkage.
>
> Please post a v3.

With the comment updates?  Or some other changes?

Thanks,
Florian



More information about the Libc-alpha mailing list