Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lld/ELF/DriverUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ std::optional<std::string> elf::findFromSearchPaths(StringRef path) {
// search paths.
std::optional<std::string> elf::searchLibraryBaseName(StringRef name) {
for (StringRef dir : config->searchPaths) {
if (!config->isStatic)
if (!(config->isStatic || config->relocatable))
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".so"))
return s;
if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a"))
Expand Down
6 changes: 6 additions & 0 deletions lld/test/ELF/libsearch.s
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
// RUN: ld.lld -o %t3 %t.o -L%t.dir -lls
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s

// Should use static when dynamic exists in search path
// RUN: ld.lld --relocatable -o %t3 %t.o -L%t.dir -lls
// RUN: llvm-readelf -s -h %t3 | FileCheck --check-prefix=RELOCATABLE %s
// RELOCATABLE: Type: REL (Relocatable file)
// RELOCATABLE: [[#]] _static

// Check for library search order
// RUN: mkdir -p %t.dir2
// RUN: cp %t.dir/libls.a %t.dir2
Expand Down