aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-close.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-10-27 11:36:44 +0200
committerFlorian Weimer <fweimer@redhat.com>2022-10-27 11:36:44 +0200
commit6f360366f7f76b158a0f4bf20d42f2854ad56264 (patch)
tree28f8951950311cfab96b60143e28ef96d9f9d036 /elf/dl-close.c
parenta65ff76c9a1811dd2396ab45563f645579c0e687 (diff)
downloadglibc-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-close.c')
-rw-r--r--elf/dl-close.c42
1 files changed, 1 insertions, 41 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index bcd6e206e9..14deca2e2b 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -36,11 +36,6 @@
#include <dl-unmap-segments.h>
-
-/* Type of the constructor functions. */
-typedef void (*fini_t) (void);
-
-
/* Special l_idx value used to indicate which objects remain loaded. */
#define IDX_STILL_USED -1
@@ -110,31 +105,6 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
return false;
}
-/* Invoke dstructors for CLOSURE (a struct link_map *). Called with
- exception handling temporarily disabled, to make errors fatal. */
-static void
-call_destructors (void *closure)
-{
- struct link_map *map = closure;
-
- if (map->l_info[DT_FINI_ARRAY] != NULL)
- {
- ElfW(Addr) *array =
- (ElfW(Addr) *) (map->l_addr
- + map->l_info[DT_FINI_ARRAY]->d_un.d_ptr);
- unsigned int sz = (map->l_info[DT_FINI_ARRAYSZ]->d_un.d_val
- / sizeof (ElfW(Addr)));
-
- while (sz-- > 0)
- ((fini_t) array[sz]) ();
- }
-
- /* Next try the old-style destructor. */
- if (map->l_info[DT_FINI] != NULL)
- DL_CALL_DT_FINI (map, ((void *) map->l_addr
- + map->l_info[DT_FINI]->d_un.d_ptr));
-}
-
void
_dl_close_worker (struct link_map *map, bool force)
{
@@ -280,17 +250,7 @@ _dl_close_worker (struct link_map *map, bool force)
half-cooked objects. Temporarily disable exception
handling, so that errors are fatal. */
if (imap->l_init_called)
- {
- /* 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",
- imap->l_name, nsid);
-
- if (imap->l_info[DT_FINI_ARRAY] != NULL
- || imap->l_info[DT_FINI] != NULL)
- _dl_catch_exception (NULL, call_destructors, imap);
- }
+ _dl_catch_exception (NULL, _dl_call_fini, imap);
#ifdef SHARED
/* Auditing checkpoint: we remove an object. */