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

Keystone automatically converting immediates for relative instructions as if they were absolute? #567

Open
tmsrise opened this issue Nov 27, 2023 · 1 comment

Comments

@tmsrise
Copy link

tmsrise commented Nov 27, 2023

I was manually calculating offsets for jump targets and running into issues before realizing that Keystone was assembling my immediates as if they were absolute.

For example, in armv7, the branch (b) instruction uses relative addressing.

I would expect

b 0x1234

to jump to pc + 0x1234, but Keystone instead acts as if I want to jump to 0x1234 and effectively replaces it with an entirely different offset. (This of course only occurs when using a non-zero starting address). While very convenient, it's surprising and unintuitive.

Is there a way to explicitly control this behavior? Can I continue to integrate with keystone under the assumption that this isn't a bug from accidentally treating an immediate like a parsed label?

@tmsrise
Copy link
Author

tmsrise commented Nov 27, 2023

Probably due to #108, not sure if this "fix" is intended (though very much appreciated, if integrated correctly.). Either way it's non-obvious with no documentation other than an offhand vague mention in powerpoint. Also causes issues like #568

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

1 participant