mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
Revert "elf: Always call destructors in reverse constructor order (bug 30785)"
This reverts commit6985865bc3
. Reason for revert: The commit changes the order of ELF destructor calls too much relative to what applications expect or can handle. In particular, during process exit and _dl_fini, after the revert commit, we no longer call the destructors of the main program first; that only happens after some dlopen'ed objects have been destructed. This robs applications of an opportunity to influence destructor order by calling dlclose explicitly from the main program's ELF destructors. A couple of different approaches involving reverse constructor order were tried, and none of them worked really well. It seems we need to keep the dependency sorting in _dl_fini. There is also an ambiguity regarding nested dlopen calls from ELF constructors: Should those destructors run before or after the object that called dlopen? Commit6985865bc3
used reverse order of the start of ELF constructor calls for destructors, but arguably using completion of constructors is more correct. However, that alone is not sufficient to address application compatibility issues (it does not change _dl_fini ordering at all).
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include <ldsodefs.h>
|
||||
#include <elf-initfini.h>
|
||||
|
||||
struct link_map *_dl_init_called_list;
|
||||
|
||||
static void
|
||||
call_init (struct link_map *l, int argc, char **argv, char **env)
|
||||
@@ -43,21 +42,6 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
|
||||
dependency. */
|
||||
l->l_init_called = 1;
|
||||
|
||||
/* Help an already-running dlclose: The just-loaded object must not
|
||||
be removed during the current pass. (No effect if no dlclose in
|
||||
progress.) */
|
||||
l->l_map_used = 1;
|
||||
|
||||
/* Record execution before starting any initializers. This way, if
|
||||
the initializers themselves call dlopen, their ELF destructors
|
||||
will eventually be run before this object is destructed, matching
|
||||
that their ELF constructors have run before this object was
|
||||
constructed. _dl_fini uses this list for audit callbacks, so
|
||||
register objects on the list even if they do not have a
|
||||
constructor. */
|
||||
l->l_init_called_next = _dl_init_called_list;
|
||||
_dl_init_called_list = l;
|
||||
|
||||
/* Check for object which constructors we do not run here. */
|
||||
if (__builtin_expect (l->l_name[0], 'a') == '\0'
|
||||
&& l->l_type == lt_executable)
|
||||
|
Reference in New Issue
Block a user