Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -40,6 +40,7 @@ void readGroup(); void readOutput(); void readOutputFormat(); + void readSearchDir(); std::vector Tokens; size_t Pos = 0; @@ -55,6 +56,8 @@ readOutput(); } else if (Tok == "OUTPUT_FORMAT") { readOutputFormat(); + } else if (Tok == "SEARCH_DIR") { + readSearchDir(); } else { error("unknown directive: " + Tok); } @@ -161,6 +164,13 @@ expect(")"); } +void LinkerScript::readSearchDir() { + expect("("); + StringRef Tok = next(); + Config->InputSearchPaths.push_back(Tok); + expect(")"); +} + // Entry point. The other functions or classes are private to this file. void lld::elf2::readLinkerScript(MemoryBufferRef MB) { LinkerScript(MB.getBuffer()).run(); Index: test/elf2/linkerscript.s =================================================================== --- test/elf2/linkerscript.s +++ test/elf2/linkerscript.s @@ -23,6 +23,10 @@ # RUN: ld.lld2 %t.script %t # RUN: llvm-readobj %t.out > /dev/null +# RUN: echo "SEARCH_DIR(\"/lib/foo/blah\")" > %t.script +# RUN: ld.lld2 %t.script %t +# RUN: llvm-readobj %t.out > /dev/null + # RUN: echo "FOO(BAR)" > %t.script # RUN: not ld.lld2 -o foo %t.script > %t.log 2>&1 # RUN: FileCheck -check-prefix=ERR1 %s < %t.log