mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 07:30:33 +00:00
Better r_str_hash(), Fixes in CCa, Added ?h, Better rbin for BEOS bins
Identify Haiku binaries as 'beos' with noodle() Fix CCa for non numeric offsets Use sdb's r_str_hash() instead of old one (much less collisions) Added ?h command to hash strings CCa now appends instead of replacing comments Do not mark as static if bin links to libs
This commit is contained in:
parent
c9eb90adbc
commit
3f1d3ba146
@ -388,6 +388,8 @@ R_API int r_bin_is_stripped (RBin *bin) {
|
||||
}
|
||||
|
||||
R_API int r_bin_is_static (RBin *bin) {
|
||||
if (r_list_length (bin->cur.o->libs)>0)
|
||||
return R_FALSE;
|
||||
return R_BIN_DBG_STATIC (bin->cur.o->info->dbg_info);
|
||||
}
|
||||
|
||||
|
@ -558,6 +558,13 @@ int Elf_(r_bin_elf_get_bits)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline int noodle(struct Elf_(r_bin_elf_obj_t) *bin, const char *s) {
|
||||
const ut8 *p = bin->b->buf;
|
||||
if (bin->b->length>64) {
|
||||
p += bin->b->length-64;
|
||||
} else return 0;
|
||||
return r_mem_mem (p, 64, (const ut8 *)s, strlen (s)) != NULL;
|
||||
}
|
||||
static inline int needle(struct Elf_(r_bin_elf_obj_t) *bin, const char *s) {
|
||||
if (bin->shstrtab) {
|
||||
int len = bin->shstrtab_size;
|
||||
@ -574,6 +581,7 @@ char* Elf_(r_bin_elf_get_osabi_name)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
if (needle (bin, "openbsd")) return strdup ("openbsd");
|
||||
if (needle (bin, "netbsd")) return strdup ("netbsd");
|
||||
if (needle (bin, "freebsd")) return strdup ("freebsd");
|
||||
if (noodle (bin, "BEOS:APP_VERSION")) return strdup ("beos");
|
||||
if (needle (bin, "GNU")) return strdup ("linux");
|
||||
return strdup ("linux");
|
||||
#if 0
|
||||
|
@ -77,7 +77,7 @@ struct Elf_(r_bin_elf_obj_t) {
|
||||
ut64 baddr;
|
||||
int endian;
|
||||
const char* file;
|
||||
struct r_buf_t* b;
|
||||
RBuffer *b;
|
||||
};
|
||||
|
||||
int Elf_(r_bin_elf_has_va)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||
|
@ -222,28 +222,28 @@ static RBinInfo* info(RBinArch *arch) {
|
||||
strncpy (ret->rpath, str, R_BIN_SIZEOF_STRINGS);
|
||||
free (str);
|
||||
} else strncpy (ret->rpath, "NONE", R_BIN_SIZEOF_STRINGS);
|
||||
if ((str = Elf_(r_bin_elf_get_file_type) (arch->bin_obj)) == NULL)
|
||||
if (!(str = Elf_(r_bin_elf_get_file_type) (arch->bin_obj)))
|
||||
return NULL;
|
||||
strncpy (ret->type, str, R_BIN_SIZEOF_STRINGS);
|
||||
ret->has_pi = (strstr (str, "DYN"))? 1: 0;
|
||||
free (str);
|
||||
if ((str = Elf_(r_bin_elf_get_elf_class) (arch->bin_obj)) == NULL)
|
||||
if (!(str = Elf_(r_bin_elf_get_elf_class) (arch->bin_obj)))
|
||||
return NULL;
|
||||
strncpy (ret->bclass, str, R_BIN_SIZEOF_STRINGS);
|
||||
free (str);
|
||||
if ((str = Elf_(r_bin_elf_get_osabi_name) (arch->bin_obj)) == NULL)
|
||||
if (!(str = Elf_(r_bin_elf_get_osabi_name) (arch->bin_obj)))
|
||||
return NULL;
|
||||
strncpy (ret->os, str, R_BIN_SIZEOF_STRINGS);
|
||||
free (str);
|
||||
if ((str = Elf_(r_bin_elf_get_osabi_name) (arch->bin_obj)) == NULL)
|
||||
if (!(str = Elf_(r_bin_elf_get_osabi_name) (arch->bin_obj)))
|
||||
return NULL;
|
||||
strncpy (ret->subsystem, str, R_BIN_SIZEOF_STRINGS);
|
||||
free (str);
|
||||
if ((str = Elf_(r_bin_elf_get_machine_name) (arch->bin_obj)) == NULL)
|
||||
if (!(str = Elf_(r_bin_elf_get_machine_name) (arch->bin_obj)))
|
||||
return NULL;
|
||||
strncpy (ret->machine, str, R_BIN_SIZEOF_STRINGS);
|
||||
free (str);
|
||||
if ((str = Elf_(r_bin_elf_get_arch) (arch->bin_obj)) == NULL)
|
||||
if (!(str = Elf_(r_bin_elf_get_arch) (arch->bin_obj)))
|
||||
return NULL;
|
||||
strncpy (ret->arch, str, R_BIN_SIZEOF_STRINGS);
|
||||
free (str);
|
||||
|
@ -124,7 +124,7 @@ static int bin_info (RCore *r, int mode) {
|
||||
info->has_va? "true": "false",
|
||||
info->bits,
|
||||
r_str_bool (R_BIN_DBG_STRIPPED (info->dbg_info)),
|
||||
r_str_bool (R_BIN_DBG_STATIC (info->dbg_info)),
|
||||
r_str_bool (r_bin_is_static (r->bin)),//R_BIN_DBG_STATIC (info->dbg_info)),
|
||||
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))
|
||||
@ -202,7 +202,7 @@ static int bin_info (RCore *r, int mode) {
|
||||
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_DBG_STATIC (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)),
|
||||
@ -855,6 +855,11 @@ static int bin_libs (RCore *r, int mode) {
|
||||
}
|
||||
r_cons_printf ("]");
|
||||
} else
|
||||
if ((mode & R_CORE_BIN_RADARE)) {
|
||||
r_list_foreach (libs, iter, lib) {
|
||||
r_cons_printf ("CCa entry0 %s\n", lib);
|
||||
}
|
||||
} else
|
||||
if ((mode & R_CORE_BIN_SET)) {
|
||||
// Nothing to set.
|
||||
// TODO: load libraries with iomaps?
|
||||
|
@ -46,6 +46,11 @@ static int cmd_help(void *data, const char *input) {
|
||||
} else eprintf ("Unknown opcode\n");
|
||||
} else eprintf ("Use: ?d [opcode] to get the description of the opcode\n");
|
||||
break;
|
||||
case 'h':
|
||||
if (input[1]==' ') {
|
||||
r_cons_printf ("0x%08x\n", (ut32)r_str_hash (input+2));
|
||||
} else eprintf ("Usage: ?h [string-to-hash]\n");
|
||||
break;
|
||||
case 'y':
|
||||
for (input++; input[0]==' '; input++);
|
||||
if (*input) {
|
||||
@ -405,6 +410,7 @@ static int cmd_help(void *data, const char *input) {
|
||||
" ?d opcode describe opcode for asm.arch\n"
|
||||
" ?e string echo string\n"
|
||||
" ?f [num] [str] map each bit of the number as flag string index\n"
|
||||
" ?h [str] calculate hash for given string\n"
|
||||
" ?iy prompt yesno input prompt\n"
|
||||
" ?i[ynmkp] arg prompt for number or Yes,No,Msg,Key,Path and store in $$?\n"
|
||||
" ?in prompt yesno input prompt\n"
|
||||
|
@ -90,6 +90,7 @@ static int cmd_info(void *data, const char *input) {
|
||||
#define RBININFO(x) r_core_bin_info(core,x,mode,va,NULL,offset)
|
||||
case 'S': RBININFO (R_CORE_BIN_ACC_SECTIONS); break;
|
||||
case 'h': RBININFO (R_CORE_BIN_ACC_FIELDS); break;
|
||||
case 'l': RBININFO (R_CORE_BIN_ACC_LIBS); break;
|
||||
case 's': RBININFO (R_CORE_BIN_ACC_SYMBOLS); break;
|
||||
case 'd': RBININFO (R_CORE_BIN_ACC_DWARF); break;
|
||||
case 'i': RBININFO (R_CORE_BIN_ACC_IMPORTS); break;
|
||||
|
@ -94,7 +94,9 @@ static int cmd_meta(void *data, const char *input) {
|
||||
}
|
||||
case 'C': /* comment */
|
||||
if (input[1] == 'a') {
|
||||
const char *p = strchr (input+3, ' ');
|
||||
char *s = strdup (input+3);
|
||||
char *p = strchr (s, ' ');
|
||||
if (p) *p++ = 0;
|
||||
ut64 addr;
|
||||
if (input[2]=='-') {
|
||||
if (input[3]) {
|
||||
@ -105,16 +107,19 @@ static int cmd_meta(void *data, const char *input) {
|
||||
} else {
|
||||
eprintf ("Usage: CCa-[address]\n");
|
||||
}
|
||||
free (s);
|
||||
return R_TRUE;
|
||||
}
|
||||
addr = r_num_math (core->num, input+2);
|
||||
addr = r_num_math (core->num, s);
|
||||
// Comment at
|
||||
if (p) {
|
||||
r_meta_set_string (core->anal->meta,
|
||||
R_META_TYPE_COMMENT, addr, p+1);
|
||||
r_meta_add (core->anal->meta,
|
||||
R_META_TYPE_COMMENT,
|
||||
addr, addr+1, p);
|
||||
} else {
|
||||
eprintf ("Usage: CCa [address] [comment]\n");
|
||||
}
|
||||
free (s);
|
||||
return R_TRUE;
|
||||
}
|
||||
case 'h': /* comment */
|
||||
|
@ -926,14 +926,6 @@ r_config_set (cfg, "asm.arch", R_SYS_ARCH);
|
||||
config_set("range.graphs", "true");
|
||||
config_set("range.functions", "true");
|
||||
|
||||
config_set("child.stdio", "");
|
||||
config_set("child.stdin", "");
|
||||
config_set("child.stdout", "");
|
||||
config_set("child.stderr", "");
|
||||
config_set("child.setgid", ""); // must be int ?
|
||||
config_set("child.chdir", ".");
|
||||
config_set("child.chroot", "/");
|
||||
config_set("child.setuid", "");
|
||||
#if __mips__
|
||||
config_set("dbg.fpregs", "true");
|
||||
#else
|
||||
@ -942,24 +934,6 @@ r_config_set (cfg, "asm.arch", R_SYS_ARCH);
|
||||
config_set("dbg.forks", "false"); // stop debugger in any fork or clone
|
||||
config_set("dbg.controlc", "true"); // stop debugger if ^C is pressed
|
||||
config_set_i("dbg.focus", 0); // focus on ps.pid or not (ignore events of rest of procs)
|
||||
config_set("dbg.syms", "true");
|
||||
config_set("dbg.stepo", "false"); // step over for !contu (debug_step())
|
||||
config_set("dbg.maps", "true");
|
||||
config_set("dbg.sections", "true");
|
||||
config_set("dbg.strings", "false");
|
||||
config_set("dbg.stop", "false");
|
||||
config_set("dbg.threads", "false");
|
||||
config_set("dbg.contscbt", "true");
|
||||
config_set("dbg.contsc2", "true"); // WTF?
|
||||
config_set("dbg.regs", "true");
|
||||
config_set("dbg.regs2", "false");
|
||||
config_set("dbg.stack", "true");
|
||||
config_set("dbg.vstack", "true");
|
||||
config_set("dbg.wptrace", "false");
|
||||
config_set_i("dbg.stacksize", 66);
|
||||
config_set("dbg.stackreg", "esp");
|
||||
config_set("dbg.bt", "false");
|
||||
config_set_i("dbg.btlast", 0);
|
||||
config_set("dbg.fullbt", "false"); // user backtrace or lib+user backtrace
|
||||
config_set("dbg.bttype", "default"); // default, st and orig or so!
|
||||
#if __APPLE__ || __ARM__ || __mips__
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
static int endian = 1; // XXX HACK
|
||||
|
||||
static int core_cmd_callback (void *user, const char *cmd) {
|
||||
RCore *core = (RCore *)user;
|
||||
return r_core_cmd0 (core, cmd);
|
||||
@ -46,7 +44,7 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
int refsz = (core->assembler->bits & R_SYS_BITS_64)? 8: 4;
|
||||
const char *p = strchr (str+5, ':');
|
||||
ut64 n;
|
||||
// TODO: honor endian
|
||||
// TODO: honor LE
|
||||
if (p) {
|
||||
refsz = atoi (str+1);
|
||||
str = p;
|
||||
@ -749,7 +747,7 @@ static void rap_break (void *u) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move into core/io/rap? */
|
||||
// TODO: PLEASE move into core/io/rap? */
|
||||
// TODO: use static buffer instead of mallocs all the time. it's network!
|
||||
R_API int r_core_serve(RCore *core, RIODesc *file) {
|
||||
ut8 cmd, flg, *ptr = NULL, buf[1024];
|
||||
@ -757,6 +755,7 @@ R_API int r_core_serve(RCore *core, RIODesc *file) {
|
||||
int i, pipefd;
|
||||
RIORap *rior;
|
||||
ut64 x;
|
||||
int LE = 1; // 1 if host is little LE
|
||||
|
||||
rior = (RIORap *)file->data;
|
||||
if (rior == NULL|| rior->fd == NULL) {
|
||||
@ -824,7 +823,7 @@ reaccept:
|
||||
}
|
||||
}
|
||||
buf[0] = RMT_OPEN | RMT_REPLY;
|
||||
r_mem_copyendian (buf+1, (ut8 *)&pipefd, 4, !endian);
|
||||
r_mem_copyendian (buf+1, (ut8 *)&pipefd, 4, !LE);
|
||||
r_socket_write (c, buf, 5);
|
||||
r_socket_flush (c);
|
||||
|
||||
@ -841,7 +840,7 @@ reaccept:
|
||||
r_meta_type_to_string (d->type),
|
||||
(int)(d->to-d->from), d->str, d->from);
|
||||
i = strlen ((char *)buf);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !endian);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !LE);
|
||||
r_socket_write (c, (ut8 *)&j, 4);
|
||||
r_socket_write (c, buf, i);
|
||||
r_socket_flush (c);
|
||||
@ -854,7 +853,7 @@ reaccept:
|
||||
"S 0x%08"PFMT64x" 0x%08"PFMT64x" 0x%08"PFMT64x" 0x%08"PFMT64x" %s %d",
|
||||
s->offset, s->vaddr, s->size, s->vsize, s->name, s->rwx);
|
||||
i = strlen ((char *)buf);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !endian);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !LE);
|
||||
r_socket_write (c, (ut8 *)&j, 4);
|
||||
r_socket_write (c, buf, i);
|
||||
r_socket_flush (c);
|
||||
@ -869,7 +868,7 @@ reaccept:
|
||||
snprintf ((char *)buf, sizeof (buf),
|
||||
"fs %s", r_flag_space_get_i (core->flags, fs));
|
||||
i = strlen ((char *)buf);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !endian);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !LE);
|
||||
r_socket_write (c, (ut8 *)&j, 4);
|
||||
r_socket_write (c, buf, i);
|
||||
}
|
||||
@ -877,7 +876,7 @@ reaccept:
|
||||
"f %s %"PFMT64d" 0x%08"PFMT64x,
|
||||
flag->name, flag->size, flag->offset);
|
||||
i = strlen ((char *)buf);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !endian);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !LE);
|
||||
r_socket_write (c, (ut8 *)&j, 4);
|
||||
r_socket_write (c, buf, i);
|
||||
r_socket_flush (c);
|
||||
@ -885,7 +884,7 @@ reaccept:
|
||||
|
||||
snprintf ((char *)buf, sizeof (buf), "s 0x%"PFMT64x, core->offset);
|
||||
i = strlen ((char *)buf);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !endian);
|
||||
r_mem_copyendian ((ut8 *)&j, (ut8 *)&i, 4, !LE);
|
||||
r_socket_write (c, (ut8 *)&j, 4);
|
||||
r_socket_write (c, buf, i);
|
||||
|
||||
@ -898,7 +897,7 @@ reaccept:
|
||||
break;
|
||||
case RMT_READ:
|
||||
r_socket_read_block (c, (ut8*)&buf, 4);
|
||||
r_mem_copyendian ((ut8*)&i, buf, 4, !endian);
|
||||
r_mem_copyendian ((ut8*)&i, buf, 4, !LE);
|
||||
ptr = (ut8 *)malloc (i+core->blocksize+5);
|
||||
if (ptr==NULL) {
|
||||
eprintf ("Cannot read %d bytes\n", i);
|
||||
@ -911,7 +910,7 @@ reaccept:
|
||||
i = RMT_MAX;
|
||||
if (i>core->blocksize)
|
||||
r_core_block_size (core, i);
|
||||
r_mem_copyendian (ptr+1, (ut8 *)&i, 4, !endian);
|
||||
r_mem_copyendian (ptr+1, (ut8 *)&i, 4, !LE);
|
||||
memcpy (ptr+5, core->block, i); //core->blocksize);
|
||||
r_socket_write (c, ptr, i+5);
|
||||
r_socket_flush (c);
|
||||
@ -925,7 +924,7 @@ reaccept:
|
||||
|
||||
/* read */
|
||||
r_socket_read_block (c, (ut8*)&bufr, 4);
|
||||
r_mem_copyendian ((ut8*)&i, (ut8 *)bufr, 4, !endian);
|
||||
r_mem_copyendian ((ut8*)&i, (ut8 *)bufr, 4, !LE);
|
||||
if (i>0 && i<RMT_MAX) {
|
||||
if ((cmd=malloc (i))) {
|
||||
r_socket_read_block (c, (ut8*)cmd, i);
|
||||
@ -945,7 +944,7 @@ reaccept:
|
||||
}
|
||||
bufw = malloc (cmd_len + 5);
|
||||
bufw[0] = RMT_CMD | RMT_REPLY;
|
||||
r_mem_copyendian ((ut8*)bufw+1, (ut8 *)&cmd_len, 4, !endian);
|
||||
r_mem_copyendian ((ut8*)bufw+1, (ut8 *)&cmd_len, 4, !LE);
|
||||
memcpy (bufw+5, cmd_output, cmd_len);
|
||||
r_socket_write (c, bufw, cmd_len+5);
|
||||
r_socket_flush (c);
|
||||
@ -955,7 +954,7 @@ reaccept:
|
||||
}
|
||||
case RMT_WRITE:
|
||||
r_socket_read (c, buf, 5);
|
||||
r_mem_copyendian((ut8 *)&x, buf+1, 4, endian);
|
||||
r_mem_copyendian((ut8 *)&x, buf+1, 4, LE);
|
||||
ptr = malloc (x);
|
||||
r_socket_read (c, ptr, x);
|
||||
r_core_write_at (core, core->offset, ptr, x);
|
||||
@ -964,13 +963,13 @@ reaccept:
|
||||
break;
|
||||
case RMT_SEEK:
|
||||
r_socket_read_block (c, buf, 9);
|
||||
r_mem_copyendian((ut8 *)&x, buf+1, 8, !endian);
|
||||
r_mem_copyendian((ut8 *)&x, buf+1, 8, !LE);
|
||||
if (buf[0]!=2) {
|
||||
r_core_seek (core, x, buf[0]);
|
||||
x = core->offset;
|
||||
} else x = core->file->size;
|
||||
buf[0] = RMT_SEEK | RMT_REPLY;
|
||||
r_mem_copyendian (buf+1, (ut8*)&x, 8, !endian);
|
||||
r_mem_copyendian (buf+1, (ut8*)&x, 8, !LE);
|
||||
r_socket_write (c, buf, 9);
|
||||
r_socket_flush (c);
|
||||
break;
|
||||
@ -978,11 +977,11 @@ reaccept:
|
||||
eprintf ("CLOSE\n");
|
||||
// XXX : proper shutdown
|
||||
r_socket_read_block (c, buf, 4);
|
||||
r_mem_copyendian ((ut8*)&i, buf, 4, endian);
|
||||
r_mem_copyendian ((ut8*)&i, buf, 4, LE);
|
||||
{
|
||||
//FIXME: Use r_socket_close
|
||||
int ret = close (i);
|
||||
r_mem_copyendian (buf+1, (ut8*)&ret, 4, !endian);
|
||||
r_mem_copyendian (buf+1, (ut8*)&ret, 4, !LE);
|
||||
buf[0] = RMT_CLOSE | RMT_REPLY;
|
||||
r_socket_write (c, buf, 5);
|
||||
r_socket_flush (c);
|
||||
@ -991,7 +990,7 @@ reaccept:
|
||||
case RMT_SYSTEM:
|
||||
// read
|
||||
r_socket_read_block (c, buf, 4);
|
||||
r_mem_copyendian ((ut8*)&i, buf, 4, !endian);
|
||||
r_mem_copyendian ((ut8*)&i, buf, 4, !LE);
|
||||
if (i>0&&i<RMT_MAX) {
|
||||
ptr = (ut8 *) malloc (i+6);
|
||||
if (!ptr) return R_FALSE;
|
||||
@ -1041,7 +1040,7 @@ reaccept:
|
||||
|
||||
// send
|
||||
ptr[0] = (RMT_SYSTEM | RMT_REPLY);
|
||||
r_mem_copyendian ((ut8*)ptr+1, (ut8*)&i, 4, !endian);
|
||||
r_mem_copyendian ((ut8*)ptr+1, (ut8*)&i, 4, !LE);
|
||||
if (i<0) i = 0;
|
||||
r_socket_write (c, ptr, i+5);
|
||||
r_socket_flush (c);
|
||||
|
@ -250,8 +250,10 @@ toro:
|
||||
r_config_set_i (core->config, "asm.bits", f->bits);
|
||||
}
|
||||
} else {
|
||||
r_config_set_i (core->config, "asm.bits", oldbits);
|
||||
oldbits = 0;
|
||||
if (oldbits) {
|
||||
r_config_set_i (core->config, "asm.bits", oldbits);
|
||||
oldbits = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (oldbits) {
|
||||
|
@ -169,6 +169,7 @@ static void rcc_reset_callname() {
|
||||
#define FRAME_END_FMT "__%d_%d_end_frame%d"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static char *get_frame_label(int type) {
|
||||
static char label[128];
|
||||
int nf = nfunctions;
|
||||
@ -192,6 +193,7 @@ static char *get_end_frame_label(REgg *egg) {
|
||||
//snprintf (label, sizeof (label)-1, "frame_end_%d_%d", nfunctions, nbrackets);
|
||||
return label;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void rcc_pusharg(REgg *egg, char *str) {
|
||||
REggEmit *e = egg->emit;
|
||||
|
@ -872,6 +872,8 @@ R_API void r_anal_hint_set_length (RAnal *a, ut64 addr, int size, int length);
|
||||
R_API void r_anal_hint_set_opcode (RAnal *a, ut64 addr, int size, const char *str);
|
||||
R_API void r_anal_hint_set_analstr (RAnal *a, ut64 addr, int size, const char *str);
|
||||
|
||||
R_API int r_anal_esil_eval(RAnal *anal, const char *str);
|
||||
|
||||
/* plugin pointers */
|
||||
extern RAnalPlugin r_anal_plugin_csr;
|
||||
extern RAnalPlugin r_anal_plugin_c55plus;
|
||||
|
@ -248,6 +248,7 @@ R_API int r_cons_eof();
|
||||
R_API int r_cons_palette_init(const unsigned char *pal);
|
||||
R_API int r_cons_pal_set (const char *key, const char *val);
|
||||
R_API void r_cons_pal_list ();
|
||||
R_API void r_cons_pal_show ();
|
||||
R_API int r_cons_get_size(int *rows);
|
||||
R_API int r_cons_arrow_to_hjkl(int ch);
|
||||
R_API int r_cons_html_print(const char *ptr);
|
||||
|
@ -40,12 +40,24 @@ typedef struct r_egg_t {
|
||||
} REgg;
|
||||
|
||||
/* XXX: this may fail in different arches */
|
||||
#define R_EGG_OS_LINUX 0xcd21ce66
|
||||
#define R_EGG_OS_OSX 0x1bf9e4
|
||||
#define R_EGG_OS_DARWIN 0x5e417f87
|
||||
#define R_EGG_OS_MACOS 0xdc208773
|
||||
#define R_EGG_OS_W32 0x1dd9f6
|
||||
#define R_EGG_OS_WINDOWS 0xc9f3d7f
|
||||
#if 0
|
||||
r2 -q - <<EOF
|
||||
?e #define R_EGG_OS_LINUX \`?h linux\`
|
||||
?e #define R_EGG_OS_OSX \`?h osx\`
|
||||
?e #define R_EGG_OS_DARWIN \`?h darwin\`
|
||||
?e #define R_EGG_OS_MACOS \`?h macos\`
|
||||
?e #define R_EGG_OS_W32 \`?h w32\`
|
||||
?e #define R_EGG_OS_WINDOWS \`?h windows\`
|
||||
?e #define R_EGG_OS_BEOS \`?h beos\`
|
||||
EOF
|
||||
#endif
|
||||
#define R_EGG_OS_LINUX 0x0a52b843
|
||||
#define R_EGG_OS_OSX 0x0b875ee1
|
||||
#define R_EGG_OS_DARWIN 0x4292f662
|
||||
#define R_EGG_OS_MACOS 0x0a66c956
|
||||
#define R_EGG_OS_W32 0x0b877473
|
||||
#define R_EGG_OS_WINDOWS 0x7de634da
|
||||
#define R_EGG_OS_BEOS 0x7c70357e
|
||||
|
||||
#if __APPLE__
|
||||
#define R_EGG_OS_DEFAULT R_EGG_OS_OSX
|
||||
|
@ -16,7 +16,7 @@ R_API RIODesc *r_io_desc_new(RIOPlugin *plugin, int fd, const char *name, int fl
|
||||
int i;
|
||||
RIODesc *desc = R_NEW (RIODesc);
|
||||
if (!desc) return NULL;
|
||||
if (fd<0) eprintf ("r_io_desc_new: Warning: fd '%s' is -1\n", name);
|
||||
if (fd==-1) eprintf ("WARNING: r_io_desc_new with fd = -1\n");
|
||||
desc->state = R_IO_DESC_TYPE_OPENED;
|
||||
desc->name = strdup (name);
|
||||
if (desc->name == NULL) {
|
||||
@ -25,7 +25,7 @@ R_API RIODesc *r_io_desc_new(RIOPlugin *plugin, int fd, const char *name, int fl
|
||||
}
|
||||
desc->plugin = plugin;
|
||||
desc->flags = flags;
|
||||
if (fd <0) {
|
||||
if (fd == -2) {
|
||||
ut8 *p = (ut8 *)&(desc->fd);
|
||||
desc->fd = ((int) ((size_t) desc) & 0xffffff);
|
||||
desc->fd = p[0];
|
||||
|
@ -70,7 +70,7 @@ static int __plugin_open(struct r_io_t *io, const char *pathname) {
|
||||
static RIODesc *__open(struct r_io_t *io, const char *pathname, int rw, int mode) {
|
||||
if (__plugin_open (io, pathname)) {
|
||||
RIOMalloc *mal = R_NEW (RIOMalloc);
|
||||
mal->fd = -1; /* causes r_io_desc_new() to set the correct fd */
|
||||
mal->fd = -2; /* causes r_io_desc_new() to set the correct fd */
|
||||
if (!memcmp (pathname, "hex://", 6)) {
|
||||
mal->size = strlen (pathname);
|
||||
mal->buf = malloc (mal->size);
|
||||
@ -87,8 +87,10 @@ static RIODesc *__open(struct r_io_t *io, const char *pathname, int rw, int mode
|
||||
}
|
||||
}
|
||||
if (mal->buf != NULL)
|
||||
return r_io_desc_new (&r_io_plugin_malloc, mal->fd, pathname, rw, mode, mal);
|
||||
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size);
|
||||
return r_io_desc_new (&r_io_plugin_malloc, mal->fd,
|
||||
pathname, rw, mode, mal);
|
||||
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9,
|
||||
mal->size);
|
||||
free (mal);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -205,20 +205,26 @@ fail:
|
||||
return dst;
|
||||
}
|
||||
|
||||
/* XXX Fix new hash algo*/
|
||||
R_API ut64 r_str_hash64(const char *str) {
|
||||
ut64 ret = 0;
|
||||
for (; *str; str++)
|
||||
ret ^= (ret<<7 | *str);
|
||||
return ret;
|
||||
R_API ut64 r_str_hash64(const char *s) {
|
||||
int len = strlen (s);
|
||||
ut64 h = 5381;
|
||||
if (len<1) len = strlen (s)+1; // XXX slow
|
||||
while (len--) {
|
||||
h += (h<<5);
|
||||
h ^= *s++;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
R_API ut32 r_str_hash(const char *str) {
|
||||
ut32 ret = 0;
|
||||
if (str && *str)
|
||||
for (; *str; str++)
|
||||
ret ^= (ret<<7 | *str);
|
||||
return ret;
|
||||
R_API ut32 r_str_hash (const char *s) {
|
||||
int len = strlen (s);
|
||||
ut32 h = 5381;
|
||||
if (len<1) len = strlen (s)+1; // XXX slow
|
||||
while (len--) {
|
||||
h += (h<<5);
|
||||
h ^= *s++;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
R_API int r_str_delta(char *p, char a, char b) {
|
||||
|
Loading…
Reference in New Issue
Block a user