Add two-stage ARM64 trampoline allocation with instruction expansion#26
Merged
Add two-stage ARM64 trampoline allocation with instruction expansion#26
Conversation
The previous fix used alloc_near with a fixed ±128MB range for ARM64 trampolines. This fails on some VM layouts where no free memory exists within that range. - Try ±128MB first (all relocations fit in-place), then ±4GB (covers ADRP), then unrestricted mmap as final fallback - When a relocated instruction overflows its immediate range, expand it to an absolute sequence (LDR X16 + BR X16 for branches, MOVZ/MOVK for address loads, inverted condition + absolute branch for conditionals) - Trampoline is now variable-length: Vec<u32> instead of fixed offsets - Dynamic error messages in alloc_near show actual max_range - 7 new unit tests for all expansion types (B, BL, ADR, ADRP, CBZ, TBZ, near-stays-single)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous fix used alloc_near with a fixed ±128MB range for ARM64 trampolines. This fails on some VM layouts where no free memory exists within that range.