mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 15:41:38 +00:00
* r_parse & r_core
- Rename asm.symsreplace to asm.filter * r_core - Add command 'aga' to output address-graphs * build - Strip binary rpath before install
This commit is contained in:
parent
e8ba45c6b0
commit
21868d3b6c
@ -66,7 +66,10 @@ install-bins:
|
||||
# programs
|
||||
@${INSTALL_DIR} ${PFX}/bin
|
||||
@for a in `find */t -perm -u+x -type f | grep 2`; \
|
||||
do echo "$$a ${PFX}/bin"; ${INSTALL_PROGRAM} $$a ${PFX}/bin ; done
|
||||
do echo "$$a ${PFX}/bin"; \
|
||||
./bin/t/rpathdel $$a $$a ; \
|
||||
${INSTALL_PROGRAM} $$a ${PFX}/bin ; \
|
||||
done
|
||||
# shortcut
|
||||
-cd ${PFX}/bin && rm -f r2 ; ln -fs radare2 r2
|
||||
|
||||
|
@ -20,10 +20,8 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!r_bin_wr_rpath_del (bin)) {
|
||||
fprintf (stderr, "Error: Cannot remove rpath\n");
|
||||
if (!r_bin_wr_rpath_del (bin))
|
||||
return 1;
|
||||
}
|
||||
r_bin_wr_output (bin, output);
|
||||
|
||||
r_bin_free (bin);
|
||||
|
@ -5,13 +5,13 @@
|
||||
#include <r_flags.h>
|
||||
#include <r_core.h>
|
||||
|
||||
static char *r_core_anal_graph_label(struct r_core_t *core, struct r_anal_bb_t *bb, int lines) {
|
||||
static char *r_core_anal_graph_label(struct r_core_t *core, struct r_anal_bb_t *bb, int opts) {
|
||||
struct r_anal_aop_t *aopi;
|
||||
RListIter *iter;
|
||||
char cmd[1024], file[1024], *cmdstr = NULL, *filestr = NULL, *str = NULL;
|
||||
int i, j, line = 0, oline = 0, idx = 0;
|
||||
|
||||
if (lines) {
|
||||
if (opts == R_CORE_ANAL_GRAPHLINES) {
|
||||
r_list_foreach (bb->aops, iter, aopi) {
|
||||
r_bin_meta_get_line (&core->bin, aopi->addr, file, 1023, &line);
|
||||
if (line != 0 && line != oline && strcmp (file, "??")) {
|
||||
@ -27,7 +27,7 @@ static char *r_core_anal_graph_label(struct r_core_t *core, struct r_anal_bb_t *
|
||||
}
|
||||
oline = line;
|
||||
}
|
||||
} else {
|
||||
} else if (opts == R_CORE_ANAL_GRAPHBODY) {
|
||||
snprintf (cmd, 1023, "pD %lli @ 0x%08llx", bb->size, bb->addr);
|
||||
cmdstr = r_core_cmd_str(core, cmd);
|
||||
}
|
||||
@ -60,7 +60,7 @@ static char *r_core_anal_graph_label(struct r_core_t *core, struct r_anal_bb_t *
|
||||
return str;
|
||||
}
|
||||
|
||||
static void r_core_anal_graph_nodes(struct r_core_t *core, RList *pbb, ut64 addr, int lines) {
|
||||
static void r_core_anal_graph_nodes(struct r_core_t *core, RList *pbb, ut64 addr, int opts) {
|
||||
struct r_anal_bb_t *bbi, *bbc;
|
||||
RListIter *iter;
|
||||
char *str;
|
||||
@ -84,14 +84,14 @@ static void r_core_anal_graph_nodes(struct r_core_t *core, RList *pbb, ut64 addr
|
||||
r_cons_printf ("\t\"0x%08llx\" -> \"0x%08llx\" [color=\"%s\"];\n", bbi->addr, bbi->jump,
|
||||
bbi->fail != -1 ? "green" : "blue");
|
||||
r_cons_flush ();
|
||||
if (addr != 0) r_core_anal_graph_nodes (core, pbb, bbi->jump, lines);
|
||||
if (addr != 0) r_core_anal_graph_nodes (core, pbb, bbi->jump, opts);
|
||||
}
|
||||
if (bbi->fail != -1) {
|
||||
r_cons_printf ("\t\"0x%08llx\" -> \"0x%08llx\" [color=\"red\"];\n", bbi->addr, bbi->fail);
|
||||
r_cons_flush ();
|
||||
if (addr != 0) r_core_anal_graph_nodes (core, pbb, bbi->fail, lines);
|
||||
if (addr != 0) r_core_anal_graph_nodes (core, pbb, bbi->fail, opts);
|
||||
}
|
||||
if ((str = r_core_anal_graph_label (core, bbi, lines))) {
|
||||
if ((str = r_core_anal_graph_label (core, bbi, opts))) {
|
||||
r_cons_printf (" \"0x%08llx\" [label=\"%s\"]\n", bbi->addr, str);
|
||||
r_cons_flush ();
|
||||
free(str);
|
||||
@ -343,33 +343,36 @@ 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, int lines) {
|
||||
R_API int r_core_anal_graph(struct r_core_t *core, ut64 addr, int opts) {
|
||||
RList *pbb = NULL;
|
||||
int reflines = r_config_get_i(&core->config, "asm.lines");
|
||||
int bytes = r_config_get_i(&core->config, "asm.bytes");
|
||||
int dwarf = r_config_get_i(&core->config, "asm.dwarf");
|
||||
|
||||
r_config_set_i(&core->config, "asm.lines", 0);
|
||||
r_config_set_i(&core->config, "asm.bytes", 0);
|
||||
r_config_set_i(&core->config, "asm.dwarf", 0);
|
||||
r_cons_printf ("digraph code {\n");
|
||||
r_cons_printf ("\tgraph [bgcolor=white];\n");
|
||||
r_cons_printf ("\tnode [color=lightgray, style=filled shape=box fontname=\"Courier\" fontsize=\"8\"];\n");
|
||||
r_cons_flush ();
|
||||
if (addr != 0) pbb = r_anal_bb_list_new (); /* In partial graphs define printed bb list */
|
||||
r_core_anal_graph_nodes (core, pbb, addr, lines);
|
||||
r_core_anal_graph_nodes (core, pbb, addr, opts);
|
||||
if (pbb) r_list_destroy (pbb);
|
||||
r_cons_printf ("}\n");
|
||||
r_cons_flush ();
|
||||
r_config_set_i(&core->config, "asm.lines", reflines);
|
||||
r_config_set_i(&core->config, "asm.bytes", bytes);
|
||||
r_config_set_i(&core->config, "asm.dwarf", dwarf);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_anal_graph_fcn(struct r_core_t *core, char *fname, int lines) {
|
||||
R_API int r_core_anal_graph_fcn(struct r_core_t *core, char *fname, int opts) {
|
||||
struct r_anal_fcn_t *fcni;
|
||||
RListIter *iter;
|
||||
|
||||
r_list_foreach (core->anal.fcns, iter, fcni)
|
||||
if (!strcmp (fname, fcni->name))
|
||||
return r_core_anal_graph (core, fcni->addr, lines);
|
||||
return r_core_anal_graph (core, fcni->addr, opts);
|
||||
return R_FALSE;
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
int linesout = r_config_get_i (&core->config, "asm.linesout");
|
||||
int show_comments = r_config_get_i (&core->config, "asm.comments");
|
||||
int pseudo = r_config_get_i (&core->config, "asm.pseudo");
|
||||
int symreplace = r_config_get_i (&core->config, "asm.symreplace");
|
||||
int filter = r_config_get_i (&core->config, "asm.filter");
|
||||
int linesopts = 0;
|
||||
|
||||
if (r_config_get_i (&core->config, "asm.linesstyle"))
|
||||
@ -824,8 +824,8 @@ static int cmd_print(void *data, const char *input) {
|
||||
if (pseudo) {
|
||||
r_parse_parse (&core->parser, asmop.buf_asm, str);
|
||||
opstr = str;
|
||||
} else if (symreplace) {
|
||||
r_parse_symreplace (&core->parser, &core->flags, asmop.buf_asm, str);
|
||||
} else if (filter) {
|
||||
r_parse_filter (&core->parser, &core->flags, asmop.buf_asm, str);
|
||||
opstr = str;
|
||||
} else opstr = asmop.buf_asm;
|
||||
r_cons_strcat (opstr);
|
||||
@ -1161,7 +1161,7 @@ static int cmd_anal(void *data, const char *input) {
|
||||
case 'g':
|
||||
switch (input[1]) {
|
||||
case 'l':
|
||||
r_core_anal_graph (core, r_num_math (&core->num, input+2), R_TRUE);
|
||||
r_core_anal_graph (core, r_num_math (&core->num, input+2), R_CORE_ANAL_GRAPHLINES);
|
||||
break;
|
||||
case 'f':
|
||||
{
|
||||
@ -1170,16 +1170,20 @@ static int cmd_anal(void *data, const char *input) {
|
||||
free (fname);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
r_core_anal_graph (core, r_num_math (&core->num, input+2), 0);
|
||||
break;
|
||||
case '?':
|
||||
r_cons_printf (
|
||||
"Usage: ag[?f]\n"
|
||||
" ag [addr] ; Output graphviz code (bb at addr and childs)\n"
|
||||
" aga [addr] ; Idem, but only addresses\n"
|
||||
" agl [fcn name] ; Output graphviz code using meta-data\n"
|
||||
" agf [fcn name] ; Output graphviz code of function\n"
|
||||
" agfl [fcn name] ; Output graphviz code of function using meta-data\n");
|
||||
break;
|
||||
default:
|
||||
r_core_anal_graph (core, r_num_math (&core->num, input+2), R_FALSE);
|
||||
r_core_anal_graph (core, r_num_math (&core->num, input+2), R_CORE_ANAL_GRAPHBODY);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
|
@ -137,7 +137,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
&config_asm_bits_callback);
|
||||
r_config_set_i (cfg, "asm.nbytes", 8);
|
||||
r_config_set (cfg, "asm.pseudo", "false"); // DEPRECATED ???
|
||||
r_config_set (cfg, "asm.symreplace", "false");
|
||||
r_config_set (cfg, "asm.filter", "true");
|
||||
r_config_set (cfg, "asm.bytes", "true");
|
||||
r_config_set (cfg, "asm.offset", "true");
|
||||
r_config_set (cfg, "asm.lines", "true");
|
||||
|
@ -23,6 +23,9 @@
|
||||
#define R_CORE_BLOCKSIZE 64
|
||||
#define R_CORE_BLOCKSIZE_MAX 0x40000 /* 4 MB */
|
||||
|
||||
#define R_CORE_ANAL_GRAPHLINES 0x1
|
||||
#define R_CORE_ANAL_GRAPHBODY 0x2
|
||||
|
||||
typedef struct r_core_file_t {
|
||||
char *uri;
|
||||
char *filename;
|
||||
|
@ -23,7 +23,7 @@ typedef struct r_parse_handle_t {
|
||||
int (*fini)(void *user);
|
||||
int (*parse)(struct r_parse_t *p, void *data, char *str);
|
||||
int (*assemble)(struct r_parse_t *p, char *data, char *str);
|
||||
int (*symreplace)(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str);
|
||||
int (*filter)(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str);
|
||||
struct list_head list;
|
||||
} RParseHandle;
|
||||
|
||||
@ -37,7 +37,7 @@ R_API int r_parse_list(struct r_parse_t *p);
|
||||
R_API int r_parse_use(struct r_parse_t *p, const char *name);
|
||||
R_API int r_parse_parse(struct r_parse_t *p, void *data, char *str);
|
||||
R_API int r_parse_assemble(struct r_parse_t *p, char *data, char *str);
|
||||
R_API int r_parse_symreplace(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str);
|
||||
R_API int r_parse_filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str);
|
||||
|
||||
/* plugin pointers */
|
||||
extern struct r_parse_handle_t r_parse_plugin_dummy;
|
||||
|
@ -18,6 +18,8 @@ struct r_parse_handle_t r_parse_plugin_dummy = {
|
||||
.init = NULL,
|
||||
.fini = NULL,
|
||||
.parse = &parse,
|
||||
.assemble = NULL,
|
||||
.filter = NULL
|
||||
};
|
||||
|
||||
#ifndef CORELIB
|
||||
|
@ -33,6 +33,8 @@ struct r_parse_handle_t r_parse_plugin_mreplace = {
|
||||
.init = NULL,
|
||||
.fini = NULL,
|
||||
.parse = &parse,
|
||||
.assemble = NULL,
|
||||
.filter = NULL
|
||||
};
|
||||
|
||||
#else
|
||||
|
@ -137,7 +137,7 @@ static int assemble(struct r_parse_t *p, void *data, char *str)
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int symreplace(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str)
|
||||
static int filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str)
|
||||
{
|
||||
struct list_head *pos;
|
||||
char *ptr;
|
||||
@ -164,7 +164,7 @@ struct r_parse_handle_t r_parse_plugin_x86_pseudo = {
|
||||
.fini = NULL,
|
||||
.parse = &parse,
|
||||
.assemble = &assemble,
|
||||
.symreplace = &symreplace,
|
||||
.filter = &filter,
|
||||
};
|
||||
|
||||
struct r_lib_struct_t radare_plugin = {
|
||||
|
@ -88,9 +88,9 @@ R_API int r_parse_assemble(struct r_parse_t *p, char *data, char *str) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_parse_symreplace(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str) {
|
||||
if (p->cur && p->cur->symreplace)
|
||||
return p->cur->symreplace(p, f, data, str);
|
||||
R_API int r_parse_filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str) {
|
||||
if (p->cur && p->cur->filter)
|
||||
return p->cur->filter(p, f, data, str);
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user