[lld] e73203a - [PDB] Check the type server guid when ghashing
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu May 20 16:36:20 PDT 2021
Author: Reid Kleckner
Date: 2021-05-20T16:36:12-07:00
New Revision: e73203a561b7624a6d1c224f40d07c5edc73756f
URL: https://github.com/llvm/llvm-project/commit/e73203a561b7624a6d1c224f40d07c5edc73756f
DIFF: https://github.com/llvm/llvm-project/commit/e73203a561b7624a6d1c224f40d07c5edc73756f.diff
LOG: [PDB] Check the type server guid when ghashing
Previously we simply didn't check this. Prereq to make the test suite
pass with ghash enabled by default.
Differential Revision: https://reviews.llvm.org/D102885
Added:
Modified:
lld/COFF/DebugTypes.cpp
lld/test/COFF/pdb-type-server-invalid-signature.yaml
Removed:
################################################################################
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index fedcb054540f8..69b031e9a2d5a 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -54,7 +54,8 @@ class TypeServerSource : public TpiSource {
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 @@ class TypeServerSource : public TpiSource {
// 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 @@ Expected<TypeServerSource *> UseTypeServerSource::getTypeServerSource() {
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 @@ Error UseTypeServerSource::mergeDebugT(TypeMerger *m) {
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;
diff --git a/lld/test/COFF/pdb-type-server-invalid-signature.yaml b/lld/test/COFF/pdb-type-server-invalid-signature.yaml
index 45713292cd2b7..87c4367684845 100644
--- a/lld/test/COFF/pdb-type-server-invalid-signature.yaml
+++ b/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'
More information about the llvm-commits
mailing list