[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
This commit is contained in:
Reid Kleckner 2021-05-20 16:19:20 -07:00
parent 748db5bfac
commit e73203a561
2 changed files with 15 additions and 9 deletions

View file

@ -54,7 +54,8 @@ public:
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 @@ public:
// 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;

View file

@ -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'