1
1
/* Close a shared object opened by `_dl_open'.
2
Copyright (C) 1996-2007, 2009 Free Software Foundation, Inc.
2
Copyright (C) 1996-2007, 2009, 2010 Free Software Foundation, Inc.
3
3
This file is part of the GNU C Library.
5
5
The GNU C Library is free software; you can redistribute it and/or
749
749
__rtld_lock_unlock_recursive (GL(dl_load_lock));
753
static bool __libc_freeres_fn_section
754
free_slotinfo (struct dtv_slotinfo_list **elemp)
759
/* Nothing here, all is removed (or there never was anything). */
762
if (!free_slotinfo (&(*elemp)->next))
763
/* We cannot free the entry. */
766
/* That cleared our next pointer for us. */
768
for (cnt = 0; cnt < (*elemp)->len; ++cnt)
769
if ((*elemp)->slotinfo[cnt].map != NULL)
773
/* We can remove the list element. */
781
libc_freeres_fn (free_mem)
783
for (Lmid_t nsid = 0; nsid < GL(dl_nns); ++nsid)
784
if (__builtin_expect (GL(dl_ns)[nsid]._ns_global_scope_alloc, 0) != 0
785
&& (GL(dl_ns)[nsid]._ns_main_searchlist->r_nlist
786
// XXX Check whether we need NS-specific initial_searchlist
787
== GLRO(dl_initial_searchlist).r_nlist))
789
/* All object dynamically loaded by the program are unloaded. Free
790
the memory allocated for the global scope variable. */
791
struct link_map **old = GL(dl_ns)[nsid]._ns_main_searchlist->r_list;
793
/* Put the old map in. */
794
GL(dl_ns)[nsid]._ns_main_searchlist->r_list
795
// XXX Check whether we need NS-specific initial_searchlist
796
= GLRO(dl_initial_searchlist).r_list;
797
/* Signal that the original map is used. */
798
GL(dl_ns)[nsid]._ns_global_scope_alloc = 0;
800
/* Now free the old map. */
804
if (USE___THREAD || GL(dl_tls_dtv_slotinfo_list) != NULL)
806
/* Free the memory allocated for the dtv slotinfo array. We can do
807
this only if all modules which used this memory are unloaded. */
809
if (GL(dl_initial_dtv) == NULL)
810
/* There was no initial TLS setup, it was set up later when
811
it used the normal malloc. */
812
free_slotinfo (&GL(dl_tls_dtv_slotinfo_list));
815
/* The first element of the list does not have to be deallocated.
816
It was allocated in the dynamic linker (i.e., with a different
817
malloc), and in the static library it's in .bss space. */
818
free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)->next);
821
void *scope_free_list = GL(dl_scope_free_list);
822
GL(dl_scope_free_list) = NULL;
823
free (scope_free_list);