diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-09-01 17:19:00 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-09-01 17:19:00 +0000 |
commit | a8a1269d8814fe54d5d25619ca138849bca29b78 (patch) | |
tree | e0b08b062f4003cdb7912c771517fb6a3df0fb91 /elf/dl-close.c | |
parent | 052b6a6c94cc330dfbc09ff7b5f03c943deb7ca2 (diff) | |
download | glibc-a8a1269d8814fe54d5d25619ca138849bca29b78.tar.gz glibc-a8a1269d8814fe54d5d25619ca138849bca29b78.tar.xz glibc-a8a1269d8814fe54d5d25619ca138849bca29b78.zip |
Update.
1998-09-01 15:36 Ulrich Drepper <drepper@cygnus.com> * malloc/Makefile: Include Makeconfig before testing config-sysdirs. * malloc/mtrace.c: Add bug report address. Update email address. Add more @XXX@ to print correct address size. * elf/dl-addr.c (_dl_addr): Make sure that map to be examined is really initialized. * elf/dl-close.c (_dl_close): Use l_map_start and l_map_end info for munmap call instead of examining phdr again. Free all malloc()ed strings and arrays.
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r-- | elf/dl-close.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c index 0851e20193..e89e46d51f 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -89,11 +89,6 @@ _dl_close (struct link_map *map) for (i = 0; i < nsearchlist; ++i) --list[i]->l_opencount; - if (map->l_origin != NULL) - free ((char *) map->l_origin); - /* The name always is allocated. */ - free (map->l_name); - /* Check each element of the search list to see if all references to it are gone. */ for (i = 0; i < nsearchlist; ++i) @@ -101,12 +96,10 @@ _dl_close (struct link_map *map) struct link_map *imap = list[i]; if (imap->l_opencount == 0 && imap->l_type == lt_loaded) { + struct libname_list *lnp; + /* That was the last reference, and this was a dlopen-loaded object. We can unmap it. */ - const ElfW(Phdr) *ph; - const ElfW(Phdr) *first, *last; - ElfW(Addr) mapstart, mapend; - if (imap->l_global) { /* This object is in the global scope list. Remove it. */ @@ -122,22 +115,11 @@ _dl_close (struct link_map *map) --_dl_global_scope_end; } - /* We can unmap all the maps at once. We just have to determine - the length and the `munmap' call does the rest. */ - first = last = NULL; - for (ph = imap->l_phdr; ph < imap->l_phdr + imap->l_phnum; ++ph) - if (ph->p_type == PT_LOAD) - { - if (first == NULL) - first = ph; - last = ph; - } - - /* Now we have all the information we need for the unmapping. - See the method used in `_dl_map_object_from_fd'. */ - mapstart = first->p_vaddr & ~(first->p_align - 1); - mapend = last->p_vaddr + last->p_memsz; - __munmap ((caddr_t) (imap->l_addr + mapstart), mapend - mapstart); + /* We can unmap all the maps at once. We determined the + length when we loaded the object and `munmap' call does + the rest. */ + __munmap ((void *) imap->l_map_start, + imap->l_map_end - imap->l_map_start); /* Finally, unlink the data structure and free it. */ #ifdef PIC @@ -155,6 +137,23 @@ _dl_close (struct link_map *map) imap->l_next->l_prev = imap->l_prev; if (imap->l_searchlist && imap->l_searchlist != list) free (imap->l_searchlist); + + if (imap->l_versions != NULL) + free (imap->l_versions); + if (imap->l_origin != NULL) + free ((char *) imap->l_origin); + + /* These names always is allocated. */ + free (imap->l_name); + lnp = imap->l_libname; + do + { + free (lnp->name); + lnp = lnp->next; + } + while (lnp != NULL); + free (imap->l_libname); + free (imap); } } |