[PATCH] D52666: [LLD][COFF] Fix pdb loading when the path points to a removable device

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 11:34:55 PDT 2018


aganea created this revision.
aganea added reviewers: thakis, zturner.
Herald added a subscriber: llvm-commits.

As described here <https://bugs.chromium.org/p/chromium/issues/detail?id=889990>, this patch fixes the case where an OBJ has a reference to a PDB path which happens to map locally to a removable device, drive which has no media inserted at the time of the link. In that case, the first attempt to load the PDB returns "resource unavailable try again". This prevents retrying the PDB load with the OBJ's path.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D52666

Files:
  COFF/PDB.cpp


Index: COFF/PDB.cpp
===================================================================
--- COFF/PDB.cpp
+++ COFF/PDB.cpp
@@ -351,6 +351,12 @@
 
 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52666.167519.patch
Type: text/x-patch
Size: 776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180928/4adc6e5a/attachment.bin>


More information about the llvm-commits mailing list