summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2018-09-28 21:53:40 +0000
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>2018-09-28 21:53:40 +0000
commit91def5cc6a008ef16f8a858f872f1af885326527 (patch)
treebeca26b4991185b9f4a02b223b12c577332be00d
parent3e709d5f785aa67f93e33c49a94b2806e4456bd3 (diff)
downloadbcm5719-llvm-91def5cc6a008ef16f8a858f872f1af885326527.tar.gz
bcm5719-llvm-91def5cc6a008ef16f8a858f872f1af885326527.zip
[LLD][COFF] Fix pdb loading when the path points to a removable device
Differential Revision: https://reviews.llvm.org/D52666 llvm-svn: 343366
-rw-r--r--lld/COFF/PDB.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index e25fb4ec5cf..80f02191b94 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -351,6 +351,12 @@ Expected<const CVIndexMap&> PDBLinker::mergeDebugT(ObjFile *File,
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)
OpenPOWER on IntegriCloud