mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-17 12:34:35 +03:00
Instruction validator now doesn't pass 'push/pop [mem]' having unknown size
This commit is contained in:
@@ -2997,11 +2997,11 @@ const InstDB::InstSignature InstDB::_instSignatureTable[] = {
|
|||||||
ROW(3, 1, 1, 1, 27 , 4 , 33 , 0 , 0 , 0 ), // {r16|m16|mem, r16, <ax>}
|
ROW(3, 1, 1, 1, 27 , 4 , 33 , 0 , 0 , 0 ), // {r16|m16|mem, r16, <ax>}
|
||||||
ROW(3, 1, 1, 1, 28 , 6 , 36 , 0 , 0 , 0 ), // {r32|m32|mem, r32, <eax>}
|
ROW(3, 1, 1, 1, 28 , 6 , 36 , 0 , 0 , 0 ), // {r32|m32|mem, r32, <eax>}
|
||||||
ROW(3, 0, 1, 1, 15 , 8 , 38 , 0 , 0 , 0 ), // {r64|m64|mem, r64, <rax>}
|
ROW(3, 0, 1, 1, 15 , 8 , 38 , 0 , 0 , 0 ), // {r64|m64|mem, r64, <rax>}
|
||||||
ROW(1, 1, 1, 0, 69 , 0 , 0 , 0 , 0 , 0 ), // #127 {r16|m16|r64|m64|mem}
|
ROW(1, 1, 1, 0, 69 , 0 , 0 , 0 , 0 , 0 ), // #127 {r16|m16|r64|m64}
|
||||||
ROW(1, 1, 0, 0, 13 , 0 , 0 , 0 , 0 , 0 ), // {r32|m32}
|
ROW(1, 1, 0, 0, 13 , 0 , 0 , 0 , 0 , 0 ), // {r32|m32}
|
||||||
ROW(1, 1, 0, 0, 70 , 0 , 0 , 0 , 0 , 0 ), // {ds|es|ss}
|
ROW(1, 1, 0, 0, 70 , 0 , 0 , 0 , 0 , 0 ), // {ds|es|ss}
|
||||||
ROW(1, 1, 1, 0, 71 , 0 , 0 , 0 , 0 , 0 ), // {fs|gs}
|
ROW(1, 1, 1, 0, 71 , 0 , 0 , 0 , 0 , 0 ), // {fs|gs}
|
||||||
ROW(1, 1, 1, 0, 72 , 0 , 0 , 0 , 0 , 0 ), // #131 {r16|m16|r64|m64|mem|i8|i16|i32}
|
ROW(1, 1, 1, 0, 72 , 0 , 0 , 0 , 0 , 0 ), // #131 {r16|m16|r64|m64|i8|i16|i32}
|
||||||
ROW(1, 1, 0, 0, 73 , 0 , 0 , 0 , 0 , 0 ), // {r32|m32|i32|u32}
|
ROW(1, 1, 0, 0, 73 , 0 , 0 , 0 , 0 , 0 ), // {r32|m32|i32|u32}
|
||||||
ROW(1, 1, 0, 0, 74 , 0 , 0 , 0 , 0 , 0 ), // {cs|ss|ds|es}
|
ROW(1, 1, 0, 0, 74 , 0 , 0 , 0 , 0 , 0 ), // {cs|ss|ds|es}
|
||||||
ROW(1, 1, 1, 0, 71 , 0 , 0 , 0 , 0 , 0 ), // {fs|gs}
|
ROW(1, 1, 1, 0, 71 , 0 , 0 , 0 , 0 , 0 ), // {fs|gs}
|
||||||
@@ -3424,10 +3424,10 @@ const InstDB::OpSignature InstDB::_opSignatureTable[] = {
|
|||||||
ROW(F(Vm), M(Vm64y), 0, 0x00),
|
ROW(F(Vm), M(Vm64y), 0, 0x00),
|
||||||
ROW(F(Vm), M(Vm64z), 0, 0x00),
|
ROW(F(Vm), M(Vm64z), 0, 0x00),
|
||||||
ROW(F(GpbLo) | F(Implicit), 0, 0, 0x01),
|
ROW(F(GpbLo) | F(Implicit), 0, 0, 0x01),
|
||||||
ROW(F(Gpw) | F(Gpq) | F(Mem), M(M16) | M(M64) | M(Any), 0, 0x00),
|
ROW(F(Gpw) | F(Gpq) | F(Mem), M(M16) | M(M64), 0, 0x00),
|
||||||
ROW(F(SReg), 0, 0, 0x1A),
|
ROW(F(SReg), 0, 0, 0x1A),
|
||||||
ROW(F(SReg), 0, 0, 0x60),
|
ROW(F(SReg), 0, 0, 0x60),
|
||||||
ROW(F(Gpw) | F(Gpq) | F(Mem) | F(I8) | F(I16) | F(I32), M(M16) | M(M64) | M(Any), 0, 0x00),
|
ROW(F(Gpw) | F(Gpq) | F(Mem) | F(I8) | F(I16) | F(I32), M(M16) | M(M64), 0, 0x00),
|
||||||
ROW(F(Gpd) | F(Mem) | F(I32) | F(U32), M(M32), 0, 0x00),
|
ROW(F(Gpd) | F(Mem) | F(I32) | F(U32), M(M32), 0, 0x00),
|
||||||
ROW(F(SReg), 0, 0, 0x1E),
|
ROW(F(SReg), 0, 0, 0x1E),
|
||||||
ROW(F(Vm), M(Vm64x) | M(Vm64y), 0, 0x00),
|
ROW(F(Vm), M(Vm64x) | M(Vm64y), 0, 0x00),
|
||||||
|
|||||||
@@ -282,6 +282,20 @@ class GenUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent some instructions from having implicit memory size if that would
|
||||||
|
// make them ambiguous. There are some instructions where the ambiguity is
|
||||||
|
// okay, but some like 'push' and 'pop' where it isn't.
|
||||||
|
static canUseImplicitMemSize(name) {
|
||||||
|
switch (name) {
|
||||||
|
case "pop":
|
||||||
|
case "push":
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static singleRegCase(name) {
|
static singleRegCase(name) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "xchg" :
|
case "xchg" :
|
||||||
@@ -1406,7 +1420,8 @@ class SignatureArray extends Array {
|
|||||||
// Patch all instructions to accept implicit-size memory operand.
|
// Patch all instructions to accept implicit-size memory operand.
|
||||||
for (bIndex = 0; bIndex < sameSizeSet.length; bIndex++) {
|
for (bIndex = 0; bIndex < sameSizeSet.length; bIndex++) {
|
||||||
const bInst = sameSizeSet[bIndex];
|
const bInst = sameSizeSet[bIndex];
|
||||||
if (implicit) bInst[memPos].flags.mem = true;
|
if (implicit)
|
||||||
|
bInst[memPos].flags.mem = true;
|
||||||
|
|
||||||
if (!implicit)
|
if (!implicit)
|
||||||
DEBUG(`${this.name}: Explicit: ${bInst}`);
|
DEBUG(`${this.name}: Explicit: ${bInst}`);
|
||||||
@@ -1697,7 +1712,9 @@ class InstSignatureTable extends core.Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (signatures.length && GenUtils.canUseImplicitMemSize(dbInsts[0].name))
|
||||||
signatures.calcImplicitMemSize();
|
signatures.calcImplicitMemSize();
|
||||||
|
|
||||||
signatures.simplify();
|
signatures.simplify();
|
||||||
signatures.compact();
|
signatures.compact();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user