From: Peter Johnson Date: Fri, 21 Jan 2005 23:46:27 +0000 (-0000) Subject: * yasm.c (main): Make sure we check for undefined symbols before doing any X-Git-Tag: v0.5.0rc1~180 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a19e5c44c475444206a6100a465f887a362ee97;p=yasm * yasm.c (main): Make sure we check for undefined symbols before doing any expression processing. A crash is possible if we don't do this. * nomem64-err.asm, nomem64-err.errwarn: New order forces split of this into: * nomem64-err2.asm, nomem64-err2.errwarn: move two cases here. Found by: Ewout Prangsma svn path=/trunk/yasm/; revision=1194 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 2e8143c9..c98a7fd9 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -545,6 +545,16 @@ main(int argc, char *argv[]) if (in != stdin) fclose(in); + /* Check for undefined symbols */ + yasm_symtab_parser_finalize(yasm_object_get_symtab(object)); + + if (yasm_get_num_errors(warning_error) > 0) { + yasm_errwarn_output_all(yasm_object_get_linemap(object), warning_error, + print_yasm_error, print_yasm_warning); + cleanup(object); + return EXIT_FAILURE; + } + /* Finalize parse */ yasm_object_finalize(object); @@ -555,7 +565,7 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - yasm_symtab_parser_finalize(yasm_object_get_symtab(object)); + /* Optimize */ cur_optimizer_module->optimize(object); if (yasm_get_num_errors(warning_error) > 0) { diff --git a/modules/arch/x86/tests/Makefile.inc b/modules/arch/x86/tests/Makefile.inc index 19e1b99d..c67cad39 100644 --- a/modules/arch/x86/tests/Makefile.inc +++ b/modules/arch/x86/tests/Makefile.inc @@ -84,6 +84,8 @@ EXTRA_DIST += modules/arch/x86/tests/negequ.errwarn EXTRA_DIST += modules/arch/x86/tests/negequ.hex EXTRA_DIST += modules/arch/x86/tests/nomem64-err.asm EXTRA_DIST += modules/arch/x86/tests/nomem64-err.errwarn +EXTRA_DIST += modules/arch/x86/tests/nomem64-err2.asm +EXTRA_DIST += modules/arch/x86/tests/nomem64-err2.errwarn EXTRA_DIST += modules/arch/x86/tests/nomem64.asm EXTRA_DIST += modules/arch/x86/tests/nomem64.errwarn EXTRA_DIST += modules/arch/x86/tests/nomem64.hex diff --git a/modules/arch/x86/tests/nomem64-err.asm b/modules/arch/x86/tests/nomem64-err.asm index 6b92797f..09ff36ab 100644 --- a/modules/arch/x86/tests/nomem64-err.asm +++ b/modules/arch/x86/tests/nomem64-err.asm @@ -1,6 +1,4 @@ [bits 64] -mov bh, r8b -mov r8b, ch push es pop fs pushaw diff --git a/modules/arch/x86/tests/nomem64-err.errwarn b/modules/arch/x86/tests/nomem64-err.errwarn index 8c47ff8d..2694d2fb 100644 --- a/modules/arch/x86/tests/nomem64-err.errwarn +++ b/modules/arch/x86/tests/nomem64-err.errwarn @@ -1,25 +1,14 @@ --:2: invalid combination of opcode and operands --:3: invalid combination of opcode and operands --:4: warning: `es' segment register ignored in 64-bit mode --:4: invalid combination of opcode and operands --:6: `pushaw' invalid in 64-bit mode --:6: invalid combination of opcode and operands --:7: `popa' invalid in 64-bit mode --:7: invalid combination of opcode and operands --:8: `lds' invalid in 64-bit mode --:8: invalid combination of opcode and operands --:9: `aas' invalid in 64-bit mode --:9: invalid combination of opcode and operands --:10: `das' invalid in 64-bit mode --:10: invalid combination of opcode and operands --:11: `aad' invalid in 64-bit mode --:11: invalid combination of opcode and operands --:12: `into' invalid in 64-bit mode --:12: invalid combination of opcode and operands --:13: `salc' invalid in 64-bit mode --:13: invalid combination of opcode and operands --:15: warning: `xmm9' is a register in 64-bit mode --:16: warning: `rax' is a register in 64-bit mode --:17: warning: `rdx' is a register in 64-bit mode --:18: warning: `cdqe' is an instruction in 64-bit mode --:19: warning: `swapgs' is an instruction in 64-bit mode +-:2: warning: `es' segment register ignored in 64-bit mode +-:4: `pushaw' invalid in 64-bit mode +-:5: `popa' invalid in 64-bit mode +-:6: `lds' invalid in 64-bit mode +-:7: `aas' invalid in 64-bit mode +-:8: `das' invalid in 64-bit mode +-:9: `aad' invalid in 64-bit mode +-:10: `into' invalid in 64-bit mode +-:11: `salc' invalid in 64-bit mode +-:13: warning: `xmm9' is a register in 64-bit mode +-:14: warning: `rax' is a register in 64-bit mode +-:15: warning: `rdx' is a register in 64-bit mode +-:16: warning: `cdqe' is an instruction in 64-bit mode +-:17: warning: `swapgs' is an instruction in 64-bit mode diff --git a/modules/arch/x86/tests/nomem64-err2.asm b/modules/arch/x86/tests/nomem64-err2.asm new file mode 100644 index 00000000..85eb0491 --- /dev/null +++ b/modules/arch/x86/tests/nomem64-err2.asm @@ -0,0 +1,3 @@ +[bits 64] +mov bh, r8b +mov r8b, ch diff --git a/modules/arch/x86/tests/nomem64-err2.errwarn b/modules/arch/x86/tests/nomem64-err2.errwarn new file mode 100644 index 00000000..f4a79b24 --- /dev/null +++ b/modules/arch/x86/tests/nomem64-err2.errwarn @@ -0,0 +1,2 @@ +-:2: invalid combination of opcode and operands +-:3: invalid combination of opcode and operands