Skip to content

Commit

Permalink
Add few missing arm64 fpu instructions for pseudo ##decompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Jul 10, 2024
1 parent 4d2a841 commit 9d8fa62
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion libr/arch/p/arm/pseudo.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ static int replace(int argc, const char *argv[], char *newstr) {
const char *str;
int args[MAXPSEUDOOPS];
} ops[] = {
{ 2, "uxtb", "# = #", { 1, 2 } },
{ 0, "abs", "# = abs(#)", { 1, 1 } },
{ 0, "adc", "# = # + #", { 1, 2, 3 } },
{ 3, "add", "# = # + #", { 1, 2, 3 } },
{ 0, "fcvtzs", "# = #", { 1, 2 } },
{ 0, "scvtf", "# = #", { 1, 2 } },
{ 2, "add", "# += #", { 1, 2 } },
{ 2, "adds", "# += #", { 1, 2 } },
{ 4, "madd", "# = (# * #) + #", { 1, 2, 3, 4 } },
Expand All @@ -43,6 +46,7 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ 0, "b.gt", "if (a > b) goto #", { 1 } },
{ 0, "b.le", "if (a <= b) goto #", { 1 } },
{ 0, "b.lt", "if (a < b) goto #", { 1 } },
{ 0, "b.ls", "if (a < b) goto #", { 1 } },
{ 0, "b.ge", "if (a >= b) goto #", { 1 } },
{ 0, "beq lr", "ifeq ret", {0} },
{ 0, "beq", "je #", { 1 } },
Expand Down Expand Up @@ -76,6 +80,9 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ 2, "sxth", "# = (short) #", { 1, 2 } },
{ 0, "fdv", "# = # / #", { 1, 2, 3 } },
{ 0, "fml", "# = # * #", { 1, 2, 3 } },
{ 3, "ldurb", "# = (byte) # #", { 1, 2, 3 } },
{ 3, "ldur", "# = # #", { 1, 2, 3 } },
{ 3, "ldursw", "# = # #", { 1, 2, 3 } },
{ 2, "ldr", "# = #", { 1, 2 } },
{ 2, "ldrh", "# = (word) #", { 1, 2 } },
{ 3, "ldrh", "# = (word) # + #", { 1, 2, 3 } },
Expand Down Expand Up @@ -347,7 +354,7 @@ static char *mount_oldstr(RParse* p, const char *reg, st64 delta, bool ucase) {
}

static bool subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) {
r_return_val_if_fail (p, false);
R_RETURN_VAL_IF_FAIL (p, false);
RList *spargs = NULL;
RList *bpargs = NULL;
RListIter *iter;
Expand Down
6 changes: 4 additions & 2 deletions libr/core/pseudo.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,16 @@ R_API int r_core_pseudo_code(RCore *core, const char *input) {
indent--;
continue;
}
#if 0
if (sdb_num_get (db, K_ELSE (bb->addr), 0)) {
NEWLINE (addr, indent);
if (!strcmp (blocktype, "else")) {
PRINTF (" // } %s {", blocktype);
PRINTF (" // %s", blocktype);
} else {
PRINTF (" // } %s (?);", blocktype);
PRINTF (" // %s ();", blocktype);
}
}
#endif
if (addr != bb->addr) {
queuegoto = addr;
// r_cons_printf ("\n%s goto loc_0x%"PFMT64x, indentstr, addr);
Expand Down
2 changes: 0 additions & 2 deletions test/db/cmd/cmd_pdc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ int entry0 (int stack, int stack) {
var = si - 0
if (var > 0) goto loc_0x402018 // unlikely
goto loc_0x00402042;
// } while (?);
goto loc_0x00402042;
}
return eax;
Expand Down Expand Up @@ -170,7 +169,6 @@ int sym.func.100003a54 (int x0, int x1) {
x1 = x0 + 0x68 // arg1
x0 = x8
goto sym.imp.strcoll // int strcoll("", "")
// } else {
}
return x0;
loc_0x100003a6c: // orphan
Expand Down

0 comments on commit 9d8fa62

Please sign in to comment.