fix: activate --as-needed shared libraries for weak symbol references#1672
Open
PritamP20 wants to merge 2 commits intowild-linker:mainfrom
Open
fix: activate --as-needed shared libraries for weak symbol references#1672PritamP20 wants to merge 2 commits intowild-linker:mainfrom
PritamP20 wants to merge 2 commits intowild-linker:mainfrom
Conversation
libwild/src/resolution.rs
Outdated
| // file got loaded. TODO: If the file is a non-archived object, or possibly even if | ||
| // it's an archived object that we've already decided to load, then we could skip | ||
| // this. | ||
| // The symbol is weak and the target is an archive (not a shared library). We |
Member
There was a problem hiding this comment.
It might not be an archive. It could also be a regular object file right?
Contributor
Author
There was a problem hiding this comment.
Yeah, it can be a regular object file too I'll fix the comment. The main thing this block handles is the case where a weak reference to a shared library wasn't activating it for --as-needed, so it was getting dropped from DT_NEEDED
Member
|
Do the tests pass for you locally? If they do, then you might want to look at your |
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.
When
--as-neededis active, Wild was dropping shared libraries fromDT_NEEDEDif the only reference to one of their symbols was weak. This diverges from GNU ld and lld, which both include the library in this case.The fix is in
resolve_symbolinlibwild/src/resolution.rs. Previously,try_request_file_id(which marks a library as needed) was only called for strong references. The condition now also activates shared libraries for weak references, while preserving the existing behaviour for archives weak references to archive members should still not force them to be pulled in.Fixes #1665
Tests
Mold test
as-needed-weak.shnow passes removed frommiscskip group: