mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-02 10:16:21 +00:00
* Some fixes in make all/clean
* Initial work on RAnalCond
This commit is contained in:
parent
4bd719546c
commit
d3c0819cc7
5
Makefile
5
Makefile
@ -51,6 +51,11 @@ uninstall:
|
||||
|
||||
deinstall: uninstall
|
||||
cd libr && ${MAKE} uninstall PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR}
|
||||
rm -rf ${DESTDIR}${PREFIX}/include/libr
|
||||
rm -rf ${DESTDIR}${PREFIX}/lib/libr_*.so
|
||||
rm -rf ${DESTDIR}${PREFIX}/lib/libr_*.a
|
||||
rm -rf ${DESTDIR}${PREFIX}/lib/libr.so
|
||||
rm -rf ${DESTDIR}${PREFIX}/lib/libr.a
|
||||
rm -rf ${DESTDIR}${PREFIX}/share/doc/radare2
|
||||
|
||||
swig-dist:
|
||||
|
@ -19,8 +19,6 @@ Code analysis module
|
||||
|
||||
-- allow to load register values from traces
|
||||
|
||||
* TODO: Add static plugin support here
|
||||
|
||||
var an = new RAnal ();
|
||||
io.bind (an);
|
||||
an.set ("x86");
|
||||
@ -57,7 +55,7 @@ r_anal_get_fun(an, 0x804800);
|
||||
|
||||
void analyze_graph(Analysis an, uint64 addr)
|
||||
{
|
||||
var? op = an.get_op(addr);
|
||||
var op = an.get_op(addr);
|
||||
while (op != null) {
|
||||
if (op.type == Analysis.OpcodeType.BRANCH) {
|
||||
foreach (var jmp in op.refs) {
|
||||
|
@ -303,29 +303,27 @@ R_API int r_core_anal_fcn_clean(RCore *core, ut64 addr) {
|
||||
}
|
||||
|
||||
R_API void r_core_anal_refs(RCore *core, ut64 addr, int gv) {
|
||||
RListIter *iter, *iter2;
|
||||
RAnalRef *fcnr;
|
||||
RAnalFcn *fcni;
|
||||
RListIter *iter, *iter2;
|
||||
const char *name;
|
||||
|
||||
if (gv)
|
||||
r_cons_printf ("digraph code {\n"
|
||||
if (gv) r_cons_printf ("digraph code {\n"
|
||||
"\tgraph [bgcolor=white];\n"
|
||||
"\tnode [color=lightgray, style=filled shape=box"
|
||||
" fontname=\"Courier\" fontsize=\"8\"];\n");
|
||||
|
||||
r_list_foreach (core->anal->fcns, iter, fcni) {
|
||||
if (addr != 0 && addr != fcni->addr)
|
||||
continue;
|
||||
if (!gv)
|
||||
r_cons_printf ("0x%08"PFMT64x"\n", fcni->addr);
|
||||
if (!gv) r_cons_printf ("0x%08"PFMT64x"\n", fcni->addr);
|
||||
r_list_foreach (fcni->refs, iter2, fcnr) {
|
||||
char *name = "";
|
||||
// TODO: display only code or data refs?
|
||||
RFlagItem *flag = r_flag_get_i (core->flags, fcnr->addr);
|
||||
if (flag)
|
||||
name = flag->name;
|
||||
if (gv) r_cons_printf ("\t\"0x%08"PFMT64x"\" -> \"0x%08"PFMT64x"\" [label=\"%s\" color=\"%s\"];\n",
|
||||
fcni->addr, fcnr->addr, name, "green");
|
||||
else r_cons_printf (" - 0x%08"PFMT64x"\n", fcnr->addr);
|
||||
if (gv) r_cons_printf ("\t\"0x%08"PFMT64x"\" -> \"0x%08"PFMT64x"\" "
|
||||
"[label=\"%s\" color=\"%s\"];\n",
|
||||
fcni->addr, fcnr->addr, flag?flag->name:"",
|
||||
(fcnr->type==R_ANAL_REF_TYPE_CODE)?"green":"red");
|
||||
else r_cons_printf (" - 0x%08"PFMT64x" (%c)\n", fcnr->addr, fcnr->type);
|
||||
}
|
||||
}
|
||||
r_cons_printf ("}\n");
|
||||
@ -339,26 +337,12 @@ R_API int r_core_anal_fcn_list(RCore *core, int rad) {
|
||||
|
||||
r_list_foreach (core->anal->fcns, iter, fcni)
|
||||
if (rad) {
|
||||
r_cons_printf ("af+ 0x%08"PFMT64x" %"PFMT64d" %s", fcni->addr, fcni->size, fcni->name);
|
||||
|
||||
if ((fcni->diff == R_ANAL_DIFF_MATCH))
|
||||
r_cons_printf (" m");
|
||||
else if ((fcni->diff == R_ANAL_DIFF_UNMATCH))
|
||||
r_cons_printf (" u");
|
||||
else r_cons_printf (" n");
|
||||
r_cons_printf ("\n");
|
||||
r_cons_printf ("af+ 0x%08"PFMT64x" %"PFMT64d" %s (%c)\n",
|
||||
fcni->addr, fcni->size, fcni->name, fcni->diff?fcni->diff:'n');
|
||||
} else {
|
||||
r_cons_printf ("[0x%08"PFMT64x"] size=%"PFMT64d" name=%s",
|
||||
fcni->addr, fcni->size, fcni->name);
|
||||
|
||||
r_cons_printf (" diff=");
|
||||
if ((fcni->diff == R_ANAL_DIFF_MATCH))
|
||||
r_cons_printf ("match");
|
||||
else if ((fcni->diff == R_ANAL_DIFF_UNMATCH))
|
||||
r_cons_printf ("unmatch");
|
||||
else r_cons_printf ("new");
|
||||
r_cons_printf ("\n");
|
||||
|
||||
r_cons_printf (" diff=%s", fcni->diff=='m'?"match": fcni->diff=='u'?"unmatch": "new");
|
||||
r_cons_printf ("\n refs: ");
|
||||
r_list_foreach (fcni->refs, iter2, refi) {
|
||||
r_cons_printf ("0x%08"PFMT64x"(%c) ", refi->addr, refi->type);
|
||||
|
@ -3,4 +3,7 @@ include ../../config.mk
|
||||
all:
|
||||
@# do nothing here
|
||||
|
||||
clean:
|
||||
@# do nothing here
|
||||
|
||||
include ../../rules.mk
|
||||
|
@ -68,8 +68,8 @@ enum {
|
||||
|
||||
enum {
|
||||
R_ANAL_DIFF_NULL = 0,
|
||||
R_ANAL_DIFF_MATCH,
|
||||
R_ANAL_DIFF_UNMATCH,
|
||||
R_ANAL_DIFF_MATCH = 'm',
|
||||
R_ANAL_DIFF_UNMATCH = 'u'
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -150,6 +150,39 @@ typedef struct r_anal_aop_t {
|
||||
int refptr;
|
||||
} RAnalOp;
|
||||
|
||||
// value+regbase+regidx+delta
|
||||
typedef struct r_anal_value_t {
|
||||
int memref; // is memory reference? or value?
|
||||
ut64 base ; // numeric address
|
||||
int delta; // numeric delta
|
||||
int regbase; // register index used (-1 if no reg)
|
||||
int regdelta; // register index used (-1 if no reg)
|
||||
} RAnalValue;
|
||||
|
||||
enum {
|
||||
R_ANAL_COND_TYPE_Z = 0, //'z', // only 'src' used
|
||||
R_ANAL_COND_TYPE_E = 1,
|
||||
R_ANAL_COND_TYPE_G = 2,
|
||||
R_ANAL_COND_TYPE_GE = 1|2,
|
||||
};
|
||||
|
||||
// 80f92f cmp cl, 0x2f
|
||||
// 7543 jnz 0xb78b2dc0
|
||||
// cmp byte [ecx+eax-0x1], 0x2f
|
||||
// RAnalCond = {
|
||||
// .type = R_ANAL_COND_TYPE_Z,
|
||||
// .negate = 1,
|
||||
// .src = {
|
||||
|
||||
typedef struct r_anal_cond_t {
|
||||
// filled by CJMP opcode
|
||||
int type;
|
||||
int negate;
|
||||
// filled by 'cmp' opcode
|
||||
RAnalValue src;
|
||||
RAnalValue dst;
|
||||
} RAnalCond;
|
||||
|
||||
typedef struct r_anal_bb_t {
|
||||
ut64 addr;
|
||||
ut64 size;
|
||||
|
@ -1,6 +1,7 @@
|
||||
OBJ=hello.o
|
||||
BIN=hello
|
||||
BINDEPS=r_cons r_line r_util
|
||||
|
||||
#LIBS=../*.o -L../../cons -Wl,-R../../cons -lr_cons \
|
||||
# ../../util/*.a
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user