Index: COFF/PDB.cpp =================================================================== --- COFF/PDB.cpp +++ COFF/PDB.cpp @@ -351,6 +351,12 @@ static Expected> 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> MBOrErr = MemoryBuffer::getFile( TSPath, /*FileSize=*/-1, /*RequiresNullTerminator=*/false); if (!MBOrErr)