8051 is a 8bit cpu, set asm.bits when asm.arch doesnt supports current value

This commit is contained in:
pancake 2014-06-10 11:48:02 +02:00
parent 20ed296741
commit b3e8b3152b
4 changed files with 13 additions and 7 deletions

View File

@ -84,7 +84,7 @@ static int i8051_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len
struct r_anal_plugin_t r_anal_plugin_8051 = {
.name = "8051",
.arch = R_SYS_ARCH_8051,
.bits = 16,
.bits = 8,
.desc = "8051 CPU code analysis plugin",
.license = "LGPL3",
.init = NULL,

View File

@ -38,7 +38,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
RAsmPlugin r_asm_plugin_8051 = {
.name = "8051",
.arch = "8051",
.bits = 16,
.bits = 8,
.desc = "8051 Intel CPU",
.init = NULL,
.fini = NULL,

View File

@ -152,6 +152,7 @@ static int cb_analsplit(void *user, void *data) {
}
static int cb_asmarch(void *user, void *data) {
char asmparser[32];
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
const char *asmos = core->config? r_config_get (core->config, "asm.os"): NULL;
@ -163,11 +164,16 @@ static int cb_asmarch(void *user, void *data) {
r_egg_setup (core->egg, node->value, core->anal->bits, 0, R_SYS_OS);
if (!r_asm_use (core->assembler, node->value))
eprintf ("asm.arch: cannot find (%s)\n", node->value);
{
char asmparser[32];
snprintf (asmparser, sizeof (asmparser), "%s.pseudo", node->value);
r_config_set (core->config, "asm.parser", asmparser);
snprintf (asmparser, sizeof (asmparser), "%s.pseudo", node->value);
r_config_set (core->config, "asm.parser", asmparser);
if (!(core->assembler->cur->bits & core->anal->bits)) {
int bits = core->assembler->cur->bits;
if (8&bits) bits = 8;
else if (16&bits) bits=16;
else if (32&bits) bits=32;
else bits=64;
r_config_set_i (core->config, "asm.bits", bits);
}
if (!r_config_set (core->config, "anal.arch", node->value)) {
char *p, *s = strdup (node->value);

View File

@ -365,7 +365,7 @@ R_API RSocket *r_socket_accept(RSocket *s) {
//signal (SIGPIPE, SIG_DFL);
sock->fd = accept (s->fd, (struct sockaddr *)&s->sa, &salen);
if (sock->fd == -1) {
r_sys_perror("accept");
r_sys_perror ("accept");
free (sock);
return NULL;
}