[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r12743 - in /fsf/glibc-2_13-branch/libc: ./ elf/ shadow/



Author: eglibc
Date: Fri Feb  4 09:45:21 2011
New Revision: 12743

Log:
Import glibc-2.13 for 2011-02-04

Added:
    fsf/glibc-2_13-branch/libc/elf/tst-initorder.c
    fsf/glibc-2_13-branch/libc/elf/tst-initorder.exp
    fsf/glibc-2_13-branch/libc/elf/tst-initordera1.c
    fsf/glibc-2_13-branch/libc/elf/tst-initordera2.c
    fsf/glibc-2_13-branch/libc/elf/tst-initordera3.c
    fsf/glibc-2_13-branch/libc/elf/tst-initordera4.c
    fsf/glibc-2_13-branch/libc/elf/tst-initorderb1.c
    fsf/glibc-2_13-branch/libc/elf/tst-initorderb2.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-a1.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-a2.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-a3.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-a4.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-b1.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-b2.c
    fsf/glibc-2_13-branch/libc/elf/tst-order-main.c
Modified:
    fsf/glibc-2_13-branch/libc/ChangeLog
    fsf/glibc-2_13-branch/libc/NEWS
    fsf/glibc-2_13-branch/libc/elf/Makefile
    fsf/glibc-2_13-branch/libc/elf/dl-deps.c
    fsf/glibc-2_13-branch/libc/elf/dl-fini.c
    fsf/glibc-2_13-branch/libc/elf/dl-runtime.c
    fsf/glibc-2_13-branch/libc/shadow/sgetspent.c

Modified: fsf/glibc-2_13-branch/libc/ChangeLog
==============================================================================
--- fsf/glibc-2_13-branch/libc/ChangeLog (original)
+++ fsf/glibc-2_13-branch/libc/ChangeLog Fri Feb  4 09:45:21 2011
@@ -1,3 +1,42 @@
+2011-02-02  Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	* elf/dl-runtime.c (_dl_call_pltexit): Pass correct address of the
+	function to the callback.
+	Patch partly by Jiri Olsa <jolsa@xxxxxxxxxx>.
+
+2011-02-02  Andreas Schwab  <schwab@xxxxxxxxxx>
+
+	* shadow/sgetspent.c: Check return value of __sgetspent_r instead
+	of errno.
+
+2011-01-19  Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	[BZ #11724]
+	* elf/dl-deps.c (_dl_map_object_deps): Rewrite sorting determining order
+	of constructors.
+	* elf/dl-fini.c (_dl_sort_fini): Rewrite sorting determining order
+	of destructors.
+	(_dl_fini): Don't call _dl_sort_fini if there is only one object.
+
+	[BZ #11724]
+	* elf/Makefile: Add rules to build and run new test.
+	* elf/tst-initorder.c: New file.
+	* elf/tst-initorder.exp: New file.
+	* elf/tst-initordera1.c: New file.
+	* elf/tst-initordera2.c: New file.
+	* elf/tst-initordera3.c: New file.
+	* elf/tst-initordera4.c: New file.
+	* elf/tst-initorderb1.c: New file.
+	* elf/tst-initorderb2.c: New file.
+	* elf/tst-order-a1.c: New file.
+	* elf/tst-order-a2.c: New file.
+	* elf/tst-order-a3.c: New file.
+	* elf/tst-order-a4.c: New file.
+	* elf/tst-order-b1.c: New file.
+	* elf/tst-order-b2.c: New file.
+	* elf/tst-order-main.c: New file.
+	New test case by George Gensure <werkt0@xxxxxxxxx>.
+
 2010-10-01  Andreas Schwab  <schwab@xxxxxxxxxx>
 
 	* sysdeps/posix/getaddrinfo.c (gaih_inet): Don't discard result of

Modified: fsf/glibc-2_13-branch/libc/NEWS
==============================================================================
--- fsf/glibc-2_13-branch/libc/NEWS (original)
+++ fsf/glibc-2_13-branch/libc/NEWS Fri Feb  4 09:45:21 2011
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2011-1-15
+GNU C Library NEWS -- history of user-visible changes.  2011-1-19
 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
 See the end for copying conditions.
 

Modified: fsf/glibc-2_13-branch/libc/elf/Makefile
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/Makefile (original)
+++ fsf/glibc-2_13-branch/libc/elf/Makefile Fri Feb  4 09:45:21 2011
@@ -118,7 +118,10 @@
 		   ifuncmain7.c ifuncmain7pic.c ifuncmain7picstatic.c \
 		   ifuncmain7pie.c ifuncmain7static.c \
 		   tst-unique1.c tst-unique1mod1.c tst-unique1mod2.c \
-		   tst-unique2.c tst-unique2mod1.c tst-unique2mod2.c
+		   tst-unique2.c tst-unique2mod1.c tst-unique2mod2.c \
+			 tst-initordera1.c tst-initordera2.c tst-initorderb1.c \
+			 tst-initorderb2.c tst-initordera3.c tst-initordera4.c \
+			 tst-initorder.c
 
 CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
@@ -198,7 +201,8 @@
 	 unload3 unload4 unload5 unload6 unload7 tst-global1 order2 \
 	 tst-audit1 tst-audit2 \
 	 tst-stackguard1 tst-addr1 tst-thrlock \
-	 tst-unique1 tst-unique2
+	 tst-unique1 tst-unique2 \
+	 tst-initorder
 #	 reldep9
 test-srcs = tst-pathopt
 tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
@@ -250,7 +254,10 @@
 		unload7mod1 unload7mod2 \
 		order2mod1 order2mod2 order2mod3 order2mod4 \
 		tst-unique1mod1 tst-unique1mod2 \
-		tst-unique2mod1 tst-unique2mod2
+		tst-unique2mod1 tst-unique2mod2 \
+		tst-initordera1 tst-initorderb1 \
+		tst-initordera2 tst-initorderb2 \
+		tst-initordera3 tst-initordera4
 ifeq (yes,$(have-initfini-array))
 modules-names += tst-array2dep tst-array5dep
 endif
@@ -531,6 +538,11 @@
 $(objpfx)unload6mod3.so: $(libdl)
 $(objpfx)unload7mod1.so: $(libdl)
 $(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
+$(objpfx)tst-initordera2.so: $(objpfx)tst-initordera1.so
+$(objpfx)tst-initorderb2.so: $(objpfx)tst-initorderb1.so $(objpfx)tst-initordera2.so
+$(objpfx)tst-initordera3.so: $(objpfx)tst-initorderb2.so $(objpfx)tst-initorderb1.so
+$(objpfx)tst-initordera4.so: $(objpfx)tst-initordera3.so
+$(objpfx)tst-initorder: $(objpfx)tst-initordera4.so $(objpfx)tst-initordera1.so $(objpfx)tst-initorderb2.so
 
 LDFLAGS-tst-tlsmod5.so = -nostdlib
 LDFLAGS-tst-tlsmod6.so = -nostdlib
@@ -1162,6 +1174,12 @@
 $(objpfx)tst-unique2: $(libdl) $(objpfx)tst-unique2mod1.so
 $(objpfx)tst-unique2.out: $(objpfx)tst-unique2mod2.so
 
+$(objpfx)tst-initorder.out: $(objpfx)tst-initorder
+	$(elf-objpfx)${rtld-installed-name} \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $< > $@
+	cmp $@ tst-initorder.exp > /dev/null
+
 ifeq (yes,$(config-cflags-avx))
 CFLAGS-tst-audit4.c += -mavx
 CFLAGS-tst-auditmod4a.c += -mavx

Modified: fsf/glibc-2_13-branch/libc/elf/dl-deps.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/dl-deps.c (original)
+++ fsf/glibc-2_13-branch/libc/elf/dl-deps.c Fri Feb  4 09:45:21 2011
@@ -1,5 +1,5 @@
 /* Load the dependencies of a mapped object.
-   Copyright (C) 1996-2003, 2004, 2005, 2006, 2007, 2010
+   Copyright (C) 1996-2003, 2004, 2005, 2006, 2007, 2010, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -591,7 +591,7 @@
 	    /* Need to allocate new array of relocation dependencies.  */
 	    struct link_map_reldeps *l_reldeps;
 	    l_reldeps = malloc (sizeof (*l_reldeps)
-	    			+ map->l_reldepsmax
+				+ map->l_reldepsmax
 				  * sizeof (struct link_map *));
 	    if (l_reldeps == NULL)
 	      /* Bad luck, keep the reldeps duplicated between
@@ -616,48 +616,60 @@
   /* Now determine the order in which the initialization has to happen.  */
   memcpy (l_initfini, map->l_searchlist.r_list,
 	  nlist * sizeof (struct link_map *));
+
   /* We can skip looking for the binary itself which is at the front
-     of the search list.  Look through the list backward so that circular
-     dependencies are not changing the order.  */
-  for (i = 1; i < nlist; ++i)
-    {
-      struct link_map *l = map->l_searchlist.r_list[i];
-      unsigned int j;
-      unsigned int k;
-
-      /* Find the place in the initfini list where the map is currently
-	 located.  */
-      for (j = 1; l_initfini[j] != l; ++j)
-	;
-
-      /* Find all object for which the current one is a dependency and
-	 move the found object (if necessary) in front.  */
-      for (k = j + 1; k < nlist; ++k)
+     of the search list.  */
+  assert (nlist > 1);
+  i = 1;
+  bool seen[nlist];
+  memset (seen, false, nlist * sizeof (seen[0]));
+  while (1)
+    {
+      /* Keep track of which object we looked at this round.  */
+      seen[i] = true;
+      struct link_map *thisp = l_initfini[i];
+
+      /* Find the last object in the list for which the current one is
+	 a dependency and move the current object behind the object
+	 with the dependency.  */
+      unsigned int k = nlist - 1;
+      while (k > i)
 	{
-	  struct link_map **runp;
-
-	  runp = l_initfini[k]->l_initfini;
+	  struct link_map **runp = l_initfini[k]->l_initfini;
 	  if (runp != NULL)
-	    {
-	      while (*runp != NULL)
-		if (__builtin_expect (*runp++ == l, 0))
-		  {
-		    struct link_map *here = l_initfini[k];
-
-		    /* Move it now.  */
-		    memmove (&l_initfini[j] + 1, &l_initfini[j],
-			     (k - j) * sizeof (struct link_map *));
-		    l_initfini[j] = here;
-
-		    /* Don't insert further matches before the last
-		       entry moved to the front.  */
-		    ++j;
-
-		    break;
-		  }
-	    }
+	    /* Look through the dependencies of the object.  */
+	    while (*runp != NULL)
+	      if (__builtin_expect (*runp++ == thisp, 0))
+		{
+		  /* Move the current object to the back past the last
+		     object with it as the dependency.  */
+		  memmove (&l_initfini[i], &l_initfini[i + 1],
+			   (k - i) * sizeof (l_initfini[0]));
+		  l_initfini[k] = thisp;
+
+		  if (seen[i + 1])
+		    {
+		      ++i;
+		      goto next_clear;
+		    }
+
+		  memmove (&seen[i], &seen[i + 1], (k - i) * sizeof (seen[0]));
+		  seen[k] = true;
+
+		  goto next;
+		}
+
+	  --k;
 	}
-    }
+
+      if (++i == nlist)
+	break;
+    next_clear:
+      memset (&seen[i], false, (nlist - i) * sizeof (seen[0]));
+
+    next:;
+    }
+
   /* Terminate the list of dependencies.  */
   l_initfini[nlist] = NULL;
   atomic_write_barrier ();

Modified: fsf/glibc-2_13-branch/libc/elf/dl-fini.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/dl-fini.c (original)
+++ fsf/glibc-2_13-branch/libc/elf/dl-fini.c Fri Feb  4 09:45:21 2011
@@ -1,5 +1,6 @@
 /* Call the termination functions of loaded shared objects.
-   Copyright (C) 1995,96,1998-2002,2004-2005,2009 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,1998-2002,2004-2005,2009,2011
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -32,86 +33,84 @@
 _dl_sort_fini (struct link_map *l, struct link_map **maps, size_t nmaps,
 	       char *used, Lmid_t ns)
 {
-  if (ns == LM_ID_BASE)
-    /* The main executable always comes first.  */
-    l = l->l_next;
-
-  for (; l != NULL; l = l->l_next)
-    /* Do not handle ld.so in secondary namespaces and object which
-       are not removed.  */
-    if (l == l->l_real && l->l_idx != -1)
-      {
-	/* Find the place in the 'maps' array.  */
-	unsigned int j;
-	for (j = ns == LM_ID_BASE ? 1 : 0; maps[j] != l; ++j)
-	  assert (j < nmaps);
-
-	/* Find all object for which the current one is a dependency
-	   and move the found object (if necessary) in front.  */
-	for (unsigned int k = j + 1; k < nmaps; ++k)
-	  {
-	    struct link_map **runp = maps[k]->l_initfini;
-	    if (runp != NULL)
-	      {
-		while (*runp != NULL)
-		  if (*runp == l)
-		    {
-		      struct link_map *here = maps[k];
-
-		      /* Move it now.  */
-		      memmove (&maps[j] + 1,
-			       &maps[j], (k - j) * sizeof (struct link_map *));
-		      maps[j] = here;
-
-		      if (used != NULL)
-			{
-			  char here_used = used[k];
-
-			  memmove (&used[j] + 1,
-				   &used[j], (k - j) * sizeof (char));
-			  used[j] = here_used;
-			}
-
-		      ++j;
-
-		      break;
-		    }
-		  else
-		    ++runp;
-	      }
-
-	    if (__builtin_expect (maps[k]->l_reldeps != NULL, 0))
-	      {
-		unsigned int m = maps[k]->l_reldeps->act;
-		struct link_map **relmaps = &maps[k]->l_reldeps->list[0];
-
-		while (m-- > 0)
-		  {
-		    if (relmaps[m] == l)
-		      {
-			struct link_map *here = maps[k];
-
-			/* Move it now.  */
-			memmove (&maps[j] + 1,
-				 &maps[j],
-				 (k - j) * sizeof (struct link_map *));
-			maps[j] = here;
-
-			if (used != NULL)
-			  {
-			    char here_used = used[k];
-
-			    memmove (&used[j] + 1,
-				     &used[j], (k - j) * sizeof (char));
-			    used[j] = here_used;
-			  }
-
-			break;
-		      }
-		  }
-	      }
-	  }
-      }
+  /* We can skip looking for the binary itself which is at the front
+     of the search list for the main namespace.  */
+  assert (nmaps > 1);
+  unsigned int i = ns == LM_ID_BASE;
+  bool seen[nmaps];
+  memset (seen, false, nmaps * sizeof (seen[0]));
+  while (1)
+    {
+      /* Keep track of which object we looked at this round.  */
+      seen[i] = true;
+      struct link_map *thisp = maps[i];
+
+      /* Do not handle ld.so in secondary namespaces and object which
+	 are not removed.  */
+      if (thisp != thisp->l_real || thisp->l_idx == -1)
+	goto skip;
+
+      /* Find the last object in the list for which the current one is
+	 a dependency and move the current object behind the object
+	 with the dependency.  */
+      unsigned int k = nmaps - 1;
+      while (k > i)
+	{
+	  struct link_map **runp = maps[k]->l_initfini;
+	  if (runp != NULL)
+	    /* Look through the dependencies of the object.  */
+	    while (*runp != NULL)
+	      if (__builtin_expect (*runp++ == thisp, 0))
+		{
+		move:
+		  /* Move the current object to the back past the last
+		     object with it as the dependency.  */
+		  memmove (&maps[i], &maps[i + 1],
+			   (k - i) * sizeof (maps[0]));
+		  maps[k] = thisp;
+
+		  if (used != NULL)
+		    {
+		      char here_used = used[i];
+		      memmove (&used[i], &used[i + 1],
+			       (k - i) * sizeof (used[0]));
+		      used[k] = here_used;
+		    }
+
+		  if (seen[i + 1])
+		    {
+		      ++i;
+		      goto next_clear;
+		    }
+
+		  memmove (&seen[i], &seen[i + 1], (k - i) * sizeof (seen[0]));
+		  seen[k] = true;
+
+		  goto next;
+		}
+
+	  if (__builtin_expect (maps[k]->l_reldeps != NULL, 0))
+	    {
+	      unsigned int m = maps[k]->l_reldeps->act;
+	      struct link_map **relmaps = &maps[k]->l_reldeps->list[0];
+
+	    /* Look through the relocation dependencies of the object.  */
+	      while (m-- > 0)
+		if (__builtin_expect (relmaps[m] == thisp, 0))
+		  goto move;
+	    }
+
+	  --k;
+	}
+
+    skip:
+      if (++i == nmaps)
+	break;
+    next_clear:
+      memset (&seen[i], false, (nmaps - i) * sizeof (seen[0]));
+
+    next:;
+    }
 }
 
 
@@ -196,7 +195,7 @@
       assert (ns == LM_ID_BASE || i == nloaded || i == nloaded - 1);
       nmaps = i;
 
-      if (nmaps != 0)
+      if (nmaps > 1)
 	/* Now we have to do the sorting.  */
 	_dl_sort_fini (GL(dl_ns)[ns]._ns_loaded, maps, nmaps, NULL, ns);
 

Modified: fsf/glibc-2_13-branch/libc/elf/dl-runtime.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/dl-runtime.c (original)
+++ fsf/glibc-2_13-branch/libc/elf/dl-runtime.c Fri Feb  4 09:45:21 2011
@@ -1,5 +1,5 @@
 /* On-demand PLT fixup for shared objects.
-   Copyright (C) 1995-2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1995-2009, 2010, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -446,6 +446,7 @@
 
   /* Set up the sym parameter.  */
   ElfW(Sym) sym = *defsym;
+  sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr);
 
   /* Get the symbol name.  */
   const char *strtab = (const void *) D_PTR (reloc_result->bound,

Added: fsf/glibc-2_13-branch/libc/elf/tst-initorder.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initorder.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initorder.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,7 @@
+#include <stdio.h>
+
+int
+main( int argc, char *argv[] )
+{
+  printf( "main\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-initorder.exp
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initorder.exp (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initorder.exp Fri Feb  4 09:45:21 2011
@@ -1,0 +1,13 @@
+start_a1
+start_a2
+start_b1
+start_b2
+start_a3
+start_a4
+main
+finish_a4
+finish_a3
+finish_b2
+finish_b1
+finish_a2
+finish_a1

Added: fsf/glibc-2_13-branch/libc/elf/tst-initordera1.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initordera1.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initordera1.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a1( void ) __attribute__((constructor));
+extern void finish_a1( void ) __attribute__((destructor));
+
+void
+start_a1( void )
+{
+  printf( "start_a1\n" );
+}
+
+void
+finish_a1( void )
+{
+  printf( "finish_a1\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-initordera2.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initordera2.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initordera2.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a2( void ) __attribute__((constructor));
+extern void finish_a2( void ) __attribute__((destructor));
+
+void
+start_a2( void )
+{
+  printf( "start_a2\n" );
+}
+
+void
+finish_a2( void )
+{
+  printf( "finish_a2\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-initordera3.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initordera3.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initordera3.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a3( void ) __attribute__((constructor));
+extern void finish_a3( void ) __attribute__((destructor));
+
+void
+start_a3( void )
+{
+  printf( "start_a3\n" );
+}
+
+void
+finish_a3( void )
+{
+  printf( "finish_a3\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-initordera4.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initordera4.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initordera4.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a4( void ) __attribute__((constructor));
+extern void finish_a4( void ) __attribute__((destructor));
+
+void
+start_a4( void )
+{
+  printf( "start_a4\n" );
+}
+
+void
+finish_a4( void )
+{
+  printf( "finish_a4\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-initorderb1.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initorderb1.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initorderb1.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_b1( void ) __attribute__((constructor));
+extern void finish_b1( void ) __attribute__((destructor));
+
+void
+start_b1( void )
+{
+  printf( "start_b1\n" );
+}
+
+void
+finish_b1( void )
+{
+  printf( "finish_b1\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-initorderb2.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-initorderb2.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-initorderb2.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_b2( void ) __attribute__((constructor));
+extern void finish_b2( void ) __attribute__((destructor));
+
+void
+start_b2( void )
+{
+  printf( "start_b2\n" );
+}
+
+void
+finish_b2( void )
+{
+  printf( "finish_b2\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-a1.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-a1.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-a1.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a1( void ) __attribute__((constructor));
+extern void finish_a1( void ) __attribute__((destructor));
+
+void
+start_a1( void )
+{
+  printf( "start_a1\n" );
+}
+
+void
+finish_a1( void )
+{
+  printf( "finish_a1\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-a2.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-a2.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-a2.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a2( void ) __attribute__((constructor));
+extern void finish_a2( void ) __attribute__((destructor));
+
+void
+start_a2( void )
+{
+  printf( "start_a2\n" );
+}
+
+void
+finish_a2( void )
+{
+  printf( "finish_a2\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-a3.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-a3.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-a3.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a3( void ) __attribute__((constructor));
+extern void finish_a3( void ) __attribute__((destructor));
+
+void
+start_a3( void )
+{
+  printf( "start_a3\n" );
+}
+
+void
+finish_a3( void )
+{
+  printf( "finish_a3\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-a4.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-a4.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-a4.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_a4( void ) __attribute__((constructor));
+extern void finish_a4( void ) __attribute__((destructor));
+
+void
+start_a4( void )
+{
+  printf( "start_a4\n" );
+}
+
+void
+finish_a4( void )
+{
+  printf( "finish_a4\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-b1.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-b1.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-b1.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_b1( void ) __attribute__((constructor));
+extern void finish_b1( void ) __attribute__((destructor));
+
+void
+start_b1( void )
+{
+  printf( "start_b1\n" );
+}
+
+void
+finish_b1( void )
+{
+  printf( "finish_b1\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-b2.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-b2.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-b2.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,16 @@
+#include <stdio.h>
+
+extern void start_b2( void ) __attribute__((constructor));
+extern void finish_b2( void ) __attribute__((destructor));
+
+void
+start_b2( void )
+{
+  printf( "start_b2\n" );
+}
+
+void
+finish_b2( void )
+{
+  printf( "finish_b2\n" );
+}

Added: fsf/glibc-2_13-branch/libc/elf/tst-order-main.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/elf/tst-order-main.c (added)
+++ fsf/glibc-2_13-branch/libc/elf/tst-order-main.c Fri Feb  4 09:45:21 2011
@@ -1,0 +1,10 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int
+main( int argc, char *argv[] )
+{
+  printf( "main\n" );
+  exit(EXIT_SUCCESS);
+}

Modified: fsf/glibc-2_13-branch/libc/shadow/sgetspent.c
==============================================================================
--- fsf/glibc-2_13-branch/libc/shadow/sgetspent.c (original)
+++ fsf/glibc-2_13-branch/libc/shadow/sgetspent.c Fri Feb  4 09:45:21 2011
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -49,8 +49,8 @@
     }
 
   while (buffer != NULL
-	 && __sgetspent_r (string, &resbuf, buffer, buffer_size, &result) != 0
-	 && errno == ERANGE)
+	 && (__sgetspent_r (string, &resbuf, buffer, buffer_size, &result)
+	     == ERANGE))
     {
       char *new_buf;
       buffer_size += BUFLEN_SPWD;