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

Properly create BLX instruction #1266

Merged
merged 1 commit into from Jun 29, 2019

Conversation

Projects
None yet
2 participants
@luigoalma
Copy link
Contributor

commented Jun 29, 2019

Sorry I'm coming with a commit post release, but looking at that patch function I made made me think about the maths that were being done.
And this a correction of them.
Better than leaving it uncorrected.
A bit shall never be set on a THUMB -> ARM BLX op, and this bit was what messed with me the first time i made this code but didn't knew about it. Hence now that added & ~(1<<16).
So, the op jump distance math was incorrect because i never fixed that bit, but instead changed the maths of the op distance, originally.
Old code was basically doing (Destination_offset - blx_op_offset+4) / 2 instead of +2, which worked as mentioned on commit message, by sheer luck of offsets.
But now this new code is correct.

Properly create BLX instruction
Rethinked and revised this function.
This previous one worked by "accident".
More a sheer luck of offsets on current firmware (as of writing)
But now, this is more mathematically correct way of creating a
THUMB -> ARM BLX instruction.
Also setting the new op in a set of 2 u16,
because patching code is in thumb.

@TuxSH TuxSH merged commit 6ed93a1 into AuroraWright:master Jun 29, 2019

@TuxSH

This comment has been minimized.

Copy link
Collaborator

commented Jun 29, 2019

Release hotfixed with this PR merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.