mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 21:29:49 +00:00
Add support for wired-to-ground registers for MIPS and V850 (#11320)
This commit is contained in:
parent
a8aad5305d
commit
63669bee85
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 = ®->regset[item->arena];
|
||||
int off = BITS2BYTES (item->offset);
|
||||
RRegSet *regset = ®->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) {
|
||||
|
Loading…
Reference in New Issue
Block a user