Skip to content

Commit

Permalink
ESILify the XCHG and XADD ops for x86
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jan 7, 2016
1 parent d2a192c commit 8686a35
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 28 additions & 1 deletion libr/anal/p/anal_x86_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,34 @@ SETL/SETNGE
op->type = R_ANAL_OP_TYPE_ADD;
op->family = R_ANAL_OP_FAMILY_MMX;
break;
case X86_INS_XCHG:
op->type = R_ANAL_OP_TYPE_MOV;
op->family = R_ANAL_OP_FAMILY_CPU;
{
char *src = getarg (&gop, 1, 0, NULL);
char *dst = getarg (&gop, 0, 1, NULL);
esilprintf (op, "%s,%s,%s,=,%s,=", src, dst, src, dst);
free (src);
free (dst);
}
break;
case X86_INS_XADD: /* xchg + add */
op->type = R_ANAL_OP_TYPE_ADD;
op->family = R_ANAL_OP_FAMILY_CPU;
{
char *src = getarg (&gop, 1, 0, NULL);
char *dst = getarg (&gop, 0, 1, NULL);
if (src == dst) {
esilprintf (op, "%s,%s,+,%s", src, dst, dst);
} else {
esilprintf (op, "%s,%s,%s,=,%s,=," "%s,%s,+,%s",
src, dst, src, dst,
src, dst, dst);
}
free (src);
free (dst);
}
break;
case X86_INS_FADD:
case X86_INS_FADDP:
op->family = R_ANAL_OP_FAMILY_FPU;
Expand All @@ -1303,7 +1331,6 @@ SETL/SETNGE
case X86_INS_ADDSUBPD:
case X86_INS_ADDSUBPS:
case X86_INS_ADDPD:
case X86_INS_XADD:
// The OF, SF, ZF, AF, CF, and PF flags are set according to the
// result.
op->type = R_ANAL_OP_TYPE_ADD;
Expand Down
2 changes: 2 additions & 0 deletions sys/indent-whitelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ libr/bin/filter.c
libr/bin/format/objc/mach0_classes.c
libr/cons/hud.c
libr/cons/2048.c
libr/cons/utf8.c
libr/cons/line.c
libr/cons/canvas.c
libr/cons/editor.c
Expand All @@ -31,6 +32,7 @@ libr/util/stack.c
libr/util/slist.c
libr/util/log.c
libr/util/cache.c
libr/core/file.c
"
case "$1" in
"help"|-h)
Expand Down

0 comments on commit 8686a35

Please sign in to comment.