Module Name:    src
Committed By:   joerg
Date:           Mon Aug  4 21:41:44 UTC 2014

Modified Files:
        src/common/lib/libx86emu: x86emu.c

Log Message:
Fix decoding of near CALL when address-size prefix (67h) is present.

>From Wolf Ramovsky via FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/common/lib/libx86emu/x86emu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libx86emu/x86emu.c
diff -u src/common/lib/libx86emu/x86emu.c:1.9 src/common/lib/libx86emu/x86emu.c:1.10
--- src/common/lib/libx86emu/x86emu.c:1.9	Mon Aug  4 21:40:11 2014
+++ src/common/lib/libx86emu/x86emu.c	Mon Aug  4 21:41:44 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86emu.c,v 1.9 2014/08/04 21:40:11 joerg Exp $	*/
+/*	$NetBSD: x86emu.c,v 1.10 2014/08/04 21:41:44 joerg Exp $	*/
 
 /****************************************************************************
 *
@@ -3604,12 +3604,19 @@ Handles opcode 0xe8
 static void
 x86emuOp_call_near_IMM(struct X86EMU *emu)
 {
-	int16_t ip;
-
-	ip = (int16_t) fetch_word_imm(emu);
-	ip += (int16_t) emu->x86.R_IP;	/* CHECK SIGN */
-	push_word(emu, emu->x86.R_IP);
-	emu->x86.R_IP = ip;
+	if (emu->x86.mode & SYSMODE_PREFIX_DATA) {
+		int32_t ip;
+		ip = (int32_t) fetch_long_imm(emu);
+		ip += (int32_t) emu->x86.R_EIP;
+		push_long(emu, emu->x86.R_EIP);
+		emu->x86.R_EIP = ip;
+	} else {
+		int16_t ip;
+		ip = (int16_t) fetch_word_imm(emu);
+		ip += (int16_t) emu->x86.R_IP;	/* CHECK SIGN */
+		push_word(emu, emu->x86.R_IP);
+		emu->x86.R_IP = ip;
+	}
 }
 /****************************************************************************
 REMARKS:

Reply via email to