diff options
author | Florian Weimer <fweimer@redhat.com> | 2022-10-27 11:36:44 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2022-10-27 11:36:44 +0200 |
commit | 6f360366f7f76b158a0f4bf20d42f2854ad56264 (patch) | |
tree | 28f8951950311cfab96b60143e28ef96d9f9d036 /elf/dl-fini.c | |
parent | a65ff76c9a1811dd2396ab45563f645579c0e687 (diff) | |
download | glibc-6f360366f7f76b158a0f4bf20d42f2854ad56264.tar glibc-6f360366f7f76b158a0f4bf20d42f2854ad56264.tar.gz glibc-6f360366f7f76b158a0f4bf20d42f2854ad56264.tar.bz2 glibc-6f360366f7f76b158a0f4bf20d42f2854ad56264.zip |
elf: Introduce to _dl_call_fini
This consolidates the destructor invocations from _dl_fini and
dlclose. Remove the micro-optimization that avoids
calling _dl_call_fini if they are no destructors (as dlclose is quite
expensive anyway). The debug log message is now printed
unconditionally.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/dl-fini.c')
-rw-r--r-- | elf/dl-fini.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/elf/dl-fini.c b/elf/dl-fini.c index 030b1fcbcd..50ff94db16 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -21,11 +21,6 @@ #include <ldsodefs.h> #include <elf-initfini.h> - -/* Type of the constructor functions. */ -typedef void (*fini_t) (void); - - void _dl_fini (void) { @@ -116,38 +111,7 @@ _dl_fini (void) if (l->l_init_called) { - /* Make sure nothing happens if we are called twice. */ - l->l_init_called = 0; - - /* Is there a destructor function? */ - if (l->l_info[DT_FINI_ARRAY] != NULL - || (ELF_INITFINI && l->l_info[DT_FINI] != NULL)) - { - /* When debugging print a message first. */ - if (__builtin_expect (GLRO(dl_debug_mask) - & DL_DEBUG_IMPCALLS, 0)) - _dl_debug_printf ("\ncalling fini: %s [%lu]\n\n", - DSO_FILENAME (l->l_name), - ns); - - /* First see whether an array is given. */ - if (l->l_info[DT_FINI_ARRAY] != NULL) - { - ElfW(Addr) *array = - (ElfW(Addr) *) (l->l_addr - + l->l_info[DT_FINI_ARRAY]->d_un.d_ptr); - unsigned int i = (l->l_info[DT_FINI_ARRAYSZ]->d_un.d_val - / sizeof (ElfW(Addr))); - while (i-- > 0) - ((fini_t) array[i]) (); - } - - /* Next try the old-style destructor. */ - if (ELF_INITFINI && l->l_info[DT_FINI] != NULL) - DL_CALL_DT_FINI - (l, l->l_addr + l->l_info[DT_FINI]->d_un.d_ptr); - } - + _dl_call_fini (l); #ifdef SHARED /* Auditing checkpoint: another object closed. */ _dl_audit_objclose (l); |