about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-16 18:30:44 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-16 18:30:44 +0000
commit22bc79788225fb13ff8e66d38e0dd92d44b1e588 (patch)
tree4245a0b22a3abc3601bc9924b5d3452dba61e7c8 /elf
parent6760028826b40e45fe7f12b3e1ec934b032dba55 (diff)
downloadglibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.tar.gz
glibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.tar.xz
glibc-22bc79788225fb13ff8e66d38e0dd92d44b1e588.zip
Update.
1998-03-15  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* posix/wordexp-test.c: Add more tests.
	(testit): Fix logic.

	* posix/wordexp.c (exec_comm): In the child, redirect stderr to
	/dev/null instead of closing it, close pipe.  Always chop off all
	trailing newlines.  Kill and reap child before returning error.
	(w_addword, parse_glob): Fix memory leak.
	(wordexp): Fix dangling pointer problem.

1998-03-16  Ulrich Drepper  <drepper@cygnus.com>

	* elf/dl-close.c (_dl_close): Correct and simplify unmapping.

	* posix/wordexp-test.c (main): Fix little thinkos and typos.

	* catgets/Makefile (CPPFLAGS): Change NLSPATH to also examine
	directory index by only the language.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-close.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 253b073367..f2155031e6 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -80,7 +80,8 @@ _dl_close (struct link_map *map)
 	  /* That was the last reference, and this was a dlopen-loaded
 	     object.  We can unmap it.  */
 	  const ElfW(Phdr) *ph;
-	  const ElfW(Phdr) *eph;
+	  const ElfW(Phdr) *first, *last;
+	  ElfW(Addr) mapstart, mapend;
 
 	  if (imap->l_info[DT_FINI])
 	    /* Call its termination function.  */
@@ -100,24 +101,23 @@ _dl_close (struct link_map *map)
 	      _dl_global_scope_end[1] = NULL;
 	    }
 
-	  /* Find the first entry specifying a load command.  We have
-	     to determine this now since the table itself is also loaded.  */
-	  for (eph = imap->l_phdr; eph < imap->l_phdr + imap->l_phnum; ++eph)
-	    if (eph->p_type == PT_LOAD)
-	      break;
-
-	  /* Unmap the segments.  */
-	  for (ph = imap->l_phdr + (imap->l_phnum - 1); ph >= eph; --ph)
+	  /* 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)
 	      {
-		ElfW(Addr) mapstart = ph->p_vaddr & ~(ph->p_align - 1);
-		ElfW(Addr) mapend = ((ph->p_vaddr + ph->p_memsz
-				      + ph->p_align - 1)
-				     & ~(ph->p_align - 1));
-		__munmap ((caddr_t) (imap->l_addr + mapstart),
-			  mapend - mapstart);
+		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);
+
 	  /* Finally, unlink the data structure and free it.  */
 	  if (imap->l_prev)
 	    imap->l_prev->l_next = imap->l_next;