diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index ddd82663eee3..1939424eb8b6 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/StringSaver.h" +#include using namespace llvm; using namespace lld; @@ -138,8 +139,12 @@ void LinkerScript::expect(StringRef Expect) { error(Expect + " expected, but got " + Tok); } +static bool isDOSAbsolutePath(StringRef S) { + return isalpha(S[0]) && S.substr(1).startswith(":\\"); +} + void LinkerScript::addFile(StringRef S) { - if (S.startswith("/")) { + if (S.startswith("/") || isDOSAbsolutePath(S)) { Driver->addFile(S); } else if (S.startswith("=")) { if (Config->Sysroot.empty())