radlink: match MSVC for discarded associative COMDAT relocations - #940
Closed
honkstar1 wants to merge 1 commit into
Closed
radlink: match MSVC for discarded associative COMDAT relocations#940honkstar1 wants to merge 1 commit into
honkstar1 wants to merge 1 commit into
Conversation
Collaborator
|
ported fix in 40c2d64 |
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.
Summary
Match Microsoft link.exe's handling of relocations to discarded associative COMDAT metadata. This fixes an ASan-instrumented BlankProgram link without disabling ASan, REF, or ICF.
ASan can share a filename string between metadata attached to different COMDAT owners. If the filename's owner loses duplicate selection but another referring owner survives, the existing linker reports
Error(031)for the surviving reference. The issue also reproduces with raw COFF, so it is not specific to compressed objects.Compatibility policy
Microsoft link.exe accepts this case. A small COFF reproducer establishes that the discarded target contributes RVA zero, section zero, and section offset zero. Its original symbol offset is discarded; the relocation addend and ordinary image-base adjustment remain. For example, ADDR64 with addend 5 produces
image_base + 5, not a pointer to the winning owner's metadata. Loader base relocations must still be emitted.LLD 20.1.8 rejects the same discarded-section references. This PR deliberately follows the MSVC behaviour; it does not claim to recover a missing diagnostic filename.
Implementation
The regression covers both input orders, REF on/off, live and discarded targets, nonzero symbol offsets/addends, ADDR64, ADDR32NB, SECREL, SECTION, REL32, and loader rebasing. It sits with the associative-COMDAT tests, separately from #939's insertion point.
Validation
dev@47de6bf3; no optimization/compressed-object stack included in this PR.import_export, whose export-offset assertion was separately reproduced on the unmodified upstream baseline).No proprietary Engine objects are added as fixtures. Engine-installed binaries and original inputs were not replaced. The resulting BlankProgram was not launched; no runtime ASan-reporting, farm/Wine/UBA soak, or performance result is claimed.