x86 cmp/sub: Properly generate esil for bitsize of 64 ##anal (#17665)
* x86 cmp/sub esil: Support bitsize of 64 * Fix pij tests * Don't shift if bitsize is 0 * Don't esilprint anything if bitsize is invalid * Use %u instead of %d * Check whether bitsize is 0
This commit is contained in:
parent
022324029d
commit
2293d29308
2 changed files with 12 additions and 12 deletions
|
|
@ -976,17 +976,17 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
|
|||
src = getarg (&gop, 1, 0, NULL, SRC_AR, NULL);
|
||||
dst = getarg (&gop, 0, 0, NULL, DST_AR, &bitsize);
|
||||
|
||||
if (bitsize > 63) {
|
||||
bitsize = 0;
|
||||
if (!bitsize || bitsize > 64) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (insn->id == X86_INS_TEST) {
|
||||
esilprintf (op, "0,%s,%s,&,==,$z,zf,:=,$p,pf,:=,%d,$s,sf,:=,0,cf,:=,0,of,:=",
|
||||
esilprintf (op, "0,%s,%s,&,==,$z,zf,:=,$p,pf,:=,%u,$s,sf,:=,0,cf,:=,0,of,:=",
|
||||
src, dst, bitsize - 1);
|
||||
} else {
|
||||
esilprintf (op,
|
||||
"%s,%s,==,$z,zf,:=,%d,$b,cf,:=,$p,pf,:=,%d,$s,sf,:=,%s,0x%"PFMT64x",-,!,%d,$o,^,of,:=,3,$b,af,:=",
|
||||
src, dst, bitsize, bitsize - 1, src, (1ULL << (bitsize - 1)), bitsize - 1);
|
||||
"%s,%s,==,$z,zf,:=,%u,$b,cf,:=,$p,pf,:=,%u,$s,sf,:=,%s,0x%"PFMT64x",-,!,%u,$o,^,of,:=,3,$b,af,:=",
|
||||
src, dst, bitsize, bitsize - 1, src, 1ULL << (bitsize - 1), bitsize - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1476,15 +1476,15 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
|
|||
src = getarg (&gop, 1, 0, NULL, SRC_AR, NULL);
|
||||
dst = getarg (&gop, 0, 1, "-", DST_AR, &bitsize);
|
||||
|
||||
if (bitsize > 63) {
|
||||
bitsize = 0;
|
||||
if (!bitsize || bitsize > 64) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Set OF, SF, ZF, AF, PF, and CF flags.
|
||||
// We use $b rather than $c here as the carry flag really
|
||||
// represents a "borrow"
|
||||
esilprintf (op, "%s,%s,%s,0x%"PFMT64x",-,!,%d,$o,^,of,:=,%d,$s,sf,:=,$z,zf,:=,$p,pf,:=,%d,$b,cf,:=,3,$b,af,:=",
|
||||
src, dst, src, (1ULL << (bitsize - 1)), bitsize - 1, bitsize - 1, bitsize);
|
||||
esilprintf (op, "%s,%s,%s,0x%"PFMT64x",-,!,%u,$o,^,of,:=,%u,$s,sf,:=,$z,zf,:=,$p,pf,:=,%u,$b,cf,:=,3,$b,af,:=",
|
||||
src, dst, src, 1ULL << (bitsize - 1), bitsize - 1, bitsize - 1, bitsize);
|
||||
}
|
||||
break;
|
||||
case X86_INS_SBB:
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ wx b8010000004839ca7f
|
|||
pij 3
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
[{"offset":0,"val":1,"esil":"1,rax,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov eax, 1","disasm":"mov eax, 1","bytes":"b801000000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":5,"esil":"rcx,rdx,==,$z,zf,:=,0,$b,cf,:=,$p,pf,:=,-1,$s,sf,:=,rcx,0x8000000000000000,-,!,-1,$o,^,of,:=,3,$b,af,:=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"cmp rdx, rcx","disasm":"cmp rdx, rcx","bytes":"4839ca","family":"cpu","type":"cmp","reloc":false,"type_num":15,"type2_num":0},{"offset":8,"esil":"sf,of,!,^,zf,!,&,?{,10,rip,=,}","refptr":false,"fcn_addr":0,"fcn_last":0,"size":2,"opcode":"jg 0xa","disasm":"jg 0xa","bytes":"7f00","family":"cpu","type":"cjmp","reloc":false,"type_num":2147483649,"type2_num":0,"jump":10,"fail":10}]
|
||||
[{"offset":0,"val":1,"esil":"1,rax,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov eax, 1","disasm":"mov eax, 1","bytes":"b801000000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":5,"esil":"rcx,rdx,==,$z,zf,:=,64,$b,cf,:=,$p,pf,:=,63,$s,sf,:=,rcx,0x8000000000000000,-,!,63,$o,^,of,:=,3,$b,af,:=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"cmp rdx, rcx","disasm":"cmp rdx, rcx","bytes":"4839ca","family":"cpu","type":"cmp","reloc":false,"type_num":15,"type2_num":0},{"offset":8,"esil":"sf,of,!,^,zf,!,&,?{,10,rip,=,}","refptr":false,"fcn_addr":0,"fcn_last":0,"size":2,"opcode":"jg 0xa","disasm":"jg 0xa","bytes":"7f00","family":"cpu","type":"cjmp","reloc":false,"type_num":2147483649,"type2_num":0,"jump":10,"fail":10}]
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ wx b8010000004839ca7f
|
|||
pij 3
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
[{"offset":0,"val":1,"esil":"1,rax,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov eax, 1","disasm":"mov eax, 1","bytes":"b801000000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":5,"esil":"rcx,rdx,==,$z,zf,:=,0,$b,cf,:=,$p,pf,:=,-1,$s,sf,:=,rcx,0x8000000000000000,-,!,-1,$o,^,of,:=,3,$b,af,:=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"cmp rdx, rcx","disasm":"cmp rdx, rcx","bytes":"4839ca","family":"cpu","type":"cmp","reloc":false,"type_num":15,"type2_num":0},{"offset":8,"esil":"sf,of,!,^,zf,!,&,?{,10,rip,=,}","refptr":false,"fcn_addr":0,"fcn_last":0,"size":2,"opcode":"jg 0xa","disasm":"jg 0xa","bytes":"7f00","family":"cpu","type":"cjmp","reloc":false,"type_num":2147483649,"type2_num":0,"jump":10,"fail":10}]
|
||||
[{"offset":0,"val":1,"esil":"1,rax,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov eax, 1","disasm":"mov eax, 1","bytes":"b801000000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":5,"esil":"rcx,rdx,==,$z,zf,:=,64,$b,cf,:=,$p,pf,:=,63,$s,sf,:=,rcx,0x8000000000000000,-,!,63,$o,^,of,:=,3,$b,af,:=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"cmp rdx, rcx","disasm":"cmp rdx, rcx","bytes":"4839ca","family":"cpu","type":"cmp","reloc":false,"type_num":15,"type2_num":0},{"offset":8,"esil":"sf,of,!,^,zf,!,&,?{,10,rip,=,}","refptr":false,"fcn_addr":0,"fcn_last":0,"size":2,"opcode":"jg 0xa","disasm":"jg 0xa","bytes":"7f00","family":"cpu","type":"cjmp","reloc":false,"type_num":2147483649,"type2_num":0,"jump":10,"fail":10}]
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ EXPECT=<<EOF
|
|||
},
|
||||
{
|
||||
"offset": 5,
|
||||
"esil": "rcx,rdx,==,$z,zf,:=,0,$b,cf,:=,$p,pf,:=,-1,$s,sf,:=,rcx,0x8000000000000000,-,!,-1,$o,^,of,:=,3,$b,af,:=",
|
||||
"esil": "rcx,rdx,==,$z,zf,:=,64,$b,cf,:=,$p,pf,:=,63,$s,sf,:=,rcx,0x8000000000000000,-,!,63,$o,^,of,:=,3,$b,af,:=",
|
||||
"refptr": false,
|
||||
"fcn_addr": 0,
|
||||
"fcn_last": 0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue