The change in bug 30785 to use reverse constructor orders for destructors does not match expectations of existing applications when objects are destructed by _dl_fini. In particular, the destructors for the main program need to run first. This may trigger additional destructor invocations if dlclose is called. After the main program, the initially loaded objects should be destroyed, potentially triggering more dlclose calls. Only after that, the remaining dlopen'ed objects should be destroyed. This way, applications have some control over destructor ordering through there dlclose calls, which seems useful. A similar issue occurs if dlopen is called from ELF constructors: The current code schedules an object for later destruction *before* it invokes ELF constructors. This means that dlopen'ed objects from ELF constructors may be destructed first, even if the original object calling dlopen might want to close these objects by calling dlclose from its destructor. These changes mostly apply to _dl_fini because when dlclose calls ELF destructors, explicitly dlopen'ed objects (from ELF constructors etc.) still have incremented direct-open counters, and they only become eligible for destruction if invoked ELF destructors invoke dlclose.
Patches posted: [PATCH 0/3] Fine-tune ELF destructor ordering (bug 30869) <https://inbox.sourceware.org/libc-alpha/cover.1695113064.git.fweimer@redhat.com/>
This change has been abandoned after the changes from bug 30785 have been reverted.