Repository navigation
fix(x86_64): only relax when the section holds the rewritten bytes - #3069
Closed
deepakshirkem wants to merge 1 commit into
Closed
deepakshirkem wants to merge 1 commit into
deepakshirkem wants to merge 1 commit into
Conversation
The relaxation recognisers check the bytes needed to identify an instruction sequence, but five relaxations rewrite more than that. On a truncated section, applying them panicked. Decline the relaxation unless the section holds everything it rewrites.
deepakshirkem
marked this pull request as ready for review
November 23, 2026 19:18
marxin
reviewed
Nov 24, 2026
marxin
left a comment
Collaborator
There was a problem hiding this comment.
I'm against the change as it introduced unnecessary complexity. The linked issue is a product of artificially constructed object files and a normal toolchain does not produce such a garbage. Ending with a linker panic seems like a reasonable outcome for such an input.
Note, in general, one can produce an infinite number of invalid object files where we'll certainly crash and such issues should be categorized as very low priority.
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 x86-64 relaxation recognisers check the bytes they need to identify an instruction sequence, but five relaxations then rewrite more than that:
TlsLdToLocalExec,TlsLdToLocalExec64,TlsLdToLocalExecNoPlt,SkipTlsDescCallandJmpIndirectToRelative. On a section cut short after the recognised bytes,applywrote past its end and panicked.Each of those recognisers now declines the relaxation unless the section holds everything
applywrites. The relocation is then handled without relaxation: the TLSLD sequences link, and the other two now give the existing errors for a static TLSDESC call and a relocation outside its section. GNU ld rejects all five.This checks the span in each affected recogniser. A more general alternative would be for every
RelaxationKindto report the span it rewrites, checked in one place; happy to do that instead if you prefer.Fixes #2995