summary refs log tree commit diff
path: root/elf/dl-deps.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2011-08-22 16:08:16 -0400
committerUlrich Drepper <drepper@gmail.com>2011-08-22 16:08:16 -0400
commite888bcbe4fb8ad538ec640bfb18b687d51e001e7 (patch)
tree95d9ee2186182388c15bd6245d4b1cf702ec34c2 /elf/dl-deps.c
parent91b392a4bab0c2dc90e7e3ff914dec20b97adca8 (diff)
downloadglibc-e888bcbe4fb8ad538ec640bfb18b687d51e001e7.tar.gz
glibc-e888bcbe4fb8ad538ec640bfb18b687d51e001e7.tar.xz
glibc-e888bcbe4fb8ad538ec640bfb18b687d51e001e7.zip
Correct cycle detection during dependency sorting
Diffstat (limited to 'elf/dl-deps.c')
-rw-r--r--elf/dl-deps.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 0b03b903fe..cc0023d381 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -626,12 +626,12 @@ Filters not supported with LD_TRACE_PRELINKING"));
       /* We can skip looking for the binary itself which is at the front
 	 of the search list.  */
       i = 1;
-      bool seen[nlist];
-      memset (seen, false, nlist * sizeof (seen[0]));
+      char seen[nlist];
+      memset (seen, 0, nlist * sizeof (seen[0]));
       while (1)
 	{
 	  /* Keep track of which object we looked at this round.  */
-	  seen[i] = true;
+	  seen[i] += seen[i] < 2;
 	  struct link_map *thisp = l_initfini[i];
 
 	  /* Find the last object in the list for which the current one is
@@ -652,15 +652,16 @@ Filters not supported with LD_TRACE_PRELINKING"));
 			       (k - i) * sizeof (l_initfini[0]));
 		      l_initfini[k] = thisp;
 
-		      if (seen[i + 1])
+		      if (seen[i + 1] > 1)
 			{
 			  ++i;
 			  goto next_clear;
 			}
 
+		      char this_seen = seen[i];
 		      memmove (&seen[i], &seen[i + 1],
 			       (k - i) * sizeof (seen[0]));
-		      seen[k] = true;
+		      seen[k] = this_seen;
 
 		      goto next;
 		    }
@@ -671,7 +672,7 @@ Filters not supported with LD_TRACE_PRELINKING"));
 	  if (++i == nlist)
 	    break;
 	next_clear:
-	  memset (&seen[i], false, (nlist - i) * sizeof (seen[0]));
+	  memset (&seen[i], 0, (nlist - i) * sizeof (seen[0]));
 
 	next:;
 	}