diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 36d4e3b50fa5..6c0fd3139e87 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -290,7 +290,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) { // Add a given library by searching it from input search paths. void LinkerDriver::addLibrary(StringRef name) { if (Optional path = searchLibrary(name)) - addFile(*path, /*withLOption=*/true); + addFile(saver().save(*path), /*withLOption=*/true); else error("unable to find library -l" + name, ErrorTag::LibNotFound, {name}); } diff --git a/lld/test/ELF/print-archive-stats.s b/lld/test/ELF/print-archive-stats.s index eb1ce5e4768b..61e571e352a5 100644 --- a/lld/test/ELF/print-archive-stats.s +++ b/lld/test/ELF/print-archive-stats.s @@ -21,12 +21,12 @@ # RUN: ld.lld a.o %t/weak.a 1.a --print-archive-stats=- -o /dev/null | diff a.txt - ## The second 1.a has 0 fetched member. -# RUN: ld.lld a.o %t/weak.a 1.a 1.a --print-archive-stats=- -o /dev/null | \ +# RUN: ld.lld a.o %t/weak.a -L. -l:1.a -l:1.a --print-archive-stats=- -o /dev/null | \ # RUN: FileCheck --check-prefix=CHECK2 %s # CHECK2: members extracted archive # CHECK2-NEXT: 1 0 {{.*}}weak.a -# CHECK2-NEXT: 3 2 1.a -# CHECK2-NEXT: 3 0 1.a +# CHECK2-NEXT: 3 2 {{.*}}1.a +# CHECK2-NEXT: 3 0 {{.*}}1.a # RUN: not ld.lld -shared a.o --print-archive-stats=/ -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s # ERR: error: --print-archive-stats=: cannot open /: {{.*}}