From a709dd439a010a88e6e8ae94583e71296008b89e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 20 May 1998 10:50:03 +0000 Subject: Update. 1998-05-20 Andreas Jaeger * Makeconfig (rpath-link): Add resolvobjdir. (resolvobjdir): New variable. Reported by Peter Breitenlohner [fixes PR libc/633]. 1998-05-20 09:36 Ulrich Drepper * elf/dl-close.c: Call shared object terminators at the right time. Patch by Philippe Troin . 1998-05-20 Andreas Schwab * Make-dist (+tsrcs): Also add *.map for every member of $(extra-libs). * Makefile (distribute): Don't distribute scripts/printsources and scripts/=__ify. Distribute FAQ.in. (rpm/%): Don't pass subdirs to sub-make. * timezone/Makefile: Protect inclusion of z.* by $(avoid-generated) instead of $(no_deps). 1998-05-19 Andreas Schwab * sysdeps/generic/setenv.c: Protect against GNU C extension. (KNOWN_VALUE, STORE_VALUE): Do it right. (setenv): Remove unused variable. 1998-05-18 Andreas Schwab * timezone/Makefile (tz-cflags): Define TM_GMTOFF and TM_ZONE. (CFLAGS-zdump.c): Add $(tz-cflags). * timezone/zdump.c (abbr): Use TM_ZONE if defined. Add const to return type. 1998-05-18 Andreas Schwab * time/tzfile.c (__tzfile_compute): Undo last change. Instead take struct tm parameter and set tm_isdst, tm_zone and tm_offset if use_localtime. * time/tzset.c: Update prototype of __tzfile_compute. (__tz_convert): Pass tp to __tzfile_compute. Don't set tm_isdst, tm_zone and tm_offset here if __use_tzfile. 1998-05-19 Andreas Schwab * Makerules: Install libc.a even if there are no object file. 1998-05-18 Andreas Schwab * Makerules (do-makelib): Don't force creating library from scratch, to avoid wasting time and space and to get correct behaviour if $(subdirs) is incomplete. 1998-05-19 Andreas Schwab * Makerules (do-stamp): Make it work when building in source directory. --- elf/dl-close.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'elf/dl-close.c') diff --git a/elf/dl-close.c b/elf/dl-close.c index 70b2e60..49deb96 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -47,30 +47,39 @@ _dl_close (struct link_map *map) __libc_lock_lock (_dl_load_lock); /* Decrement the reference count. */ - if (--map->l_opencount > 0 || map->l_type != lt_loaded) + if (map->l_opencount > 1 || map->l_type != lt_loaded) { /* There are still references to this object. Do nothing more. */ + --map->l_opencount; __libc_lock_unlock (_dl_load_lock); return; } + list = map->l_searchlist; + + /* Call all termination functions at once. */ + for (i = 0; i < map->l_nsearchlist; ++i) + { + struct link_map *imap = list[i]; + if (imap->l_opencount == 1 && imap->l_type == lt_loaded) + { + if (imap->l_info[DT_FINI]) + /* Call its termination function. */ + (*(void (*) (void)) ((void *) imap->l_addr + + imap->l_info[DT_FINI]->d_un.d_ptr)) (); + } + } + /* Notify the debugger we are about to remove some loaded objects. */ _r_debug.r_state = RT_DELETE; _dl_debug_state (); - list = map->l_searchlist; - /* The search list contains a counted reference to each object it points to, the 0th elt being MAP itself. Decrement the reference counts on all the objects MAP depends on. */ - for (i = 1; i < map->l_nsearchlist; ++i) + for (i = 0; i < map->l_nsearchlist; ++i) --list[i]->l_opencount; - /* Clear the search list so it doesn't get freed while we are still - using it. We have cached it in LIST and will free it when - finished. */ - map->l_searchlist = NULL; - /* Check each element of the search list to see if all references to it are gone. */ for (i = 0; i < map->l_nsearchlist; ++i) @@ -84,11 +93,6 @@ _dl_close (struct link_map *map) const ElfW(Phdr) *first, *last; ElfW(Addr) mapstart, mapend; - if (imap->l_info[DT_FINI]) - /* Call its termination function. */ - (*(void (*) (void)) ((void *) imap->l_addr + - imap->l_info[DT_FINI]->d_un.d_ptr)) (); - if (imap->l_global) { /* This object is in the global scope list. Remove it. */ @@ -126,7 +130,7 @@ _dl_close (struct link_map *map) imap->l_prev->l_next = imap->l_next; if (imap->l_next) imap->l_next->l_prev = imap->l_prev; - if (imap->l_searchlist) + if (imap->l_searchlist && imap->l_searchlist != list) free (imap->l_searchlist); free (imap); } -- cgit v1.1