diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-06-27 20:17:33 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-06-27 20:17:33 -0700 |
commit | 12810fac9294cd205f3d7a4a1ce9fab480e42f89 (patch) | |
tree | acd040d8045eddd7edf0344e791af5c643a55cab | |
parent | 58a275c3e917c083b4b165c53cce47dc830492b7 (diff) | |
download | nasm-12810fac9294cd205f3d7a4a1ce9fab480e42f89.tar.gz |
nasm.c: min 2 optimization passes, don't re-run pass 1
We may not even have the most basic stabilization done unless we run
at least two optimization passes, e.g. in the case of subsections.
However, we cannot run more than one stabilization pass (pass0 == 1);
for one thing we'll call ofmt->symdef() multiple times on the same
symbol, which is not allowed. If we haven't achieved stability by the
time we decide to run a stabilization pass, plod on and hope for the
best.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r-- | asm/nasm.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1620,7 +1620,14 @@ static void assemble_file(const char *fname, StrList **depend_ptr) if (pass1 == 1) preproc->cleanup(1); - if ((passn > 1 && !global_offset_changed) || pass0 == 2) { + /* + * Always run at least two optimization passes (pass0 == 0); + * things like subsections will fail miserably without that. + * Once we commit to a stabilization pass (pass0 == 1), we can't + * go back, and if something goes bad, we can only hope + * that we don't end up with a phase error at the end. + */ + if ((passn > 1 && !global_offset_changed) || pass0 > 0) { pass0++; } else if (global_offset_changed && global_offset_changed < prev_offset_changed) { |