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

jalr doesn't resolve the address correctly. #33

Open
nihilus opened this issue Aug 30, 2015 · 3 comments
Open

jalr doesn't resolve the address correctly. #33

nihilus opened this issue Aug 30, 2015 · 3 comments
Assignees

Comments

@nihilus
Copy link
Owner

nihilus commented Aug 30, 2015

jalr doesn't resolve the address correctly.

@nihilus nihilus self-assigned this Aug 30, 2015
@hlide
Copy link

hlide commented Sep 15, 2015

        case MIPS_INS_BAL: /* Fall-through */
        case MIPS_INS_JALR:
        case MIPS_INS_JAL: {
            auto block = MipsExpressionFactoryCallback(factory_, program->createBasicBlock(), instruction);
            auto taken = delayslotCallback(block);
            taken[call(operand(0)), jump(directSuccessorButOne())];
            _[jump(taken.basicBlock())];
            break;
        }

If I recall well capstone JALR rd, rs has rd in operand(0) and rs in operand(1). Usually rd is linked to ra to get the return address and rs always contains the target address. So, the actual c++ code is wrong for JALR (trying to refactor teh same code for several opcode ids is a very bad idea in my humble opinion).

@hlide
Copy link

hlide commented Sep 15, 2015

Ah yes, because capstone MIPS is loving to mess up with you, there is a special case where MIPS_INS_JALR gives only operand(0) and it is rs when rd actually linked to ra. Which case is wrong?

@nihilus
Copy link
Owner Author

nihilus commented Sep 15, 2015

This issue is more about the ELF ABI and the MIPS ELF quirks.

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

No branches or pull requests

2 participants