diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index eeb6dc278be0..223218f40843 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -886,8 +886,9 @@ void ScriptParser::readPhdrs() { void ScriptParser::readSearchDir() { expect("("); + StringRef Tok = next(); if (!Config->Nostdlib) - Config->SearchPaths.push_back(next()); + Config->SearchPaths.push_back(Tok); expect(")"); } diff --git a/lld/test/ELF/libsearch.s b/lld/test/ELF/libsearch.s index 98512cdfd636..309fa996b550 100644 --- a/lld/test/ELF/libsearch.s +++ b/lld/test/ELF/libsearch.s @@ -88,7 +88,9 @@ // -nostdlib // RUN: echo 'SEARCH_DIR(' %t.dir ')' > %t.script // RUN: ld.lld -o %t3 %t.o -script %t.script -lls -// RUN: not ld.lld -o %t3 %t.o -script %t.script -lls -nostdlib +// RUN: not ld.lld -o %t3 %t.o -script %t.script -lls -nostdlib \ +// RUN: 2>&1 | FileCheck --check-prefix=NOSTDLIB %s +// NOSTDLIB: unable to find library -lls .globl _start,_bar _start: