-
Notifications
You must be signed in to change notification settings - Fork 457
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
Problem with encoding jmps to absolute addresses #108
Comments
Can you send in a testcase? Thanks
|
I have made a simple program that demonstrates this bug for ARM, ARM64, SPARC, MIPS, PPC and SystemZ. |
can you rewrite this into a regress test and send a PR to put it under directory |
Pull request #109 created. |
how far have you gone to attempt to fix this issue? |
I have found the source of the problem, and given enough time I can fix it. When do you plan to release keystone? |
Fixed rel address issues for SystemZ (Issue #108)
fixed all now, thanks! |
Jumps to absolute addresses are not always encoded correctly.
For example:
Since the
b
instruction encodes a relative offset to the target address, the instruction encoding should be the same, however it isn't. You can verify the incorrect encoding using capstone.The same happens with many architectures, such as KS_ARCH_ARM(other instructions such as bl), KS_ARCH_ARM64 (b, bl etc), KS_ARCH_MIPS(KS_MODE_MIPS32 with b, beq, etc), KS_ARCH_SPARC(b, etc).
The problem originates at the MCCodeEmitter (for example, for the SPARC architecture at llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp) which returns the immediate when it encounters it as an argument at a branch, and not a relative offset.
The text was updated successfully, but these errors were encountered: