target-i386: fix SIB decoding with index = 4
A SIB byte with an index of 4 means "no scaled index", even if the scale value is not 0. In 64-bit mode, if REX.X is used, an index of 4 selects %r12. This is correctly handled by the computation of the index variable, which includes the index bits, and also the REX.X prefix: index = ((code >> 3) & 7) | REX_X(s); Thanks to Avi Kivity, Jamie Lokier and Malc for the analysis of the problem and the initial patch. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
1298cb6804
commit
b16f827bdf
@ -2047,8 +2047,8 @@ static void gen_lea_modrm(DisasContext *s, int modrm, int *reg_ptr, int *offset_
|
|||||||
gen_op_movl_A0_im(disp);
|
gen_op_movl_A0_im(disp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* XXX: index == 4 is always invalid */
|
/* index == 4 means no index */
|
||||||
if (havesib && (index != 4 || scale != 0)) {
|
if (havesib && (index != 4)) {
|
||||||
#ifdef TARGET_X86_64
|
#ifdef TARGET_X86_64
|
||||||
if (s->aflag == 2) {
|
if (s->aflag == 2) {
|
||||||
gen_op_addq_A0_reg_sN(scale, index);
|
gen_op_addq_A0_reg_sN(scale, index);
|
||||||
|
Loading…
Reference in New Issue
Block a user