Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/asmjit/asmjit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkobalicek <kobalicek.petr@gmail.com>2017-03-06 20:54:52 +0300
committerkobalicek <kobalicek.petr@gmail.com>2017-03-06 20:54:52 +0300
commit528951ab9afe4ed5a07320e0bfd53dfd847199b9 (patch)
tree2c04fcb7aac5ea0424f95c062ce5e761a21d08a6
parent35ba2ad83a4fdc1fbe6133e651b0b9c433bf46a0 (diff)
Minor, catch VSIB{rip+xxx} in x86 validator as well
-rw-r--r--src/asmjit/x86/x86assembler.cpp7
-rw-r--r--src/asmjit/x86/x86inst.cpp4
2 files changed, 8 insertions, 3 deletions
diff --git a/src/asmjit/x86/x86assembler.cpp b/src/asmjit/x86/x86assembler.cpp
index 7985aef..c64614e 100644
--- a/src/asmjit/x86/x86assembler.cpp
+++ b/src/asmjit/x86/x86assembler.cpp
@@ -3861,7 +3861,7 @@ EmitModSib_LabelRip_X86:
EmitModVSib:
rxReg &= 0x7;
- // ==========|> [BASE + INDEX + DISP8|DISP16|DISP32].
+ // ==========|> [BASE + INDEX + DISP8|DISP32].
if (rmInfo & kX86MemInfo_BaseGp) {
rbReg &= 0x7;
relOffset = rmRel->as<X86Mem>().getOffsetLo32();
@@ -3885,14 +3885,14 @@ EmitModVSib:
EMIT_BYTE(cdOffset);
}
else {
- // [BASE + INDEX << SHIFT + DISP16|DISP32].
+ // [BASE + INDEX << SHIFT + DISP32].
EMIT_BYTE(mod + 0x80); // <- MOD(2, opReg, 4).
EMIT_BYTE(sib);
EMIT_32(relOffset);
}
}
}
- // ==========|> [INDEX + DISP16|DISP32].
+ // ==========|> [INDEX + DISP32].
else if (!(rmInfo & (kX86MemInfo_BaseLabel | kX86MemInfo_BaseRip))) {
// [INDEX << SHIFT + DISP32].
EMIT_BYTE(x86EncodeMod(0, opReg, 4));
@@ -3909,6 +3909,7 @@ EmitModVSib:
goto EmitModSib_LabelRip_X86;
}
else {
+ // NOTE: This also handles VSIB+RIP, which is not allowed in 64-bit mode.
goto InvalidAddress;
}
}
diff --git a/src/asmjit/x86/x86inst.cpp b/src/asmjit/x86/x86inst.cpp
index 3ef4fa4..327261c 100644
--- a/src/asmjit/x86/x86inst.cpp
+++ b/src/asmjit/x86/x86inst.cpp
@@ -3947,6 +3947,10 @@ ASMJIT_FAVOR_SIZE Error X86Inst::validate(
memFlags |= X86Inst::kMemOpMib;
}
+ // [RIP + {XMM|YMM|ZMM}] is not allowed.
+ if (baseType == X86Reg::kRegRip && (opFlags & X86Inst::kOpVm))
+ return DebugUtils::errored(kErrorInvalidAddress);
+
uint32_t indexId = m.getIndexId();
if (indexId < Operand::kPackedIdMin)
combinedRegMask |= Utils::mask(indexId);