diff lwasm/pass4.c @ 239:8beb109dfd69

Fix hang on undefined symbol in rmb under pragma undefextern Problem in the pass4.c implementation led to an infinite loop if any instructions failed to resolve. Instead, if a pass through the loop fails to resolve anything, bail out since it's clearly pointless to continue trying.
author William Astle <lost@l-w.ca>
date Tue, 14 Aug 2012 21:06:52 -0600
parents 4503199d56ba
children 8764142b3192
line wrap: on
line diff
--- a/lwasm/pass4.c	Mon Aug 13 17:22:13 2012 -0600
+++ b/lwasm/pass4.c	Tue Aug 14 21:06:52 2012 -0600
@@ -40,6 +40,7 @@
 	int cnt;
 	line_t *cl, *sl;
 	struct line_expr_s *le;
+	int trycount = 0;
 
 	// first, count the number of unresolved instructions
 	for (cnt = 0, cl = as -> line_head; cl; cl = cl -> next)
@@ -51,6 +52,7 @@
 	sl = as -> line_head;
 	while (cnt > 0)
 	{
+		trycount = cnt;
 		debug_message(as, 60, "%d unresolved instructions", cnt);
 
 		// find an unresolved instruction
@@ -142,6 +144,8 @@
 			if (as -> errorcount > 0)
 				return;
 		} while (rc > 0);
+		if (trycount == cnt)
+			break;
 	}
 }