summaryrefslogtreecommitdiff
path: root/elf/dl-close.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r--elf/dl-close.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 3618b13da7..0fbeecc4cd 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -115,6 +115,22 @@ _dl_close (struct link_map *map)
++cnt;
}
--_dl_main_searchlist->r_nlist;
+ if (_dl_main_searchlist->r_nlist
+ == _dl_initial_searchlist.r_nlist)
+ {
+ /* All object dynamically loaded by the program are
+ unloaded. Free the memory allocated for the global
+ scope variable. */
+ struct link_map **old = _dl_main_searchlist->r_list;
+
+ /* Put the old map in. */
+ _dl_main_searchlist->r_list = _dl_initial_searchlist.r_list;
+ /* Signal that the old map is used. */
+ _dl_global_scope_alloc = 0;
+
+ /* Now free the old map. */
+ free (old);
+ }
}
/* We can unmap all the maps at once. We determined the