Add support for wired-to-ground registers for MIPS and V850 (#11320)

This commit is contained in:
radare 2018-08-31 03:05:41 +02:00 committed by GitHub
parent a8aad5305d
commit 63669bee85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 23 deletions

View File

@ -1022,7 +1022,7 @@ static char *get_reg_profile(RAnal *anal) {
"=A3 a3\n"
"=R0 v0\n"
"=R1 v1\n"
"gpr zero .32 0 0\n"
"gpr zero .32 ? 0\n"
"gpr at .32 4 0\n"
"gpr v0 .32 8 0\n"
"gpr v1 .32 12 0\n"

View File

@ -359,6 +359,7 @@ static char *get_reg_profile(RAnal *anal) {
"=OF ov\n"
"=CF cy\n"
"gpr zero .32 ? 0\n"
"gpr r0 .32 0 0\n"
"gpr r1 .32 4 0\n"
"gpr r2 .32 8 0\n"

View File

@ -73,7 +73,11 @@ static const char *parse_def(RReg *reg, char **tok, const int n) {
r_reg_item_free (item);
return "Invalid size";
}
item->offset = parse_size (tok[3], &end);
if (!strcmp (tok[3], "?")) {
item->offset = -1;
} else {
item->offset = parse_size (tok[3], &end);
}
if (*end != '\0') {
r_reg_item_free (item);
return "Invalid offset";

View File

@ -62,7 +62,6 @@ R_API const char* r_reg_64_to_32(RReg* reg, const char* rreg64) {
return NULL;
}
R_API const char* r_reg_get_type(int idx) {
return (idx >= 0 && idx < R_REG_TYPE_LAST)? types[idx]: NULL;
}

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2016 - pancake */
/* radare - LGPL - Copyright 2009-2018 - pancake */
#include <r_reg.h>
#include <r_util.h>
@ -59,14 +59,11 @@ R_API ut64 r_reg_get_value_big(RReg *reg, RRegItem *item, utX *val) {
}
R_API ut64 r_reg_get_value(RReg *reg, RRegItem *item) {
RRegSet *regset;
int off;
ut64 ret = 0LL;
if (!reg || !item) {
if (!reg || !item || item->offset == -1) {
return 0LL;
}
off = BITS2BYTES (item->offset);
regset = &reg->regset[item->arena];
int off = BITS2BYTES (item->offset);
RRegSet *regset = &reg->regset[item->arena];
switch (item->size) {
case 1:
{
@ -74,54 +71,52 @@ R_API ut64 r_reg_get_value(RReg *reg, RRegItem *item) {
if (offset + item->size >= regset->arena->size) {
break;
}
ret = (regset->arena->bytes[offset] &
return (regset->arena->bytes[offset] &
(1 << (item->offset % 8))) ? 1 : 0;
}
break;
case 4:
if (regset->arena->size - off - 1 >= 0) {
ret = (r_read_at_ble8 (regset->arena->bytes, off)) & 0xF;
return (r_read_at_ble8 (regset->arena->bytes, off)) & 0xF;
}
break;
case 8:
if (regset->arena->size - off - 1 >= 0) {
ret = r_read_at_ble8 (regset->arena->bytes, off);
return r_read_at_ble8 (regset->arena->bytes, off);
}
break;
case 16:
if (regset->arena->size - off - 2 >= 0) {
ret = r_read_ble16 (regset->arena->bytes + off, reg->big_endian);
return r_read_ble16 (regset->arena->bytes + off, reg->big_endian);
}
break;
case 27:
if (off + 3 < regset->arena->size) {
ret = r_read_me27 (regset->arena->bytes + off, 0);
return r_read_me27 (regset->arena->bytes + off, 0);
}
break;
case 32:
if (off + 4 <= regset->arena->size) {
ret = r_read_ble32 (regset->arena->bytes + off, reg->big_endian);
} else {
eprintf ("r_reg_get_value: 32bit oob read %d\n", off);
return r_read_ble32 (regset->arena->bytes + off, reg->big_endian);
}
eprintf ("r_reg_get_value: 32bit oob read %d\n", off);
break;
case 64:
if (regset->arena->bytes && (off + 8 <= regset->arena->size)) {
ret = r_read_ble64 (regset->arena->bytes + off, reg->big_endian);
} else {
eprintf ("r_reg_get_value: null or oob arena for current regset\n");
return r_read_ble64 (regset->arena->bytes + off, reg->big_endian);
}
eprintf ("r_reg_get_value: null or oob arena for current regset\n");
break;
case 80: // long double
case 96: // long floating value
// FIXME: It is a precision loss, please implement me properly!
ret = (ut64)r_reg_get_longdouble (reg, item);
return (ut64)r_reg_get_longdouble (reg, item);
break;
default:
eprintf ("r_reg_get_value: Bit size %d not supported\n", item->size);
break;
}
return ret;
return 0LL;
}
R_API ut64 r_reg_get_value_by_role(RReg *reg, RRegisterId role) {