Fix stupid thinko affecting ppc64 --gc-sections

Alan Modra amodra@bigpond.net.au
Mon Jan 16 23:52:00 GMT 2006


This change introduced a really stupid bug:
revision 1.154
date: 2004/08/09 03:14:11;  author: amodra;  state: Exp;  lines: +64 -40

I converted a for() loop with continue statements to do .. while()
resulting in a loop that never exits if any of the continues are taken.
gcc mainline uses --gc-sections building libstdc++.so, and hits the
bug.

	* elf64-ppc.c (ppc64_elf_gc_mark_hook): Don't hang forever in loop.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.230
diff -u -p -r1.230 elf64-ppc.c
--- bfd/elf64-ppc.c	1 Jan 2006 00:06:24 -0000	1.230
+++ bfd/elf64-ppc.c	16 Jan 2006 23:27:28 -0000
@@ -4958,7 +4958,7 @@ ppc64_elf_gc_mark_hook (asection *sec,
       struct bfd_sym_chain *sym = info->gc_sym_list;
 
       info->gc_sym_list = NULL;
-      do
+      for (; sym != NULL; sym = sym->next)
 	{
 	  struct ppc_link_hash_entry *eh;
 
@@ -4988,10 +4988,7 @@ ppc64_elf_gc_mark_hook (asection *sec,
 	  rsec = eh->elf.root.u.def.section;
 	  if (!rsec->gc_mark)
 	    _bfd_elf_gc_mark (info, rsec, ppc64_elf_gc_mark_hook);
-
-	  sym = sym->next;
 	}
-      while (sym != NULL);
     }
 
   /* Syms return NULL if we're marking .opd, so we avoid marking all



More information about the Binutils mailing list