jmp_match: account for self-shrink on forward jcc/jmp rel8 check#239
Open
bboe wants to merge 1 commit into
Open
jmp_match: account for self-shrink on forward jcc/jmp rel8 check#239bboe wants to merge 1 commit into
bboe wants to merge 1 commit into
Conversation
The borderline rel8 fit test compared the current-layout short displacement (target - offset - short_size). For a forward jump that the previous pass emitted as NEAR, shrinking to SHORT moves the target near_size - short_size bytes closer, so the post-shrink rel8 is that many bytes smaller. NASM was keeping forward near jcc/jmp instances that a self-shrink-aware iteration emits as short (a 4-byte shrink for jcc32, 3-byte for jmp32). Track per-jump previous-pass encoding in a static side table, swapped at pass boundaries via _passn. In the borderline branch, when the current-layout check rejects AND the previous pass was NEAR AND the jump is forward, re-check against the post-shrink displacement. The previous-pass guard prevents over-shrinking already-short jumps whose displacement grew past 127; the forward guard skips backward jumps, whose target doesn't move when the jump shrinks. Add travis/test/jccshrink as a regression test: stock NASM emits 605 B with a 5-byte near jmp at 0x1d9; patched emits 602 B with eb 7f (rel8 = 127). make travis passes (301/301). Byte-identical on optimization.asm, jmp64.asm, riprel.asm, a32offs.asm. Signed-off-by: Bryce Boe <bbzbryce@gmail.com>
Author
|
Bump. |
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.
Forward jcc/jmp self-shrink case in
jmp_match()'s borderline rel8 fit check was rejecting valid shrinks because it compared against the current-layout displacement instead of the post-shrink one. Regression test:travis/test/jccshrink.