diff options
author | Victor van den Elzen <victor.vde@gmail.com> | 2008-09-11 15:07:05 +0200 |
---|---|---|
committer | Victor van den Elzen <victor.vde@gmail.com> | 2008-09-11 15:07:05 +0200 |
commit | 4252823e95bb365e704cdd8ae526d2daf01a6533 (patch) | |
tree | 4b3f9348360bdca0150375c0a8efaf53aace9eee /nasm.c | |
parent | 28f463463442010dff5dce13d07962f241faf1f5 (diff) | |
download | nasm-4252823e95bb365e704cdd8ae526d2daf01a6533.tar.gz nasm-4252823e95bb365e704cdd8ae526d2daf01a6533.tar.bz2 nasm-4252823e95bb365e704cdd8ae526d2daf01a6533.zip |
Limit number of passes to 1000
Now NASM won't take unreasonable an amount of time to generate
wrong code when it encounters equ's that don't converge, ex:
FOO equ FOO + 1
Diffstat (limited to 'nasm.c')
-rw-r--r-- | nasm.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -1166,7 +1166,9 @@ static void assemble_file(char *fname, StrList **depend_ptr) report_error(ERR_FATAL, "command line: " "32-bit segment size requires a higher cpu"); - pass_max = (INT_MAX >> 1) + 2; /* Almost unlimited */ + pass_max = 1000; /* Always terminate in a reasonable time */ + /* No real program should need this many passes */ + for (passn = 1; pass0 <= 2; passn++) { int pass1, pass2; ldfunc def_label; @@ -1730,9 +1732,17 @@ static void assemble_file(char *fname, StrList **depend_ptr) usage(); exit(1); } - if (passn >= pass_max - 2 || - (passn > 1 && !global_offset_changed)) + if (passn > 1 && !global_offset_changed) pass0++; + + if(passn >= pass_max) + /* We get here if the labels don't converge + * Example: FOO equ FOO + 1 + */ + report_error(ERR_NONFATAL, + "Can't find valid values for all labels " + "after %d passes, giving up. " + "Possible cause: recursive equ's.", passn); } preproc->cleanup(0); |