Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9197, wrong esil for aarch64 ldr #9442

Merged
merged 1 commit into from
Feb 20, 2018
Merged

Conversation

giuscri
Copy link
Contributor

@giuscri giuscri commented Feb 20, 2018

See #9197.

Test: https://github.com/radare/radare2-regressions/pull/1186

Diff is messy. Actually, the change is small.

@@ -1022,53 +1022,51 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
default:
break;
}
if ((int)MEMDISP64(1) < 0) {
Copy link
Contributor Author

@giuscri giuscri Feb 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't understand this if: why having a negative offset should result in an direct ESIL translation, while for positive offset you still have to check other things - see below?

Also, resulting expression is something like dst,base,20,-,=[8] which to my understanding translates to dst = *(20-base)

What I did was moving that check right before the ESIL with the positive offset is generated, and if offset is negative change + with a -.

Indentation messed up the diff.

@radare
Copy link
Collaborator

radare commented Feb 20, 2018 via email

@giuscri
Copy link
Contributor Author

giuscri commented Feb 20, 2018

To make the diff cleaner? How? I'm already up to date with master

@giuscri
Copy link
Contributor Author

giuscri commented Feb 20, 2018

Maybe I could split the change in 2, 3 commits to help diff and your review and you're squashing them while merging

@giuscri
Copy link
Contributor Author

giuscri commented Feb 20, 2018

Actually passing -b to git diff, it ignores the change in whitespaces/indentation levels.

$ git diff upstream/master -b
diff --git a/libr/anal/p/anal_arm_cs.c b/libr/anal/p/anal_arm_cs.c
index 8bcbbc7a6..61df5545d 100644
--- a/libr/anal/p/anal_arm_cs.c
+++ b/libr/anal/p/anal_arm_cs.c
@@ -1022,10 +1022,6 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
                default:
                    break;
                }
-               if ((int)MEMDISP64(1) < 0) {
-                       r_strbuf_setf (&op->esil, "%s,%s,%"PFMT64d",-,=[%d]",
-                               REG64(0), MEMBASE64(1), -(int)MEMDISP64(1), size);
-               } else {
                if (ISMEM64(1)) {
                        if (HASMEMINDEX64(1)) {
                                if (LSHIFT2_64(1)) {
@@ -1039,6 +1035,9 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
                                if (LSHIFT2_64(1)) {
                                        r_strbuf_appendf (&op->esil, "%s,%d,%"PFMT64d",%s,+,[%d],%s,=",
                                                        MEMBASE64(1), LSHIFT2_64(1), MEMDISP64(1), DECODE_SHIFT64(1), size, REG64(0));
+                               } else if ((int)MEMDISP64(1) < 0){
+                                       r_strbuf_appendf (&op->esil, "%"PFMT64d",%s,-,DUP,tmp,=,[%d],%s,=,",
+                                                       -(int)MEMDISP64(1), MEMBASE64(1), size, REG64(0));
                                } else {
                                        r_strbuf_appendf (&op->esil, "%s,%"PFMT64d",+,DUP,tmp,=,[%d],%s,=,",
                                                        MEMBASE64(1), MEMDISP64(1), size, REG64(0));
@@ -1069,7 +1068,6 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
                                        IMM64(1), size, REG64(0));
                        }
                }
-               }
                break;
                }
        case ARM64_INS_CCMP:

@radare radare merged commit d08115b into radareorg:master Feb 20, 2018
@giuscri giuscri deleted the fix-ldur-esil branch February 21, 2018 11:09
SakiiR pushed a commit to SakiiR/radare2 that referenced this pull request Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants