mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 07:30:33 +00:00
* r_anal
- Initial work in var analysis - Move r_var into r_anal * r_var - Removed --HG-- rename : libr/var/var.c => libr/anal/var.c
This commit is contained in:
parent
ca66fe440d
commit
d05b0fedf4
@ -6,7 +6,7 @@ PFX=${DESTDIR}${PREFIX}
|
||||
#PREFIX=${PFX}
|
||||
|
||||
# Libraries
|
||||
LIBLIST=util lib io meta lang flags bin macro hash line cons print config syscall socket cmd asm anal parse search diff bp reg debug core var sign trace vm th db
|
||||
LIBLIST=util lib io meta lang flags bin macro hash line cons print config syscall socket cmd asm anal parse search diff bp reg debug core sign trace vm th db
|
||||
|
||||
# Under development
|
||||
#LIBLIST+=print
|
||||
|
@ -8,7 +8,7 @@ foo: pre libr_anal.${EXT_SO} libr_anal.${EXT_AR} plugins
|
||||
|
||||
include ${STATIC_ANAL_PLUGINS}
|
||||
STATIC_OBJS=$(subst ..,p/..,$(subst anal_,p/anal_,$(STATIC_OBJ)))
|
||||
OBJ=${STATIC_OBJS} ctx.o reflines.o anal.o
|
||||
OBJ=${STATIC_OBJS} ctx.o reflines.o var.o anal.o
|
||||
|
||||
pre:
|
||||
if [ ! -e libr_anal.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* radare - LGPL - Copyright 2008-2009 pancake<nopcode.org> */
|
||||
|
||||
#include "r_var.h"
|
||||
#include "r_anal.h"
|
||||
#if 0
|
||||
#include "r_cons.h"
|
||||
|
||||
R_API struct r_var_t *r_var_new()
|
||||
@ -297,3 +298,4 @@ R_API int r_var_anal_get(struct r_var_t *var, int type)
|
||||
}
|
||||
return ctr;
|
||||
}
|
||||
#endif
|
@ -5,7 +5,7 @@
|
||||
#include <r_flags.h>
|
||||
#include <r_core.h>
|
||||
|
||||
static char *r_core_anal_graph_label (struct r_core_t *core, ut64 addr, ut64 size) {
|
||||
static char *r_core_anal_graph_label(struct r_core_t *core, ut64 addr, ut64 size) {
|
||||
char cmd[1024], *cmdstr = NULL, *str = NULL;
|
||||
int i, j;
|
||||
|
||||
@ -35,7 +35,7 @@ static char *r_core_anal_graph_label (struct r_core_t *core, ut64 addr, ut64 siz
|
||||
return str;
|
||||
}
|
||||
|
||||
static void r_core_anal_graph_nodes (struct r_core_t *core, RList *pbb, ut64 addr) {
|
||||
static void r_core_anal_graph_nodes(struct r_core_t *core, RList *pbb, ut64 addr) {
|
||||
struct r_anal_bb_t *bbi, *bbc;
|
||||
RListIter *iter;
|
||||
char *str;
|
||||
@ -75,7 +75,7 @@ static void r_core_anal_graph_nodes (struct r_core_t *core, RList *pbb, ut64 add
|
||||
}
|
||||
}
|
||||
|
||||
R_API int r_core_anal_bb (struct r_core_t *core, ut64 at, int depth) {
|
||||
R_API int r_core_anal_bb(struct r_core_t *core, ut64 at, int depth) {
|
||||
struct r_anal_bb_t *bb;
|
||||
ut64 jump, fail;
|
||||
ut8 *buf;
|
||||
@ -116,7 +116,7 @@ R_API int r_core_anal_bb (struct r_core_t *core, ut64 at, int depth) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_bb_clean (struct r_core_t *core, ut64 addr) {
|
||||
R_API int r_core_anal_bb_clean(struct r_core_t *core, ut64 addr) {
|
||||
struct r_anal_bb_t *bbi;
|
||||
RListIter *iter;
|
||||
ut64 jump, fail;
|
||||
@ -141,7 +141,7 @@ R_API int r_core_anal_bb_clean (struct r_core_t *core, ut64 addr) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_bb_add (struct r_core_t *core, ut64 addr, ut64 size, ut64 jump, ut64 fail) {
|
||||
R_API int r_core_anal_bb_add(struct r_core_t *core, ut64 addr, ut64 size, ut64 jump, ut64 fail) {
|
||||
struct r_anal_bb_t *bb, *bbi;
|
||||
RListIter *iter;
|
||||
|
||||
@ -158,7 +158,7 @@ R_API int r_core_anal_bb_add (struct r_core_t *core, ut64 addr, ut64 size, ut64
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_bb_list (struct r_core_t *core, int rad) {
|
||||
R_API int r_core_anal_bb_list(struct r_core_t *core, int rad) {
|
||||
struct r_anal_bb_t *bbi;
|
||||
RListIter *iter;
|
||||
|
||||
@ -183,7 +183,7 @@ R_API int r_core_anal_bb_list (struct r_core_t *core, int rad) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_bb_seek (struct r_core_t *core, ut64 addr) {
|
||||
R_API int r_core_anal_bb_seek(struct r_core_t *core, ut64 addr) {
|
||||
struct r_anal_bb_t *bbi;
|
||||
RListIter *iter;
|
||||
|
||||
@ -193,7 +193,7 @@ R_API int r_core_anal_bb_seek (struct r_core_t *core, ut64 addr) {
|
||||
return r_core_seek (core, addr, R_FALSE);
|
||||
}
|
||||
|
||||
R_API int r_core_anal_fcn (struct r_core_t *core, ut64 at, ut64 from, int depth) {
|
||||
R_API int r_core_anal_fcn(struct r_core_t *core, ut64 at, ut64 from, int depth) {
|
||||
struct r_anal_fcn_t *fcn, *fcni;
|
||||
struct r_anal_ref_t *refi;
|
||||
RListIter *iter, *iter2;
|
||||
@ -237,6 +237,7 @@ R_API int r_core_anal_fcn (struct r_core_t *core, ut64 at, ut64 from, int depth)
|
||||
fcn->name = r_str_dup_printf ("fcn_%08llx", at);
|
||||
/* Add flag */
|
||||
flagname = r_str_dup_printf ("fcn.%s", fcn->name);
|
||||
r_flag_space_set (&core->flags, "functions");
|
||||
r_flag_set (&core->flags, flagname, at, fcn->size, 0);
|
||||
free (flagname);
|
||||
r_list_append (core->anal.fcns, fcn);
|
||||
@ -251,7 +252,7 @@ R_API int r_core_anal_fcn (struct r_core_t *core, ut64 at, ut64 from, int depth)
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_fcn_clean (struct r_core_t *core, ut64 addr) {
|
||||
R_API int r_core_anal_fcn_clean(struct r_core_t *core, ut64 addr) {
|
||||
struct r_anal_fcn_t *fcni;
|
||||
RListIter *iter;
|
||||
|
||||
@ -265,7 +266,7 @@ R_API int r_core_anal_fcn_clean (struct r_core_t *core, ut64 addr) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_fcn_add (struct r_core_t *core, ut64 addr, ut64 size, const char *name) {
|
||||
R_API int r_core_anal_fcn_add(struct r_core_t *core, ut64 addr, ut64 size, const char *name) {
|
||||
struct r_anal_fcn_t *fcn, *fcni;
|
||||
RListIter *iter;
|
||||
|
||||
@ -281,7 +282,7 @@ R_API int r_core_anal_fcn_add (struct r_core_t *core, ut64 addr, ut64 size, cons
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_fcn_list (struct r_core_t *core, int rad) {
|
||||
R_API int r_core_anal_fcn_list(struct r_core_t *core, int rad) {
|
||||
struct r_anal_fcn_t *fcni;
|
||||
struct r_anal_ref_t *refi;
|
||||
RListIter *iter, *iter2;
|
||||
@ -310,7 +311,7 @@ R_API int r_core_anal_fcn_list (struct r_core_t *core, int rad) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_graph (struct r_core_t *core, ut64 addr) {
|
||||
R_API int r_core_anal_graph(struct r_core_t *core, ut64 addr) {
|
||||
RList *pbb = NULL;
|
||||
int reflines = r_config_get_i(&core->config, "asm.reflines");
|
||||
int bytes = r_config_get_i(&core->config, "asm.bytes");
|
||||
@ -331,7 +332,7 @@ R_API int r_core_anal_graph (struct r_core_t *core, ut64 addr) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_graph_fcn (struct r_core_t *core, char *fname) {
|
||||
R_API int r_core_anal_graph_fcn(struct r_core_t *core, char *fname) {
|
||||
struct r_anal_fcn_t *fcni;
|
||||
RListIter *iter;
|
||||
|
||||
|
@ -57,7 +57,7 @@ enum {
|
||||
|
||||
/* TODO: what to do with signed/unsigned conditionals? */
|
||||
enum {
|
||||
R_ANAL_OP_COND_EQ,
|
||||
R_ANAL_OP_COND_EQ = 0,
|
||||
R_ANAL_OP_COND_NE,
|
||||
R_ANAL_OP_COND_GE,
|
||||
R_ANAL_OP_COND_GT,
|
||||
@ -65,6 +65,14 @@ enum {
|
||||
R_ANAL_OP_COND_LT,
|
||||
};
|
||||
|
||||
enum {
|
||||
R_ANAL_VAR_TYPE_NULL = 0,
|
||||
R_ANAL_VAR_TYPE_GLOBAL,
|
||||
R_ANAL_VAR_TYPE_LOCAL,
|
||||
R_ANAL_VAR_TYPE_ARG,
|
||||
R_ANAL_VAR_TYPE_ARGREG,
|
||||
};
|
||||
|
||||
enum {
|
||||
R_ANAL_DATA_NULL = 0,
|
||||
R_ANAL_DATA_HEX, /* hex byte pairs */
|
||||
@ -149,12 +157,46 @@ typedef struct r_anal_fcn_t {
|
||||
RList *xrefs;
|
||||
} RAnalysisFcn;
|
||||
|
||||
typedef ut64 RAnalysisRef;
|
||||
|
||||
typedef struct r_anal_var_t {
|
||||
char *name;
|
||||
ut64 addr;
|
||||
int type;
|
||||
} RAnalysisVar;
|
||||
|
||||
typedef ut64 RAnalysisRef;
|
||||
#if 0
|
||||
typedef struct r_var_anal_t {
|
||||
int type;
|
||||
int delta;
|
||||
int count;
|
||||
} RVariableAnalysis;
|
||||
|
||||
typedef struct r_var_type_t {
|
||||
char name[128];
|
||||
char fmt[128];
|
||||
unsigned int size;
|
||||
struct list_head list;
|
||||
} RVariableType;
|
||||
|
||||
typedef struct r_var_access_t {
|
||||
ut64 addr;
|
||||
int set;
|
||||
struct list_head list;
|
||||
} RVariableAccess;
|
||||
|
||||
typedef struct r_var_item_t {
|
||||
int type; /* global, local... */
|
||||
ut64 addr; /* address where it is used */
|
||||
ut64 eaddr; /* address where it is used */
|
||||
int delta; /* */
|
||||
int arraysize; /* size of array var in bytes , 0 is no-array */
|
||||
char name[128];
|
||||
char vartype[128];
|
||||
struct list_head access; /* list of accesses for this var */
|
||||
struct list_head list;
|
||||
} RVariableItem;
|
||||
#endif
|
||||
|
||||
typedef struct r_anal_refline_t {
|
||||
ut64 from;
|
||||
@ -211,6 +253,26 @@ R_API int r_anal_aop(RAnalysis *anal, RAnalysisAop *aop, ut64 addr,
|
||||
R_API int r_anal_bb(struct r_anal_t *anal, struct r_anal_bb_t *bb,
|
||||
ut64 addr, ut8 *buf, ut64 len);
|
||||
|
||||
#if 0
|
||||
/* var.c */
|
||||
R_API struct r_var_t *r_var_new();
|
||||
R_API void r_var_free(struct r_var_t *var);
|
||||
R_API int r_var_init(struct r_var_t *var);
|
||||
R_API int r_var_type_add(struct r_var_t *var, const char *typename, int size, const char *fmt);
|
||||
R_API int r_var_type_del(struct r_var_t *var, const char *typename);
|
||||
R_API int r_var_type_list(struct r_var_t *var);
|
||||
R_API struct r_var_type_t *r_var_type_get(struct r_var_t *var, const char *datatype);
|
||||
R_API const char *r_var_type_to_string(int type);
|
||||
|
||||
R_API void r_var_item_print(struct r_var_t *var, struct r_var_item_t * v);
|
||||
R_API int r_var_list_show(struct r_var_t *var, ut64 addr);
|
||||
R_API int r_var_list(struct r_var_t *var, ut64 addr, int delta);
|
||||
|
||||
R_API int r_var_anal_get(struct r_var_t *var, int type);
|
||||
R_API void r_var_anal_reset(struct r_var_t *var);
|
||||
R_API int r_var_anal_add(struct r_var_t *var, int type, int delta);
|
||||
#endif
|
||||
|
||||
/* reflines.c */
|
||||
R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal,
|
||||
ut64 addr, ut8 *buf, ut64 len, int nlines, int linesout);
|
||||
|
@ -109,17 +109,17 @@ R_API char *r_core_cmd_str(struct r_core_t *core, const char *cmd);
|
||||
R_API int r_core_cmd_foreach(struct r_core_t *core, const char *cmd, char *each);
|
||||
|
||||
/* anal.c */
|
||||
R_API int r_core_anal_bb (struct r_core_t *core, ut64 at, int depth);
|
||||
R_API int r_core_anal_bb_clean (struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_bb_add (struct r_core_t *core, ut64 addr, ut64 size, ut64 jump, ut64 fail);
|
||||
R_API int r_core_anal_bb_list (struct r_core_t *core, int rad);
|
||||
R_API int r_core_anal_bb_seek (struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_fcn (struct r_core_t *core, ut64 at, ut64 from, int depth);
|
||||
R_API int r_core_anal_fcn_add (struct r_core_t *core, ut64 addr, ut64 size, const char *name);
|
||||
R_API int r_core_anal_fcn_list (struct r_core_t *core, int rad);
|
||||
R_API int r_core_anal_fcn_clean (struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_graph (struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_graph_fcn (struct r_core_t *core, char *input);
|
||||
R_API int r_core_anal_bb(struct r_core_t *core, ut64 at, int depth);
|
||||
R_API int r_core_anal_bb_clean(struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_bb_add(struct r_core_t *core, ut64 addr, ut64 size, ut64 jump, ut64 fail);
|
||||
R_API int r_core_anal_bb_list(struct r_core_t *core, int rad);
|
||||
R_API int r_core_anal_bb_seek(struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_fcn(struct r_core_t *core, ut64 at, ut64 from, int depth);
|
||||
R_API int r_core_anal_fcn_add(struct r_core_t *core, ut64 addr, ut64 size, const char *name);
|
||||
R_API int r_core_anal_fcn_list(struct r_core_t *core, int rad);
|
||||
R_API int r_core_anal_fcn_clean(struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_graph(struct r_core_t *core, ut64 addr);
|
||||
R_API int r_core_anal_graph_fcn(struct r_core_t *core, char *input);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,77 +0,0 @@
|
||||
#ifndef _INCLUDE_R_VAR_H_
|
||||
#define _INCLUDE_R_VAR_H_
|
||||
|
||||
#include "r_types.h"
|
||||
#include "list.h"
|
||||
|
||||
#define R_VAR_ANAL_MAX 256
|
||||
|
||||
enum {
|
||||
R_VAR_TYPE_NONE = 0,
|
||||
R_VAR_TYPE_GLOBAL,
|
||||
R_VAR_TYPE_LOCAL,
|
||||
R_VAR_TYPE_ARG,
|
||||
R_VAR_TYPE_ARGREG
|
||||
};
|
||||
|
||||
typedef struct r_var_anal_t {
|
||||
int type;
|
||||
int delta;
|
||||
int count;
|
||||
} RVariableAnalysis;
|
||||
|
||||
typedef struct r_var_type_t {
|
||||
char name[128];
|
||||
char fmt[128];
|
||||
unsigned int size;
|
||||
struct list_head list;
|
||||
} RVariableType;
|
||||
|
||||
typedef struct r_var_t {
|
||||
int anal_size;
|
||||
struct r_var_anal_t anal[R_VAR_ANAL_MAX];
|
||||
struct list_head vartypes;
|
||||
struct list_head vars;
|
||||
} RVariable;
|
||||
|
||||
typedef struct r_var_access_t {
|
||||
ut64 addr;
|
||||
int set;
|
||||
struct list_head list;
|
||||
} RVariableAccess;
|
||||
|
||||
typedef struct r_var_item_t {
|
||||
int type; /* global, local... */
|
||||
ut64 addr; /* address where it is used */
|
||||
ut64 eaddr; /* address where it is used */
|
||||
int delta; /* */
|
||||
int arraysize; /* size of array var in bytes , 0 is no-array */
|
||||
char name[128];
|
||||
char vartype[128];
|
||||
struct list_head access; /* list of accesses for this var */
|
||||
struct list_head list;
|
||||
} RVariableItem;
|
||||
|
||||
#ifdef R_API
|
||||
/* api */
|
||||
R_API struct r_var_t *r_var_new();
|
||||
R_API void r_var_free(struct r_var_t *var);
|
||||
R_API int r_var_init(struct r_var_t *var);
|
||||
R_API int r_var_type_add(struct r_var_t *var, const char *typename, int size, const char *fmt);
|
||||
R_API int r_var_type_del(struct r_var_t *var, const char *typename);
|
||||
R_API int r_var_type_list(struct r_var_t *var);
|
||||
R_API struct r_var_type_t *r_var_type_get(struct r_var_t *var, const char *datatype);
|
||||
R_API const char *r_var_type_to_string(int type);
|
||||
|
||||
/* food */
|
||||
R_API void r_var_item_print(struct r_var_t *var, struct r_var_item_t * v);
|
||||
R_API int r_var_list_show(struct r_var_t *var, ut64 addr);
|
||||
R_API int r_var_list(struct r_var_t *var, ut64 addr, int delta);
|
||||
|
||||
/* analyze */
|
||||
R_API int r_var_anal_get(struct r_var_t *var, int type);
|
||||
R_API void r_var_anal_reset(struct r_var_t *var);
|
||||
R_API int r_var_anal_add(struct r_var_t *var, int type, int delta);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
NAME=r_var
|
||||
OBJ=var.o
|
||||
DEPS=r_util r_cons
|
||||
|
||||
include ../rules.mk
|
@ -1,12 +0,0 @@
|
||||
|
||||
API for accessing and analyzing variables
|
||||
=========================================
|
||||
|
||||
Describes variable types:
|
||||
|
||||
int, float, byte, char, ...
|
||||
size of array of elements (optional)
|
||||
local/global
|
||||
...
|
||||
|
||||
This API has been stolen from the r1 API.
|
Loading…
Reference in New Issue
Block a user