Skip to content

Commit

Permalink
Minor arc + arcompact cleanups and whitespace, ending with anal_arc f…
Browse files Browse the repository at this point in the history
…ully indented (radareorg#4937)
  • Loading branch information
hamishcoleman authored and radare committed May 18, 2016
1 parent 79d57a4 commit afed79c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
30 changes: 15 additions & 15 deletions libr/anal/p/anal_arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ static int arcompact_genops(RAnalOp *op, ut64 addr, ut32 words[2]) {

static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
ut32 words[2]; /* storage for the de-swizled opcode data */
const ut8 *b = (ut8 *)data;
arc_fields fields;

/* ARCompact ISA, including */
Expand All @@ -420,26 +419,28 @@ static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, in
return 0;
}

op->type = R_ANAL_OP_TYPE_UNK;
op->ptr = UT64_MAX;
op->val = UT64_MAX;
op->jump = UT64_MAX;
op->fail = UT64_MAX;
op->refptr = 0;
op->delay = 0;

if (anal->big_endian) {
int i;
for (i = 0; i < 8; i += 4) {
words[i / 4] = r_read_be32 (&b[i]);
}
words[0] = r_read_be32 (&data[0]);
words[1] = r_read_be32 (&data[4]);
} else {
int i;
for (i = 0; i < 8; i += 4) {
words[i / 4] = r_read_me32 (&b[i]);
}
words[0] = r_read_me32 (&data[0]);
words[1] = r_read_me32 (&data[4]);
}

ut8 opcode = (words[0] & 0xf8000000) >> 27;
fields.opcode = (words[0] & 0xf8000000) >> 27;

op->size = (opcode >= 0x0c)? 2: 4;
op->size = (fields.opcode >= 0x0c)? 2: 4;
op->nopcode = op->size;

switch (opcode) {
switch (fields.opcode) {
case 0:
fields.format = (words[0] & 0x00010000) >> 16;
fields.a = (words[0] & 0x07fe0000) >> 17;
Expand Down Expand Up @@ -967,8 +968,7 @@ static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
case 0x05: /* Branch with Link */
case 0x06: /* Loop */
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4 + (((b[1] << 1) | (b[2] << 9) |
((b[3] & 7) << 17) | ((b[0] & 0x80) >> 7)) << 2);
op->jump = addr + 4 + ((r_read_le32 (&data[0]) & 0x07ffff80) >> (7 - 2));
break;
case 0x07: /* Conditional Jump and Jump with Link */
op->type = R_ANAL_OP_TYPE_CJMP;
Expand Down Expand Up @@ -1092,6 +1092,6 @@ struct r_anal_plugin_t r_anal_plugin_arc = {
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.data = &r_anal_plugin_arc,
.version = R2_VERSION
.version = R2_VERSION,
};
#endif
1 change: 1 addition & 0 deletions sys/indent-whitelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ libr/include/r_reg.h
libr/anal/cycles.c
libr/anal/esil.c
libr/anal/data.c
libr/anal/p/anal_arc.c
libr/config/config.c
libr/config/callback.c
libr/config/t/test.c
Expand Down
6 changes: 6 additions & 0 deletions sys/indent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ if [ "${IFILE}" = "-u" ]; then
IFILE="$1"
fi

# yell, rather than overwrite an innocent file
if ! type clang-format >/dev/null; then
echo This script requires clang-format to function
exit 1
fi

indentFile() {
if [ ! -f "${IFILE}" ]; then
echo "Cannot find $IFILE"
Expand Down

0 comments on commit afed79c

Please sign in to comment.