Fix all latest COVs and avoid use of tabs in i

This commit is contained in:
pancake 2014-12-03 13:15:07 +01:00
parent 123c9a87d0
commit 20925abb7f
4 changed files with 123 additions and 84 deletions

View File

@ -194,6 +194,32 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_CLC:
case X86_INS_STC:
break;
// cmov
case X86_INS_CMOVA:
case X86_INS_CMOVAE:
case X86_INS_CMOVB:
case X86_INS_CMOVBE:
case X86_INS_FCMOVBE:
case X86_INS_FCMOVB:
case X86_INS_CMOVE:
case X86_INS_FCMOVE:
case X86_INS_CMOVG:
case X86_INS_CMOVGE:
case X86_INS_CMOVL:
case X86_INS_CMOVLE:
case X86_INS_FCMOVNBE:
case X86_INS_FCMOVNB:
case X86_INS_CMOVNE:
case X86_INS_FCMOVNE:
case X86_INS_CMOVNO:
case X86_INS_CMOVNP:
case X86_INS_FCMOVNU:
case X86_INS_CMOVNS:
case X86_INS_CMOVO:
case X86_INS_CMOVP:
case X86_INS_FCMOVU:
case X86_INS_CMOVS:
// mov
case X86_INS_MOV:
case X86_INS_MOVZX:
case X86_INS_MOVABS:
@ -219,13 +245,14 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
if (INSOP(0).mem.base == X86_REG_RIP) {
op->ptr += addr + insn->size;
}
if (a->decode && insn->detail) {
if (a->decode) {
esilprintf (op, "%s,%s",
getarg (insn, 1, 0),
getarg (insn, 0, 1));
}
break;
default:
if (a->decode && insn->detail) {
if (a->decode) {
esilprintf (op, "%s,%s,=",
getarg (insn, 1, 0),
getarg (insn, 0, 0));
@ -253,7 +280,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_SHLD:
case X86_INS_SHLX:
op->type = R_ANAL_OP_TYPE_SHL;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,<<=,cz,%%z,zf,=", src, dst);
@ -264,7 +291,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_SAR:
case X86_INS_SARX:
op->type = R_ANAL_OP_TYPE_SAR;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,>>=,%%z,zf,=", src, dst);
@ -275,7 +302,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_SAL:
case X86_INS_SALC:
op->type = R_ANAL_OP_TYPE_SAL;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,<<=,%%z,zf,=", src, dst);
@ -287,7 +314,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_SHRD:
case X86_INS_SHRX:
op->type = R_ANAL_OP_TYPE_SHR;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,>>=,cz,%%z,zf,=", src, dst);
@ -306,7 +333,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_CMPSS:
case X86_INS_TEST:
op->type = R_ANAL_OP_TYPE_CMP;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,==,%%z,zf,=", dst, src);
@ -341,7 +368,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case X86_INS_LEA:
op->type = R_ANAL_OP_TYPE_LEA;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 0, 0);
char *dst = getarg (insn, 1, 2);
esilprintf (op, "%s,%s,=", dst, src);
@ -387,7 +414,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_POPCNT:
op->type = R_ANAL_OP_TYPE_POP;
if (a->decode) {
char *dst = getarg(insn, 0, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op,
"%s,[%d],%s,=,%d,%s,+=",
sp, rs, dst, rs, sp);
@ -527,7 +554,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case X86_INS_JMP:
case X86_INS_LJMP:
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,=", src, pc);
free (src);
@ -563,7 +590,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_PXOR:
case X86_INS_XOR:
op->type = R_ANAL_OP_TYPE_XOR;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,^=", dst, src);
@ -573,7 +600,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case X86_INS_OR:
op->type = R_ANAL_OP_TYPE_OR;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,|=", dst, src);
@ -592,7 +619,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_PSUBUSB:
case X86_INS_PSUBUSW:
op->type = R_ANAL_OP_TYPE_SUB;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,-=,%%c,cf,=,%%z,zf,=,%%s,sf,=,%%o,of,=", src, dst); // TODO: update flags
@ -607,7 +634,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_ANDNPD:
case X86_INS_ANDNPS:
op->type = R_ANAL_OP_TYPE_AND;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,&=", dst, src);
@ -617,13 +644,27 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case X86_INS_DIV:
op->type = R_ANAL_OP_TYPE_DIV;
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,/=", dst, src);
free (src);
free (dst);
}
break;
case X86_INS_MUL:
op->type = R_ANAL_OP_TYPE_MUL;
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,*=", dst, src);
free (src);
free (dst);
}
break;
case X86_INS_INC:
op->type = R_ANAL_OP_TYPE_ADD;
if (a->decode && insn->detail) {
if (a->decode) {
char *dst = getarg (insn, 0, 0);
esilprintf (op, "1,%s,+=", dst);
free (dst);
@ -633,7 +674,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case X86_INS_FADD:
case X86_INS_ADDPD:
op->type = R_ANAL_OP_TYPE_ADD;
if (a->decode && insn->detail) {
if (a->decode) {
char *src = getarg (insn, 1, 0);
char *dst = getarg (insn, 0, 0);
esilprintf (op, "%s,%s,+=", dst, src);

View File

@ -75,12 +75,10 @@ static int r_line_readchar_utf8(unsigned char *s, int slen) {
if (!s[len]) return 1; // ^z
if (s[len] < 28)
return s[0]?1:0;
if (ret == 1) {
if (is_valid_char (s[len]))
return s[0]?1:0;
if ((s[len] & 0xc0) != 0x80) continue;
if (len>0) break;
} else return 0;
if (is_valid_char (s[len]))
return s[0]?1:0;
if ((s[len] & 0xc0) != 0x80) continue;
if (len>0) break;
}
len++;
s[len] = 0;

View File

@ -2,6 +2,19 @@
#include <r_core.h>
// dup from cmd_info
#define PAIR_WIDTH 9
static void pair(const char *a, const char *b) {
char ws[16];
int al = strlen (a);
if (!b) b = "";
memset (ws, ' ', sizeof (ws));
al = PAIR_WIDTH-al;
if (al<0) al = 0;
ws[al] = 0;
r_cons_printf ("%s%s%s\n", a, ws, b);
}
#define STR(x) (x)?(x):""
// XXX - this may lead to conflicts with set by name
static int r_core_bin_set_cur (RCore *core, RBinFile *binfile);
@ -351,43 +364,28 @@ static int bin_info (RCore *r, int mode) {
} else {
// if type is 'fs' show something different?
//r_cons_printf ("# File info\n");
r_cons_printf ("file\t%s\n"
"type\t%s\n"
"pic\t%s\n"
"canary\t%s\n"
"nx\t%s\n"
"crypto\t%s\n"
"has_va\t%s\n"
"root\t%s\n"
"class\t%s\n"
"lang\t%s\n"
"arch\t%s\n"
"bits\t%i\n"
"machine\t%s\n"
"os\t%s\n"
"subsys\t%s\n"
"endian\t%s\n"
"strip\t%s\n"
"static\t%s\n"
"linenum\t%s\n"
"lsyms\t%s\n"
"relocs\t%s\n"
"rpath\t%s\n",
info->file, info->type,
r_str_bool (info->has_pi),
r_str_bool (info->has_canary),
r_str_bool (info->has_nx),
r_str_bool (info->has_crypto),
r_str_bool (info->has_va),
info->rclass, info->bclass, info->lang?info->lang:"unknown",
info->arch, info->bits, info->machine, info->os,
info->subsystem, info->big_endian? "big": "little",
r_str_bool (R_BIN_DBG_STRIPPED &info->dbg_info),
r_str_bool (r_bin_is_static (r->bin)),
r_str_bool (R_BIN_DBG_LINENUMS &info->dbg_info),
r_str_bool (R_BIN_DBG_SYMS &info->dbg_info),
r_str_bool (R_BIN_DBG_RELOCS &info->dbg_info),
info->rpath);
pair ("file", info->file);
pair ("type", info->type);
pair ("pic", r_str_bool (info->has_pi));
pair ("canary", r_str_bool (info->has_canary));
pair ("nx", r_str_bool (info->has_nx));
pair ("crypto", r_str_bool (info->has_crypto));
pair ("va", r_str_bool (info->has_va));
pair ("root", info->rclass);
pair ("class", info->bclass);
pair ("lang", info->lang? info->lang: "unknown");
pair ("arch", info->arch);
pair ("bits", sdb_fmt (0, "%d", info->bits));
pair ("machine", info->machine);
pair ("os", info->os);
pair ("subsys", info->subsystem);
pair ("endian", info->big_endian? "big": "little");
pair ("strip", r_str_bool (R_BIN_DBG_STRIPPED &info->dbg_info));
pair ("static", r_str_bool (r_bin_is_static (r->bin)));
pair ("linenum", r_str_bool (R_BIN_DBG_LINENUMS &info->dbg_info));
pair ("lsyms", r_str_bool (R_BIN_DBG_SYMS &info->dbg_info));
pair ("relocs", r_str_bool (R_BIN_DBG_RELOCS &info->dbg_info));
pair ("rpath", info->rpath);
for (i=0; info->sum[i].type; i++) {
int len;
//ut8 *sum = &info; // XXX

View File

@ -1,5 +1,17 @@
/* radare - LGPL - Copyright 2009-2014 - pancake */
#define PAIR_WIDTH 9
static void pair(const char *a, const char *b) {
char ws[16];
int al = strlen (a);
if (!b) b = "";
memset (ws, ' ', sizeof (ws));
al = PAIR_WIDTH-al;
if (al<0) al = 0;
ws[al] = 0;
r_cons_printf ("%s%s%s\n", a, ws, b);
}
#define STR(x) (x)?(x):""
static void r_core_file_info (RCore *core, int mode) {
const char *fn = NULL;
@ -18,7 +30,7 @@ static void r_core_file_info (RCore *core, int mode) {
fn = info->file;
switch (mode) {
case R_CORE_BIN_JSON:
r_cons_printf ("\"type\":\"%s\","
r_cons_printf ("\"type\":\"%s\","
"\"os\":\"%s\","
"\"arch\":\"%s\","
"\"bits\":%d,"
@ -29,20 +41,12 @@ static void r_core_file_info (RCore *core, int mode) {
, info->bits
, info->big_endian? "big": "little");
break;
case R_CORE_BIN_SIMPLE:
// nothing here
break;
default:
r_cons_printf ("type\t%s\n"
"os\t%s\n"
"arch\t%s\n"
"bits\t%d\n"
"endian\t%s\n"
, STR(info->type)
, STR(info->os)
, STR(info->machine)
, info->bits
, info->big_endian? "big": "little");
pair ("type", info->type);
pair ("os", info->os);
pair ("arch", info->machine);
pair ("bits", sdb_fmt (0, "%d", info->bits));
pair ("endian", info->big_endian? "big": "little");
break;
}
} else fn = (cf && cf->desc) ? cf->desc->name : NULL;
@ -70,23 +74,21 @@ static void r_core_file_info (RCore *core, int mode) {
r_cons_printf ("}");
} else if (cf && mode != R_CORE_BIN_SIMPLE) {
//r_cons_printf ("# Core file info\n");
r_cons_printf ("file\t%s\n", fn);
pair ("file", fn);
if (dbg) dbg = R_IO_WRITE | R_IO_EXEC;
if (cf->desc) {
if (cf->desc->referer && *cf->desc->referer)
r_cons_printf ("referer\t%s\n", cf->desc->referer);
r_cons_printf ("fd\t%d\n", cf->desc->fd);
r_cons_printf ("size\t0x%"PFMT64x"\n", r_io_desc_size (core->io, cf->desc));
r_cons_printf ("mode\t%s\n", r_str_rwx_i (cf->desc->flags & 7 ));
r_cons_printf ("uri\t%s\n", cf->desc->uri);
pair ("referer", cf->desc->referer);
pair ("fd", sdb_fmt (0, "%d", cf->desc->fd));
pair ("size", sdb_fmt (0,"0x%"PFMT64x, r_io_desc_size (core->io, cf->desc)));
pair ("mode", r_str_rwx_i (cf->desc->flags & 7));
pair ("uri", cf->desc->uri);
}
r_cons_printf ("block\t0x%x\n", core->blocksize);
pair ("block", sdb_fmt (0, "0x%x", core->blocksize));
if (binfile && binfile->curxtr)
r_cons_printf ("packet\t%s\n",
binfile->curxtr->name);
pair ("packet", binfile->curxtr->name);
if (plugin)
r_cons_printf ("format\t%s\n",
plugin->name);
pair ("format", plugin->name);
}
}