about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-31 17:23:45 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-31 17:23:45 +0000
commit7afab53d438e9fdc3060c20cf855235aa5ef6f49 (patch)
tree2e6dcf9891303ea88e048c86faab6c4a1377a9e8
parentbfce746a87e205a682b85e144e056029a8a30d07 (diff)
downloadglibc-7afab53d438e9fdc3060c20cf855235aa5ef6f49.tar.gz
glibc-7afab53d438e9fdc3060c20cf855235aa5ef6f49.tar.xz
glibc-7afab53d438e9fdc3060c20cf855235aa5ef6f49.zip
Update.
1998-08-31  Ulrich Drepper  <drepper@cygnus.com>

	* elf/dl-close.c (_dl_close): Update _dl_loaded if the first
	object on the list is removed.  Don't use this code for PIC.
	Reported by HJ Lu [PR libc/770].
-rw-r--r--ChangeLog6
-rw-r--r--elf/dl-close.c11
-rw-r--r--linuxthreads/ChangeLog3
-rw-r--r--linuxthreads/sysdeps/i386/i686/pt-machine.h6
-rw-r--r--linuxthreads/sysdeps/i386/pt-machine.h8
5 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b00f5157eb..750136ad06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1998-08-31  Ulrich Drepper  <drepper@cygnus.com>
+
+	* elf/dl-close.c (_dl_close): Update _dl_loaded if the first
+	object on the list is removed.  Don't use this code for PIC.
+	Reported by HJ Lu [PR libc/770].
+
 1998-08-31 15:56  Ulrich Drepper  <drepper@cygnus.com>
 
 	* db2/db_int.h: Use <db.h> instead of "db.h" to find header in include.
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 0d4b176b1e..bbbeed8e58 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <assert.h>
 #include <dlfcn.h>
 #include <stdlib.h>
 #include <string.h>
@@ -139,8 +140,16 @@ _dl_close (struct link_map *map)
 	  __munmap ((caddr_t) (imap->l_addr + mapstart), mapend - mapstart);
 
 	  /* Finally, unlink the data structure and free it.  */
-	  if (imap->l_prev)
+#ifdef PIC
+	  /* We will unlink the first object only if this is a statically
+	     linked program.  */
+	  assert (imap->l_prev != NULL);
+#else
+	  if (imap->l_prev != NULL)
 	    imap->l_prev->l_next = imap->l_next;
+	  else
+	    _dl_loaded = imap->l_next;
+#endif
 	  if (imap->l_next)
 	    imap->l_next->l_prev = imap->l_prev;
 	  if (imap->l_searchlist && imap->l_searchlist != list)
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 88cf853c84..66847d4416 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,6 +1,7 @@
 1998-08-31  Ulrich Drepper  <drepper@cygnus.com>
 
-	* sysdeps/i386/pt-machine.h (testandset): Add memory clobber.
+	* sysdeps/i386/i686/pt-machine.h (testandset): Add memory clobber.
+	* sysdeps/i386/pt-machine.h: Likewise
 	Suggested by Roland McGrath.
 
 1998-08-28 13:58  Ulrich Drepper  <drepper@cygnus.com>
diff --git a/linuxthreads/sysdeps/i386/i686/pt-machine.h b/linuxthreads/sysdeps/i386/i686/pt-machine.h
index a4b3a63f1c..d01e6cf368 100644
--- a/linuxthreads/sysdeps/i386/i686/pt-machine.h
+++ b/linuxthreads/sysdeps/i386/i686/pt-machine.h
@@ -26,9 +26,11 @@ testandset (int *spinlock)
 {
   int ret;
 
-  __asm__ __volatile__("xchgl %0, %1"
+  __asm__ __volatile__ (
+	"xchgl %0, %1"
 	: "=r"(ret), "=m"(*spinlock)
-	: "0"(1), "m"(*spinlock));
+	: "0"(1), "m"(*spinlock)
+	: "memory");
 
   return ret;
 }
diff --git a/linuxthreads/sysdeps/i386/pt-machine.h b/linuxthreads/sysdeps/i386/pt-machine.h
index 6723c80bda..7ed90b7553 100644
--- a/linuxthreads/sysdeps/i386/pt-machine.h
+++ b/linuxthreads/sysdeps/i386/pt-machine.h
@@ -26,9 +26,11 @@ testandset (int *spinlock)
 {
   int ret;
 
-  __asm__ __volatile__("xchgl %0, %1"
-	: "=r"(ret), "=m"(*spinlock)
-	: "0"(1), "m"(*spinlock));
+  __asm__ __volatile__(
+       "xchgl %0, %1"
+       : "=r"(ret), "=m"(*spinlock)
+       : "0"(1), "m"(*spinlock)
+       : "memory");
 
   return ret;
 }