[PATCH] D36334: [lld] Write the PDB absolute path to the debug directory header

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 11:49:32 PDT 2017


zturner created this revision.

This matches the behavior of MSVC


https://reviews.llvm.org/D36334

Files:
  lld/COFF/Writer.cpp


Index: lld/COFF/Writer.cpp
===================================================================
--- lld/COFF/Writer.cpp
+++ lld/COFF/Writer.cpp
@@ -78,8 +78,10 @@
 };
 
 class CVDebugRecordChunk : public Chunk {
+  SmallString<128> PDBAbsPath;
+
   size_t getSize() const override {
-    return sizeof(codeview::DebugInfo) + Config->PDBPath.size() + 1;
+    return sizeof(codeview::DebugInfo) + PDBAbsPath.size() + 1;
   }
 
   void writeTo(uint8_t *B) const override {
@@ -91,12 +93,18 @@
 
     // variable sized field (PDB Path)
     auto *P = reinterpret_cast<char *>(B + OutputSectionOff + sizeof(*DI));
-    if (!Config->PDBPath.empty())
-      memcpy(P, Config->PDBPath.data(), Config->PDBPath.size());
-    P[Config->PDBPath.size()] = '\0';
+    if (!PDBAbsPath.empty())
+      memcpy(P, PDBAbsPath.data(), PDBAbsPath.size());
+    P[PDBAbsPath.size()] = '\0';
   }
 
 public:
+  CVDebugRecordChunk() {
+    PDBAbsPath = Config->PDBPath;
+    if (!PDBAbsPath.empty())
+      llvm::sys::fs::make_absolute(PDBAbsPath);
+  }
+
   mutable codeview::DebugInfo *DI = nullptr;
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36334.109793.patch
Type: text/x-patch
Size: 1083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170804/e4bc73fe/attachment.bin>


More information about the llvm-commits mailing list