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

restore floating point registers from stack in reverse order #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ishutinvv
Copy link

We should restore registers preserved in stack in reverse order. Otherwise, it leads to shuffled values in those registers after trampoline.

The simplest way to reproduce is to swizzle any method from UIKit that accepts CGFloat or plain struct like CGRect. It's relevant only to arm64.
Btw, regular registers get restored correctly.

lukaskubanek added a commit to structuredpath/InterposeKit that referenced this pull request Oct 21, 2024
lukaskubanek added a commit to structuredpath/InterposeKit that referenced this pull request Oct 21, 2024
This commit applies the patch from steipete#37, which resolves an issue affecting swizzled methods that take `CGFloat` parameters or structs containing `CGFloat` (such as `CGPoint` or `CGRect`) on ARM64. The issue occurred because floating-point registers were apparently not being restored in the correct order, causing values in those registers to become shuffled after the trampoline call.

The fix ensures that floating-point registers are restored in reverse order, as required by ARM64 calling conventions. According to the referenced PR, regular registers were already handled correctly, so this issue specifically affected floating-point parameters.
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.

1 participant