Mercurial > hg > index.cgi
comparison 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 |
comparison
equal
deleted
inserted
replaced
238:91f91557dc9e | 239:8beb109dfd69 |
---|---|
38 { | 38 { |
39 int rc; | 39 int rc; |
40 int cnt; | 40 int cnt; |
41 line_t *cl, *sl; | 41 line_t *cl, *sl; |
42 struct line_expr_s *le; | 42 struct line_expr_s *le; |
43 int trycount = 0; | |
43 | 44 |
44 // first, count the number of unresolved instructions | 45 // first, count the number of unresolved instructions |
45 for (cnt = 0, cl = as -> line_head; cl; cl = cl -> next) | 46 for (cnt = 0, cl = as -> line_head; cl; cl = cl -> next) |
46 { | 47 { |
47 if (cl -> len == -1) | 48 if (cl -> len == -1) |
49 } | 50 } |
50 | 51 |
51 sl = as -> line_head; | 52 sl = as -> line_head; |
52 while (cnt > 0) | 53 while (cnt > 0) |
53 { | 54 { |
55 trycount = cnt; | |
54 debug_message(as, 60, "%d unresolved instructions", cnt); | 56 debug_message(as, 60, "%d unresolved instructions", cnt); |
55 | 57 |
56 // find an unresolved instruction | 58 // find an unresolved instruction |
57 for ( ; sl && sl -> len != -1; sl = sl -> next) | 59 for ( ; sl && sl -> len != -1; sl = sl -> next) |
58 { | 60 { |
140 } | 142 } |
141 } | 143 } |
142 if (as -> errorcount > 0) | 144 if (as -> errorcount > 0) |
143 return; | 145 return; |
144 } while (rc > 0); | 146 } while (rc > 0); |
147 if (trycount == cnt) | |
148 break; | |
145 } | 149 } |
146 } | 150 } |
147 | 151 |
148 void do_pass4(asmstate_t *as) | 152 void do_pass4(asmstate_t *as) |
149 { | 153 { |