mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-25 22:29:48 +00:00
Fix radiff2, Ps segfaults and ARC syntax
- Fix some nullptr derefs on uninitialized graphdiff structs - 'ar' is now r_cons compliant and rnum friendly (add arj) - Fix some arc disasm syntax issues - Fix segfault when saving analysis info in projects - ARCompact analysis needs to be rewritten
This commit is contained in:
parent
bd100e9853
commit
bec4f5b63a
@ -68,10 +68,6 @@ static RCore* opencore(const char *f) {
|
||||
return c;
|
||||
}
|
||||
|
||||
static void diff_graph(RCore *c, RCore *c2, const char *arg) {
|
||||
r_core_cmdf (c, "agd %s", arg);
|
||||
}
|
||||
|
||||
static int show_help(int v) {
|
||||
printf ("Usage: radiff2 [-cCdrspOv] [-g sym] [-t %%] [file] [file]\n");
|
||||
if (v) printf (
|
||||
@ -190,9 +186,10 @@ int main(int argc, char **argv) {
|
||||
r_anal_diff_setup_i (c->anal, diffops, threshold, threshold);
|
||||
r_anal_diff_setup_i (c2->anal, diffops, threshold, threshold);
|
||||
r_core_gdiff (c, c2);
|
||||
if (mode == MODE_GRAPH)
|
||||
diff_graph (c, c2, addr);
|
||||
else r_core_diff_show (c, c2);
|
||||
if (mode == MODE_GRAPH) {
|
||||
/* show only ->diff info from main core */
|
||||
r_core_cmdf (c, "agd %s", addr);
|
||||
} else r_core_diff_show (c, c2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -171,3 +171,4 @@ That's embarrassing.
|
||||
Connection with license server failed.
|
||||
In soviet afghanistan radare debugs russia!
|
||||
In soviet afghanistan you debug radare!
|
||||
You should know that ptracing binaries younger than 18yo is illegal
|
||||
|
@ -50,6 +50,8 @@ R_API RAnal *r_anal_new() {
|
||||
anal->decode = R_TRUE; // slow slow if not used
|
||||
anal->sdb_xrefs = NULL;
|
||||
anal->sdb_types = sdb_new (NULL, 0);
|
||||
anal->meta = r_meta_new ();
|
||||
anal->meta->printf = anal->printf = (PrintfCallback) printf;
|
||||
r_anal_type_init (anal);
|
||||
r_anal_xrefs_init (anal);
|
||||
anal->diff_ops = 0;
|
||||
@ -57,7 +59,6 @@ R_API RAnal *r_anal_new() {
|
||||
anal->diff_thfcn = R_ANAL_THRESHOLDFCN;
|
||||
anal->split = R_TRUE; // used from core
|
||||
anal->queued = NULL;
|
||||
anal->meta = r_meta_new ();
|
||||
anal->syscall = r_syscall_new ();
|
||||
r_io_bind_init (anal->iob);
|
||||
anal->reg = r_reg_new ();
|
||||
@ -117,7 +118,7 @@ R_API int r_anal_list(RAnal *anal) {
|
||||
struct list_head *pos;
|
||||
list_for_each_prev(pos, &anal->anals) {
|
||||
RAnalPlugin *h = list_entry(pos, RAnalPlugin, list);
|
||||
printf ("anal %-10s %s\n", h->name, h->desc);
|
||||
anal->printf ("anal %-10s %s\n", h->name, h->desc);
|
||||
}
|
||||
return R_FALSE;
|
||||
}
|
||||
@ -227,7 +228,7 @@ R_API int r_anal_project_save(RAnal *anal, const char *prjfile) {
|
||||
|
||||
R_API RAnalOp *r_anal_op_hexstr(RAnal *anal, ut64 addr, const char *str) {
|
||||
int len;
|
||||
char *buf;
|
||||
ut8 *buf;
|
||||
RAnalOp *op = R_NEW0 (RAnalOp);
|
||||
buf = malloc (strlen (str));
|
||||
len = r_hex_str2bin (str, buf);
|
||||
|
@ -21,8 +21,8 @@
|
||||
#define X86IM_CORE_OP_DEC 1
|
||||
#define X86IM_CORE_OP_GEN 2
|
||||
|
||||
#define X86IM_CORE_OP_IS_DEC(x) ( (x)->op == X86IM_CORE_OP_DEC )
|
||||
#define X86IM_CORE_OP_IS_GEN(x) ( (x)->op == X86IM_CORE_OP_GEN )
|
||||
#define X86IM_CORE_OP_IS_DEC(x) (x)->op == X86IM_CORE_OP_DEC
|
||||
#define X86IM_CORE_OP_IS_GEN(x) (x)->op == X86IM_CORE_OP_GEN
|
||||
|
||||
typedef struct _core_opdata
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ R_API char *r_anal_cc_to_string (RAnal *anal, RAnalCC* cc) {
|
||||
if (item) {
|
||||
snprintf (buf, sizeof (buf), "0x%"PFMT64x, r_reg_get_value (anal->reg, item));
|
||||
strcat (str, buf); // XXX: do not use strcat
|
||||
} else eprintf ("Unknown reg '%s'\n", reg);
|
||||
} //else eprintf ("Unknown reg '%s'\n", reg);
|
||||
if (i<si->args-1)
|
||||
strcat (str, ","); // XXX: do not use strcat
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2011 - nibble<.ds@gmail.com>, pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2010-2013 - nibble<.ds@gmail.com>, pancake<nopcode.org> */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
@ -123,7 +123,7 @@ R_API int r_anal_diff_bb(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2) {
|
||||
mbb2 = bb2;
|
||||
if (t == 1) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mbb != NULL && mbb2 != NULL) {
|
||||
if (ot == 1 || t > anal->diff_thfcn )
|
||||
|
@ -511,7 +511,7 @@ R_API int r_anal_fcn_split_bb(RAnalFunction *fcn, RAnalBlock *bb, ut64 addr) {
|
||||
return R_ANAL_RET_DUP;
|
||||
if (addr > bbi->addr && addr < bbi->addr + bbi->size) {
|
||||
r_list_append (fcn->bbs, bb);
|
||||
bb->addr = addr;
|
||||
bb->addr = addr+bbi->size;
|
||||
bb->size = bbi->addr + bbi->size - addr;
|
||||
bb->jump = bbi->jump;
|
||||
bb->fail = bbi->fail;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2012 - pancake */
|
||||
/* radare - LGPL - Copyright 2012-2013 - pancake */
|
||||
|
||||
#include <string.h>
|
||||
#include <r_types.h>
|
||||
@ -6,117 +6,80 @@
|
||||
#include <r_asm.h>
|
||||
#include <r_anal.h>
|
||||
|
||||
static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
|
||||
/* ARCompact ISA */
|
||||
const ut8 *b = (ut8 *)data;
|
||||
int lowbyte, highbyte;
|
||||
|
||||
lowbyte = anal->big_endian? 0: 1;
|
||||
highbyte = anal->big_endian? 1: 0;
|
||||
|
||||
if (((b[lowbyte]&0xf8) >0x38) && ((b[lowbyte]&0xf8) != 0x48)) {
|
||||
op->length = 2;
|
||||
} else {
|
||||
op->length = 4;
|
||||
}
|
||||
// XXX: compact instructions can be >4 !??
|
||||
op->fail = addr + 4;
|
||||
ut8 basecode = (b[3] & 0xf8) >> 3;
|
||||
ut8 subopcode = ((b[1]&0xf)>>2)<<1;
|
||||
//eprintf ("----> ST %x\n", subopcode);
|
||||
//eprintf ("BC = 0x%x\n", basecode);
|
||||
if (!memcmp (b, "\x4a\x26\x00\x70", 4)) {
|
||||
op->type = R_ANAL_OP_TYPE_NOP;
|
||||
return 4;
|
||||
}
|
||||
return op->length;
|
||||
}
|
||||
|
||||
static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
|
||||
const ut8 *b = (ut8 *)data;
|
||||
memset (op, '\0', sizeof (RAnalOp));
|
||||
op->length = 4;
|
||||
|
||||
if (anal->bits == 32) {
|
||||
/* ARCtangent A4 */
|
||||
op->fail = addr + 4;
|
||||
ut8 basecode = (b[3] & 0xf8) >> 3;
|
||||
switch (basecode) {
|
||||
case 0x04: /* Branch */
|
||||
case 0x05: /* Branch with Link */
|
||||
case 0x06: /* Loop */
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = addr + 4 + (((b[1] << 1) | (b[2] << 9) |
|
||||
((b[3] & 7) << 17) | ((b[0] & 0x80) >> 7)) << 2);
|
||||
break;
|
||||
case 0x07: /* Conditional Jump and Jump with Link */
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = 0;
|
||||
break;
|
||||
case 0x08:
|
||||
case 0x09:
|
||||
op->type = R_ANAL_OP_TYPE_ADD;
|
||||
break;
|
||||
case 0x0a:
|
||||
case 0x0b:
|
||||
op->type = R_ANAL_OP_TYPE_SUB;
|
||||
break;
|
||||
case 0x0c:
|
||||
op->type = R_ANAL_OP_TYPE_AND;
|
||||
break;
|
||||
case 0x0d:
|
||||
op->type = R_ANAL_OP_TYPE_OR;
|
||||
break;
|
||||
case 0x0f:
|
||||
if ((b[0] == 0xff) && (b[1] == 0xff)) {
|
||||
op->type = R_ANAL_OP_TYPE_NOP;
|
||||
break;
|
||||
}
|
||||
op->type = R_ANAL_OP_TYPE_XOR;
|
||||
break;
|
||||
case 0x13:
|
||||
op->type = R_ANAL_OP_TYPE_ROR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* ARCompact ISA */
|
||||
op->fail = addr + 4;
|
||||
ut8 basecode = (b[3] & 0xf8) >> 3;
|
||||
switch (basecode) {
|
||||
case 0x0:
|
||||
{
|
||||
ut64 imm = ((((b[0] & 0xc0) >> 6) | (b[1] << 2)) << 11) |
|
||||
((((b[2] & 0xfe) >> 1) | ((b[3] & 0x7) << 8)) << 1);
|
||||
if (imm != 0) {
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = imm;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = 0;
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
case 0x05:
|
||||
case 0x06:
|
||||
case 0x07:
|
||||
case 0x08:
|
||||
case 0x09:
|
||||
case 0x0a:
|
||||
case 0x0b:
|
||||
break;
|
||||
default:
|
||||
/* This is 16 bit instruction */
|
||||
op->length = 2;
|
||||
op->fail = addr + 2;
|
||||
basecode = (b[1] & 0xf8) >> 3;
|
||||
switch (basecode) {
|
||||
case 0x0c:
|
||||
case 0x0d:
|
||||
op->type = R_ANAL_OP_TYPE_ADD;
|
||||
break;
|
||||
case 0x0e:
|
||||
op->type = R_ANAL_OP_TYPE_MOV;
|
||||
break;
|
||||
case 0x1b:
|
||||
op->type = R_ANAL_OP_TYPE_MOV;
|
||||
break;
|
||||
case 0x1c:
|
||||
if (b[0] & 0x80)
|
||||
op->type = R_ANAL_OP_TYPE_CMP;
|
||||
else
|
||||
op->type = R_ANAL_OP_TYPE_ADD;
|
||||
break;
|
||||
case 0x1d:
|
||||
case 0x1e:
|
||||
case 0x1f:
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* ARCtangent A4 */
|
||||
if (anal->bits == 16)
|
||||
return arcompact_op (anal, op, addr, data, len);
|
||||
op->length = 4;
|
||||
op->fail = addr + 4;
|
||||
ut8 basecode = (b[3] & 0xf8) >> 3;
|
||||
switch (basecode) {
|
||||
case 0x04: /* Branch */
|
||||
case 0x05: /* Branch with Link */
|
||||
case 0x06: /* Loop */
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = addr + 4 + (((b[1] << 1) | (b[2] << 9) |
|
||||
((b[3] & 7) << 17) | ((b[0] & 0x80) >> 7)) << 2);
|
||||
break;
|
||||
case 0x07: /* Conditional Jump and Jump with Link */
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->jump = 0;
|
||||
break;
|
||||
case 0x08:
|
||||
case 0x09:
|
||||
op->type = R_ANAL_OP_TYPE_ADD;
|
||||
break;
|
||||
case 0x0a:
|
||||
case 0x0b:
|
||||
op->type = R_ANAL_OP_TYPE_SUB;
|
||||
break;
|
||||
case 0x0c:
|
||||
op->type = R_ANAL_OP_TYPE_AND;
|
||||
break;
|
||||
case 0x0d:
|
||||
op->type = R_ANAL_OP_TYPE_OR;
|
||||
break;
|
||||
case 0x0f:
|
||||
if ((b[0] == 0xff) && (b[1] == 0xff)) {
|
||||
op->type = R_ANAL_OP_TYPE_NOP;
|
||||
break;
|
||||
}
|
||||
op->type = R_ANAL_OP_TYPE_XOR;
|
||||
break;
|
||||
case 0x13:
|
||||
op->type = R_ANAL_OP_TYPE_ROR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return op->length;
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ R_API void r_anal_xrefs_save(RAnal *anal, const char *prjfile) {
|
||||
|
||||
R_API RList *r_anal_xrefs_set (RAnal *anal, const char *type, ut64 from, ut64 to) {
|
||||
char key[32];
|
||||
snprintf (key, sizeof (key), "ref.%s.%"PFMT64x, type, from);
|
||||
snprintf (key, sizeof (key), "ref.%s.0x%"PFMT64x, type, from);
|
||||
sdb_aaddn (DB, key, -1, to, 0);
|
||||
snprintf (key, sizeof (key), "xref.%s.%"PFMT64x, type, to);
|
||||
snprintf (key, sizeof (key), "xref.%s.0x%"PFMT64x, type, to);
|
||||
sdb_aaddn (DB, key, -1, from, 0);
|
||||
// (-1)funfor.%d=%d
|
||||
return NULL;
|
||||
@ -33,7 +33,7 @@ R_API RList *r_anal_xrefs_set (RAnal *anal, const char *type, ut64 from, ut64 to
|
||||
|
||||
R_API RList *r_anal_xrefs_deln (RAnal *anal, const char *type, ut64 from, ut64 to) {
|
||||
char key[32];
|
||||
snprintf (key, sizeof (key), "%s.%"PFMT64x, type, from);
|
||||
snprintf (key, sizeof (key), "%s.0x%"PFMT64x, type, from);
|
||||
sdb_adeln (DB, key, to, 0);
|
||||
return NULL;
|
||||
}
|
||||
@ -42,7 +42,7 @@ R_API int r_anal_xrefs_from (RAnal *anal, RList *list, const char *kind, const c
|
||||
char *s, *str, *ptr, key[256];
|
||||
RAnalRef *ref = NULL;
|
||||
int hasnext = 1;
|
||||
snprintf (key, sizeof (key), "%s.%s.%"PFMT64x, kind, type, addr);
|
||||
snprintf (key, sizeof (key), "%s.%s.0x%"PFMT64x, kind, type, addr);
|
||||
str = sdb_get (DB, key, 0);
|
||||
if (!str) return R_FALSE;
|
||||
for (ptr=str; hasnext; ptr = (char *)sdb_anext (s)) {
|
||||
@ -84,17 +84,46 @@ R_API void r_anal_xrefs_init (RAnal *anal) {
|
||||
#endif
|
||||
}
|
||||
|
||||
R_API void r_anal_xrefs_list(RAnal *anal) {
|
||||
|
||||
// TODO: make it better!
|
||||
sdb_list (DB);
|
||||
#if 0
|
||||
char *k, *v;
|
||||
sdb_dump_begin (DB);
|
||||
while (sdb_dump_dupnext (DB, &k, &v)) {
|
||||
printf ("%s=%s\n", k, v);
|
||||
free (k);
|
||||
free (v);
|
||||
static void xrefs_list_cb_rad(RAnal *anal, const char *k, const char *v) {
|
||||
ut64 dst, src = r_num_get (NULL, v);
|
||||
if (!strncmp (k, "ref.", 4)) {
|
||||
char *p = strchr (k+4, '.');
|
||||
if (p) {
|
||||
dst = r_num_get (NULL, p+1);
|
||||
anal->printf ("ar 0x%"PFMT64x" 0x%"PFMT64x"\n", src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void xrefs_list_cb_json(RAnal *anal, const char *k, const char *v) {
|
||||
ut64 dst, src = r_num_get (NULL, v);
|
||||
if (!strncmp (k, "ref.", 4) && (strlen (k)>8)) {
|
||||
char *p = strchr (k+4, '.');
|
||||
if (p) {
|
||||
dst = r_num_get (NULL, p+1);
|
||||
sscanf (p+1, "0x%"PFMT64x, &dst);
|
||||
anal->printf ("%"PFMT64d":%"PFMT64d",", src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void xrefs_list_cb_plain(RAnal *anal, const char *k, const char *v) {
|
||||
anal->printf ("%s=%s\n", k, v);
|
||||
}
|
||||
|
||||
R_API void r_anal_xrefs_list(RAnal *anal, int rad) {
|
||||
switch (rad) {
|
||||
case 1:
|
||||
case '*':
|
||||
sdb_foreach (DB, xrefs_list_cb_rad, anal);
|
||||
break;
|
||||
case 'j':
|
||||
anal->printf ("{");
|
||||
sdb_foreach (DB, xrefs_list_cb_json, anal);
|
||||
anal->printf ("}\n");
|
||||
break;
|
||||
default:
|
||||
sdb_foreach (DB, xrefs_list_cb_plain, anal);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -162,11 +162,11 @@ typedef enum
|
||||
#define IS_SMALL(x) (((field##x) < 256) && ((field##x) > -257))
|
||||
#define IS_REG(x) (field##x##isReg)
|
||||
#define WRITE_FORMAT_LB_Rx_RB(x) WRITE_FORMAT (x, "[","]","","")
|
||||
#define WRITE_FORMAT_x_COMMA_LB(x) WRITE_FORMAT (x, "",",[","",",[")
|
||||
#define WRITE_FORMAT_COMMA_x_RB(x) WRITE_FORMAT (x, ",","]",",","]")
|
||||
#define WRITE_FORMAT_x_COMMA_LB(x) WRITE_FORMAT (x, "",", [","",", [")
|
||||
#define WRITE_FORMAT_COMMA_x_RB(x) WRITE_FORMAT (x, ", ","]",",","]")
|
||||
#define WRITE_FORMAT_x_RB(x) WRITE_FORMAT (x, "","]","","]")
|
||||
#define WRITE_FORMAT_COMMA_x(x) WRITE_FORMAT (x, ",","",",","")
|
||||
#define WRITE_FORMAT_x_COMMA(x) WRITE_FORMAT (x, "",",","",",")
|
||||
#define WRITE_FORMAT_COMMA_x(x) WRITE_FORMAT (x, ", ","",", ","")
|
||||
#define WRITE_FORMAT_x_COMMA(x) WRITE_FORMAT (x, "",", ","",", ")
|
||||
#define WRITE_FORMAT_x(x) WRITE_FORMAT (x, "","","","")
|
||||
#define WRITE_FORMAT(x,cb1,ca1,cb,ca) strcat (formatString, \
|
||||
(IS_REG (x) ? cb1"%r"ca1 : \
|
||||
@ -1167,9 +1167,11 @@ ARCTangent_decodeInstr (bfd_vma address, disassemble_info *info)
|
||||
bytes = dsmOneArcInst (address, (void *)& s);
|
||||
|
||||
/* Display the disassembly instruction. */
|
||||
/*
|
||||
(*func) (stream, "%08lx ", s.words[0]);
|
||||
(*func) (stream, " ");
|
||||
(*func) (stream, "%-10s ", s.instrBuffer);
|
||||
(*func) (stream, " ");
|
||||
*/
|
||||
(*func) (stream, "%s ", s.instrBuffer);
|
||||
|
||||
if (__TRANSLATION_REQUIRED (s))
|
||||
{
|
||||
|
@ -256,11 +256,11 @@ static bfd_vma bfd_getm32_ac (unsigned int) ATTRIBUTE_UNUSED;
|
||||
#define IS_SIMD_16_REG(x) (usesSimdReg##x == 2)
|
||||
#define IS_SIMD_DATA_REG(x) (usesSimdReg##x == 3)
|
||||
#define WRITE_FORMAT_LB_Rx_RB(x) WRITE_FORMAT(x,"[","]","","")
|
||||
#define WRITE_FORMAT_x_COMMA_LB(x) WRITE_FORMAT(x,"",",[","",",[")
|
||||
#define WRITE_FORMAT_COMMA_x_RB(x) WRITE_FORMAT(x,",","]",",","]")
|
||||
#define WRITE_FORMAT_x_COMMA_LB(x) WRITE_FORMAT(x,"",", [","",",[")
|
||||
#define WRITE_FORMAT_COMMA_x_RB(x) WRITE_FORMAT(x,", ","]",", ","]")
|
||||
#define WRITE_FORMAT_x_RB(x) WRITE_FORMAT(x,"","]","","]")
|
||||
#define WRITE_FORMAT_COMMA_x(x) WRITE_FORMAT(x,",","",",","")
|
||||
#define WRITE_FORMAT_x_COMMA(x) WRITE_FORMAT(x,"",",","",",")
|
||||
#define WRITE_FORMAT_COMMA_x(x) WRITE_FORMAT(x,", ","",", ","")
|
||||
#define WRITE_FORMAT_x_COMMA(x) WRITE_FORMAT(x,"",", ","",", ")
|
||||
#define WRITE_FORMAT_x(x) WRITE_FORMAT(x,"","","","")
|
||||
#define WRITE_FORMAT(x,cb1,ca1,cb,ca) strcat(formatString, \
|
||||
(IS_SIMD_128_REG(x) ? cb1"%S"ca1: \
|
||||
@ -3866,7 +3866,7 @@ ARCompact_decodeInstr (bfd_vma address, /* Address of this instruct
|
||||
operand = space + 1;
|
||||
}
|
||||
|
||||
(*func) (stream, "%-10s ", instr);
|
||||
(*func) (stream, "%s ", instr);
|
||||
|
||||
if (__TRANSLATION_REQUIRED(s))
|
||||
{
|
||||
@ -3895,8 +3895,7 @@ ARCompact_decodeInstr (bfd_vma address, /* Address of this instruct
|
||||
/* We print max bytes for instruction */
|
||||
info->bytes_per_line = 8;
|
||||
|
||||
return s.instructionLen;
|
||||
|
||||
return bytes; //s.instructionLen;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -59,7 +59,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
||||
if (len<4) return -1;
|
||||
buf_global = op->buf_asm;
|
||||
Offset = a->pc;
|
||||
memcpy (bytes, buf, 4); // TODO handle thumb
|
||||
memcpy (bytes, buf, 4); // TODO handle compact
|
||||
|
||||
/* prepare disassembler */
|
||||
memset (&disasm_obj,'\0', sizeof (struct disassemble_info));
|
||||
@ -71,15 +71,12 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
||||
disasm_obj.endian = !a->big_endian;
|
||||
disasm_obj.fprintf_func = &buf_fprintf;
|
||||
disasm_obj.stream = stdout;
|
||||
disasm_obj.mach = 0; //((a->bits == 64)
|
||||
disasm_obj.mach = 0;
|
||||
|
||||
op->buf_asm[0]='\0';
|
||||
//op->inst_len = print_insn_shl ((bfd_vma)Offset, &disasm_obj);
|
||||
//op->inst_len = print_insn_shl ((bfd_vma)Offset, &disasm_obj);
|
||||
if (a->bits==16)
|
||||
op->inst_len = ARCompact_decodeInstr ((bfd_vma)Offset, &disasm_obj);
|
||||
else
|
||||
op->inst_len = ARCTangent_decodeInstr ((bfd_vma)Offset, &disasm_obj);
|
||||
if (a->bits==16)
|
||||
op->inst_len = ARCompact_decodeInstr ((bfd_vma)Offset, &disasm_obj);
|
||||
else op->inst_len = ARCTangent_decodeInstr ((bfd_vma)Offset, &disasm_obj);
|
||||
|
||||
if (op->inst_len == -1)
|
||||
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
|
||||
|
@ -936,7 +936,7 @@ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref) {
|
||||
}
|
||||
|
||||
R_API int r_core_anal_ref_list(RCore *core, int rad) {
|
||||
r_anal_xrefs_list (core->anal);
|
||||
r_anal_xrefs_list (core->anal, rad);
|
||||
return 0;
|
||||
#if 0
|
||||
RAnalFunction *fcni;
|
||||
|
@ -821,10 +821,9 @@ eprintf ("XXX: This command conflicts with 'ar'\n");
|
||||
r_anal_ref_del (core->anal, r_num_math (core->num, input+2), core->offset);
|
||||
break;
|
||||
case '\0':
|
||||
r_core_anal_ref_list (core, R_FALSE);
|
||||
break;
|
||||
case 'j':
|
||||
case '*':
|
||||
r_core_anal_ref_list (core, R_TRUE);
|
||||
r_core_anal_ref_list (core, input[1]);
|
||||
break;
|
||||
case 'd':
|
||||
case ' ':
|
||||
@ -853,11 +852,12 @@ eprintf ("XXX: This command conflicts with 'ar'\n");
|
||||
eprintf ("XXX: This command conflicts with 'ax'\n");
|
||||
r_cons_printf (
|
||||
"Usage: ar[?d-l*]\n"
|
||||
" ar addr [at] ; Add code ref pointing to addr (at is curseek)\n"
|
||||
" ard addr [at] ; Add data ref\n"
|
||||
" ar- [at] ; Clean all refs (or refs from addr)\n"
|
||||
" ar ; List refs\n"
|
||||
" ar* ; Output radare commands\n");
|
||||
" ar addr [at] Add code ref pointing to addr (at is curseek)\n"
|
||||
" ard addr [at] Add data ref\n"
|
||||
" arj List refs in json format\n"
|
||||
" ar- [at] Clean all refs (or refs from addr)\n"
|
||||
" ar List refs\n"
|
||||
" ar* Output radare commands\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -529,6 +529,7 @@ R_API int r_core_init(RCore *core) {
|
||||
core->anal = r_anal_new ();
|
||||
core->assembler->syscall = core->anal->syscall; // BIND syscall anal/asm
|
||||
r_anal_set_user_ptr (core->anal, core);
|
||||
core->anal->printf = (void *) r_cons_printf;
|
||||
core->anal->meta->printf = (void *) r_cons_printf;
|
||||
core->parser = r_parse_new ();
|
||||
core->parser->anal = core->anal;
|
||||
|
@ -135,7 +135,7 @@ static void colorize_opcode (char *p, const char *reg, const char *num) {
|
||||
strcpy (o+j, Color_RESET);
|
||||
j += strlen (Color_RESET);
|
||||
o[j++] = p[i];
|
||||
if ((p[i] > '0') && (p[i] < '9')) {
|
||||
if (p[i]=='$' || ((p[i] > '0') && (p[i] < '9'))) {
|
||||
strcpy (o+j, num);
|
||||
j += strlen (num)-1;
|
||||
} else {
|
||||
@ -552,7 +552,7 @@ toro:
|
||||
char *t, *b = asmop.buf_asm;
|
||||
for (; *b; b++, i++) {
|
||||
if (*b!=' ') continue;
|
||||
n = (10-i);
|
||||
n = (12-i);
|
||||
t = strdup (b+1); //XXX slow!
|
||||
if (n<1) n = 1;
|
||||
memset (b, ' ', n);
|
||||
|
@ -85,6 +85,12 @@ R_API int r_core_project_save(RCore *core, const char *file) {
|
||||
r_str_write (fd, "# meta\n");
|
||||
r_meta_list (core->anal->meta, R_META_TYPE_ANY, 1);
|
||||
r_cons_flush ();
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf (buf, sizeof(buf), "%s.d/xrefs", prj);
|
||||
sdb_file (core->anal->sdb_xrefs, buf);
|
||||
sdb_sync (core->anal->sdb_xrefs);
|
||||
}
|
||||
r_core_cmd (core, "ar*", 0);
|
||||
r_cons_flush ();
|
||||
r_core_cmd (core, "af*", 0);
|
||||
|
@ -515,6 +515,7 @@ typedef struct r_anal_t {
|
||||
RList *hints; // XXX use better data structure here (slist?)
|
||||
Sdb *sdb_xrefs;
|
||||
Sdb *sdb_types;
|
||||
PrintfCallback printf;
|
||||
} RAnal;
|
||||
|
||||
typedef struct r_anal_hint_t {
|
||||
@ -763,7 +764,7 @@ R_API int r_anal_fcn_count (RAnal *a, ut64 from, ut64 to);
|
||||
#define r_anal_fcn_get_vars(x) x->vars
|
||||
#define r_anal_fcn_get_bbs(x) x->bbs
|
||||
#else
|
||||
R_API void r_anal_xrefs_list(RAnal *anal);
|
||||
R_API void r_anal_xrefs_list(RAnal *anal, int rad);
|
||||
R_API RList* r_anal_fcn_get_refs (RAnalFunction *anal);
|
||||
R_API RList* r_anal_fcn_get_xrefs (RAnalFunction *anal);
|
||||
R_API RList *r_anal_xrefs_set (RAnal *anal, const char *type, ut64 from, ut64 to);
|
||||
|
Loading…
Reference in New Issue
Block a user