linker: detect duplicate exported definitions without imports#6750
Open
Lurie97 wants to merge 1 commit into
Open
linker: detect duplicate exported definitions without imports#6750Lurie97 wants to merge 1 commit into
Lurie97 wants to merge 1 commit into
Conversation
s-perron
reviewed
Jun 26, 2026
s-perron
left a comment
Collaborator
There was a problem hiding this comment.
Please add a test as well.
9cf29ef to
74eb0a5
Compare
The duplicate-export check in GetImportExportPairs() only triggers when iterating over imports. If no module imports a symbol, the linker never looks up the export table for that name, so multiple modules can each export the same function and spvtools::Link() silently accepts them instead of reporting an error. Add a standalone pass over the exports map before the import-matching loop to reject links where the same symbol name is exported by more than one module. This correctly handles LinkOnceODR symbols because they are already deduplicated into a single export entry by the preceding linkonce processing. The existing size > 1 check in the import-matching loop is now redundant and has been removed. Add a test for the case where two modules export the same symbol but neither imports it. Fixes the piglit clLinkProgram test where two modules each define get_number() with Export linkage but neither imports it. Signed-off-by: jiajia Qian <jiajia.qian@nxp.com>
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 duplicate-export check in GetImportExportPairs() only triggers when iterating over imports. If no module imports a symbol, the linker never looks up the export table for that name, so multiple modules can each export the same function and spvtools::Link() silently accepts them instead of reporting a One Definition Rule violation.
Add a standalone pass over the exports map before the import-matching loop to reject links where the same symbol name is exported by more than one module. This correctly handles LinkOnceODR symbols because they are already deduplicated into a single export entry by the preceding linkonce processing.
Fixes the piglit clLinkProgram test where two modules each define get_number() with Export linkage but neither imports it.