This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Change the search order for dependent libraries
ClosedPublic

Authored by phosek on Jan 28 2022, 11:18 AM.

Details

Summary

When processing dependent libraries, if there's a directory of the same
name as the library being searched for, either in the current directory
or earlier in the search order, LLD will try to open it and report an
error. This is because LLD uses file existence check. To address this
issue we reverse the order, searching the library by basename first
and only considering search paths later, and current directory last.

Diff Detail

Event Timeline

phosek created this revision.Jan 28 2022, 11:18 AM
phosek requested review of this revision.Jan 28 2022, 11:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2022, 11:18 AM
phosek retitled this revision from [ELF] Don't consider directories of the same name as libraries to [ELF] Change the search order for dependent libraries.Jan 28 2022, 11:19 AM
phosek edited the summary of this revision. (Show Details)
MaskRay accepted this revision.Jan 28 2022, 11:21 AM
MaskRay added a subscriber: bd1976llvm.

Thanks! There is some optimization we can make, e.g. if there is no path separator, don't bother with searchLibraryBaseName, but it may not justify the added code complexity.
@bd1976llvm would like to see smaller amount of code on this feature IIRC.

This revision is now accepted and ready to land.Jan 28 2022, 11:21 AM
This revision was automatically updated to reflect the committed changes.