SWITCH elated fixes

This commit is contained in:
Dmitry Stogov 2022-05-26 20:58:07 +03:00
parent 4a39bda507
commit 77f7d7e2af
2 changed files with 13 additions and 1 deletions

View File

@ -228,6 +228,14 @@ static uint64_t ir_disasm_rodata_reference(csh cs, const cs_insn *insn)
return (uint32_t)insn->detail->x86.operands[i].mem.disp;
}
}
if (cs_insn_group(cs, insn, X86_GRP_JUMP)) {
for (i = 0; i < insn->detail->x86.op_count; i++) {
if (insn->detail->x86.operands[i].type == X86_OP_MEM
&& insn->detail->x86.operands[i].mem.disp) {
return (uint32_t)insn->detail->x86.operands[i].mem.disp;
}
}
}
#elif defined(IR_TARGET_X64)
for (i = 0; i < insn->detail->x86.op_count; i++) {
if (insn->detail->x86.operands[i].type == X86_OP_MEM
@ -617,6 +625,10 @@ int ir_disasm(const char *name,
}
r++;
}
if (p - 1 != q && *(q-2) == '-') {
q--;
addr = (uint32_t)(-addr);
}
if (addr >= (uint64_t)(uintptr_t)start && addr < (uint64_t)(uintptr_t)orig_end) {
l = ir_addrtab_find(&labels, (uint32_t)((uintptr_t)addr - (uintptr_t)start));
if (l >= 0) {

View File

@ -4717,7 +4717,7 @@ static void ir_emit_switch(ir_ctx *ctx, int b, ir_ref def, ir_insn *insn)
}
if (IR_IS_32BIT(type, min)) {
offset = -min.i64 * 8;
offset = -min.i64 * sizeof(void*);
if (IR_IS_SIGNED_32BIT(offset)) {
| ASM_REG_IMM_OP cmp, type, op2_reg, min.i32
} else {