diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-02-14 07:57:19 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-02-14 07:57:19 +0000 |
commit | fc093be16082b406ee160762d773a791a5b3b965 (patch) | |
tree | 6649027f3fc3c8e9ca1950ded8278175a2ff5fe7 /elf/dl-close.c | |
parent | bb4cb25213ce21326236d72e8633844e4a777a8b (diff) | |
download | glibc-fc093be16082b406ee160762d773a791a5b3b965.zip glibc-fc093be16082b406ee160762d773a791a5b3b965.tar.gz glibc-fc093be16082b406ee160762d773a791a5b3b965.tar.bz2 |
Update.
* elf/dl-close.c (remove_slotinfo): New function. Handles everything
for removing reference of module in slotinfo list.
(_dl_close): Use remove_slotinfo.
* sysdeps/generic/dl-tls.c: General pretty printing.
(oom): Define only if SHARED.
(_dl_next_tls_modid): Correct starting point for the case we assume
there is a gap. Add missing instruction grouping (doh!). Correct
tests for reaching maximum index.
* elf/Makefile: Add rules to build and run tst-tls7.
* elf/tst-tls7.c: New file.
* elf/tst-tlsmod3.c: New file.
* elf/tst-tlsmod1.c: Move #include "tls-macros.h" instead #ifdef
USE_TLS.
* elf/tst-tlsmod2.c: Likewise.
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r-- | elf/dl-close.c | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c index 7e7547d..a594126 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -32,6 +32,58 @@ typedef void (*fini_t) (void); +#ifdef USE_TLS +/* Returns true we an non-empty was found. */ +static bool +remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp) +{ + if (idx - disp >= listp->len) + { + /* There must be a next entry. Otherwise would the index be wrong. */ + assert (listp->next != NULL); + + if (remove_slotinfo (idx, listp->next, disp + listp->len)) + return true; + + /* No non-empty entry. Search from the end of this elements + slotinfo array. */ + idx = disp + listp->len; + } + else + { + struct link_map *old_map = listp->slotinfo[idx - disp].map; + assert (old_map != NULL); + + /* Mark the entry as unused. */ + listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1; + listp->slotinfo[idx - disp].map = NULL; + + /* If this is not the last currently used entry no need to look + further. */ + if (old_map->l_tls_modid != GL(dl_tls_max_dtv_idx)) + return true; + + assert (old_map->l_tls_modid == GL(dl_tls_max_dtv_idx)); + } + + while (idx - disp > disp == 0 ? 1 + GL(dl_tls_static_nelem) : 0) + { + --idx; + + if (listp->slotinfo[idx - disp].map != NULL) + { + /* Found a new last used index. */ + GL(dl_tls_max_dtv_idx) = idx; + return true; + } + } + + /* No non-entry in this list element. */ + return false; +} +#endif + + void internal_function _dl_close (void *_map) @@ -214,25 +266,12 @@ _dl_close (void *_map) TLS. */ if (__builtin_expect (imap->l_tls_blocksize > 0, 0)) { - /* Locate the entry in the slotinfo array. */ - size_t idx = imap->l_tls_modid; - struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list); - - while (idx >= listp->len) - { - idx -= listp->len; - listp = listp->next; - } - - listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1; - listp->slotinfo[idx].map = NULL; - any_tls = true; - if (imap->l_tls_modid == GL(dl_tls_max_dtv_idx)) - --GL(dl_tls_max_dtv_idx); - else - GL(dl_tls_dtv_gaps) = true; + if (! remove_slotinfo (imap->l_tls_modid, + GL(dl_tls_dtv_slotinfo_list), 0)) + /* All dynamically loaded modules with TLS are unloaded. */ + GL(dl_tls_max_dtv_idx) = GL(dl_tls_static_nelem); } #endif |