From 62cf415f4976f681edecb067e9ca1c17f145a349 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 8 Jan 2008 22:29:21 -0800 Subject: [PATCH] Optimizer: force progression through final passes when hitting limit We have a number of bug reports about things not working properly when the optimizer is running out of passes. I suspect the reason is simply that we don't properly execute the final passes (pass0 = 1, 2) when hitting the limit. Make sure we advance pass0 the last few times. --- nasm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nasm.c b/nasm.c index b1c2239c..63aaeb14 100644 --- a/nasm.c +++ b/nasm.c @@ -910,7 +910,7 @@ static void assemble_file(char *fname) pass_max = (optimizing > 0 ? optimizing : 0) + 2; /* passes 1, optimizing, then 2 */ pass0 = !(optimizing > 0); /* start at 1 if not optimizing */ - for (pass = 1; pass <= pass_max && pass0 <= 2; pass++) { + for (pass = 1; pass0 <= 2; pass++) { int pass1, pass2; ldfunc def_label; @@ -1476,7 +1476,8 @@ static void assemble_file(char *fname) exit(1); } pass_cnt++; - if (pass > 1 && !global_offset_changed) { + if ((pass > 1 && !global_offset_changed) || + pass >= pass_max - 2) { pass0++; if (pass0 == 2) pass = pass_max - 1;