From 8370e6efa974f560e7b69c0f60544a7368e74547 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 10 Dec 2007 05:20:32 +0000 Subject: [PATCH] Fix NULL dereference for certain cases of REX used with jump instruction. svn path=/trunk/yasm/; revision=2024 --- modules/arch/x86/tests/Makefile.inc | 3 +++ modules/arch/x86/tests/o64loop.asm | 3 +++ modules/arch/x86/tests/o64loop.errwarn | 1 + modules/arch/x86/tests/o64loop.hex | 2 ++ modules/arch/x86/x86bc.c | 5 ++++- 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 modules/arch/x86/tests/o64loop.asm create mode 100644 modules/arch/x86/tests/o64loop.errwarn create mode 100644 modules/arch/x86/tests/o64loop.hex diff --git a/modules/arch/x86/tests/Makefile.inc b/modules/arch/x86/tests/Makefile.inc index c9093246..9069d2c2 100644 --- a/modules/arch/x86/tests/Makefile.inc +++ b/modules/arch/x86/tests/Makefile.inc @@ -104,6 +104,9 @@ EXTRA_DIST += modules/arch/x86/tests/nomem64.errwarn EXTRA_DIST += modules/arch/x86/tests/nomem64.hex EXTRA_DIST += modules/arch/x86/tests/o64.asm EXTRA_DIST += modules/arch/x86/tests/o64.hex +EXTRA_DIST += modules/arch/x86/tests/o64loop.asm +EXTRA_DIST += modules/arch/x86/tests/o64loop.errwarn +EXTRA_DIST += modules/arch/x86/tests/o64loop.hex EXTRA_DIST += modules/arch/x86/tests/opersize.asm EXTRA_DIST += modules/arch/x86/tests/opersize.hex EXTRA_DIST += modules/arch/x86/tests/opsize-err.asm diff --git a/modules/arch/x86/tests/o64loop.asm b/modules/arch/x86/tests/o64loop.asm new file mode 100644 index 00000000..14f7951b --- /dev/null +++ b/modules/arch/x86/tests/o64loop.asm @@ -0,0 +1,3 @@ +[bits 64] +o64 loop next +next: diff --git a/modules/arch/x86/tests/o64loop.errwarn b/modules/arch/x86/tests/o64loop.errwarn new file mode 100644 index 00000000..55f8201b --- /dev/null +++ b/modules/arch/x86/tests/o64loop.errwarn @@ -0,0 +1 @@ +-:2: warning: ignoring REX prefix on jump diff --git a/modules/arch/x86/tests/o64loop.hex b/modules/arch/x86/tests/o64loop.hex new file mode 100644 index 00000000..55e2c214 --- /dev/null +++ b/modules/arch/x86/tests/o64loop.hex @@ -0,0 +1,2 @@ +e2 +00 diff --git a/modules/arch/x86/x86bc.c b/modules/arch/x86/x86bc.c index f3717bf7..dfcaa26c 100644 --- a/modules/arch/x86/x86bc.c +++ b/modules/arch/x86/x86bc.c @@ -294,7 +294,10 @@ yasm_x86__bc_apply_prefixes(x86_common *common, unsigned char *rex, common->opersize = (unsigned char)prefixes[i] & 0xff; if (common->mode_bits == 64 && common->opersize == 64 && def_opersize_64 != 64) { - if (*rex == 0xff) + if (!rex) + yasm_warn_set(YASM_WARN_GENERAL, + N_("ignoring REX prefix on jump")); + else if (*rex == 0xff) yasm_warn_set(YASM_WARN_GENERAL, N_("REX prefix not allowed on this instruction, ignoring")); else -- 2.40.0