[PATCH] D102885: [PDB] Check the type server guid when ghashing

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 16:36:23 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe73203a561b7: [PDB] Check the type server guid when ghashing (authored by rnk).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102885/new/

https://reviews.llvm.org/D102885

Files:
  lld/COFF/DebugTypes.cpp
  lld/test/COFF/pdb-type-server-invalid-signature.yaml


Index: lld/test/COFF/pdb-type-server-invalid-signature.yaml
===================================================================
--- lld/test/COFF/pdb-type-server-invalid-signature.yaml
+++ lld/test/COFF/pdb-type-server-invalid-signature.yaml
@@ -3,6 +3,7 @@
 # RUN: cd %S/Inputs
 # RUN: yaml2obj %s -o %t.obj
 # RUN: lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s
+# RUN: lld-link %t.obj -out:%t.exe -debug:ghash -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s
 # RUN: cd %S
 
 # CHECK: warning: Cannot use debug info for '{{.*}}.obj'
Index: lld/COFF/DebugTypes.cpp
===================================================================
--- lld/COFF/DebugTypes.cpp
+++ lld/COFF/DebugTypes.cpp
@@ -54,7 +54,8 @@
     auto expectedInfo = file.getPDBInfoStream();
     if (!expectedInfo)
       return;
-    auto it = mappings.emplace(expectedInfo->getGuid(), this);
+    Guid = expectedInfo->getGuid();
+    auto it = mappings.emplace(Guid, this);
     assert(it.second);
     (void)it;
   }
@@ -71,6 +72,9 @@
   // TpiSource for IPI stream.
   TypeServerIpiSource *ipiSrc = nullptr;
 
+  // The PDB signature GUID.
+  codeview::GUID Guid;
+
   static std::map<codeview::GUID, TypeServerSource *> mappings;
 };
 
@@ -429,6 +433,15 @@
       return createFileError(tsPath, std::move(*pdb->loadErr));
 
     tsSrc = (TypeServerSource *)pdb->debugTypesObj;
+
+    // Just because a file with a matching name was found and it was an actual
+    // PDB file doesn't mean it matches.  For it to match the InfoStream's GUID
+    // must match the GUID specified in the TypeServer2 record.
+    if (tsSrc->Guid != tsId) {
+      return createFileError(tsPath,
+                             make_error<pdb::PDBError>(
+                                 pdb::pdb_error_code::signature_out_of_date));
+    }
   }
   return tsSrc;
 }
@@ -443,14 +456,6 @@
   if (!expectedInfo)
     return expectedInfo.takeError();
 
-  // Just because a file with a matching name was found and it was an actual
-  // PDB file doesn't mean it matches.  For it to match the InfoStream's GUID
-  // must match the GUID specified in the TypeServer2 record.
-  if (expectedInfo->getGuid() != typeServerDependency.getGuid())
-    return createFileError(
-        typeServerDependency.getName(),
-        make_error<pdb::PDBError>(pdb::pdb_error_code::signature_out_of_date));
-
   // Reuse the type index map of the type server.
   tpiMap = (*tsSrc)->tpiMap;
   ipiMap = (*tsSrc)->ipiMap;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102885.346889.patch
Type: text/x-patch
Size: 2505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210520/276f1a19/attachment.bin>


More information about the llvm-commits mailing list