[lld] r343366 - [LLD][COFF] Fix pdb loading when the path points to a removable device

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 14:53:40 PDT 2018


Author: aganea
Date: Fri Sep 28 14:53:40 2018
New Revision: 343366

URL: http://llvm.org/viewvc/llvm-project?rev=343366&view=rev
Log:
[LLD][COFF] Fix pdb loading when the path points to a removable device

Differential Revision: https://reviews.llvm.org/D52666

Modified:
    lld/trunk/COFF/PDB.cpp

Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=343366&r1=343365&r2=343366&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Fri Sep 28 14:53:40 2018
@@ -351,6 +351,12 @@ Expected<const CVIndexMap&> PDBLinker::m
 
 static Expected<std::unique_ptr<pdb::NativeSession>>
 tryToLoadPDB(const GUID &GuidFromObj, StringRef TSPath) {
+  // Ensure the file exists before anything else. We want to return ENOENT,
+  // "file not found", even if the path points to a removable device (in which
+  // case the return message would be EAGAIN, "resource unavailable try again")
+  if (!llvm::sys::fs::exists(TSPath))
+    return errorCodeToError(std::error_code(ENOENT, std::generic_category()));
+
   ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr = MemoryBuffer::getFile(
       TSPath, /*FileSize=*/-1, /*RequiresNullTerminator=*/false);
   if (!MBOrErr)




More information about the llvm-commits mailing list