[llvm] r272728 - [pdbdump] Verify TPI hash for LF_ENUM type records.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 14 15:25:07 PDT 2016
Author: ruiu
Date: Tue Jun 14 17:25:07 2016
New Revision: 272728
URL: http://llvm.org/viewvc/llvm-project?rev=272728&view=rev
Log:
[pdbdump] Verify TPI hash for LF_ENUM type records.
Modified:
llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=272728&r1=272727&r2=272728&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp Tue Jun 14 17:25:07 2016
@@ -73,15 +73,31 @@ TpiStream::~TpiStream() {}
// Currently we only verify SRC_LINE records.
static Error verifyTIHash(const codeview::CVType &Rec, uint32_t Expected,
uint32_t NumHashBuckets) {
+ using namespace codeview;
+
ArrayRef<uint8_t> D = Rec.Data;
- if (Rec.Type == codeview::LF_UDT_SRC_LINE ||
- Rec.Type == codeview::LF_UDT_MOD_SRC_LINE) {
- uint32_t Hash =
- hashStringV1(StringRef((const char *)D.data(), 4)) % NumHashBuckets;
- if (Hash != Expected)
+ uint32_t Hash;
+
+ switch (Rec.Type) {
+ case LF_UDT_SRC_LINE:
+ case LF_UDT_MOD_SRC_LINE:
+ Hash = hashStringV1(StringRef((const char *)D.data(), 4));
+ break;
+ case LF_ENUM: {
+ ErrorOr<EnumRecord> Enum = EnumRecord::deserialize(TypeRecordKind::Enum, D);
+ if (Enum.getError())
return make_error<RawError>(raw_error_code::corrupt_file,
"Corrupt TPI hash table.");
+ Hash = hashStringV1(Enum->getName());
+ break;
}
+ default:
+ return Error::success();
+ }
+
+ if ((Hash % NumHashBuckets) != Expected)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Corrupt TPI hash table.");
return Error::success();
}
More information about the llvm-commits
mailing list