diff options
author | Rui Ueyama <ruiu@google.com> | 2016-05-17 23:07:48 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-05-17 23:07:48 +0000 |
commit | 8dc18c5f451a86d95261d434a01ea4393df2fc4a (patch) | |
tree | b25c5a6fe3024179f360dc4f2bc2dc400cb7d146 /llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp | |
parent | c675cfa8a976e2cd6881b32c84051968115e4221 (diff) | |
download | llvm-8dc18c5f451a86d95261d434a01ea4393df2fc4a.zip llvm-8dc18c5f451a86d95261d434a01ea4393df2fc4a.tar.gz llvm-8dc18c5f451a86d95261d434a01ea4393df2fc4a.tar.bz2 |
pdbdump: Print out more strcutures.
I don't yet fully understand the meaning of these data strcutures,
but at least it seems that their sizes and types are correct.
With this change, we can read publics streams till end.
Differential Revision: http://reviews.llvm.org/D20343
llvm-svn: 269861
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp index dbdb1c5..9a2b142c 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp @@ -53,7 +53,7 @@ struct PublicsStream::HeaderInfo { ulittle16_t ISectThunkTable; char Padding[2]; ulittle32_t OffThunkTable; - ulittle32_t NumSects; + ulittle32_t NumSections; }; @@ -74,6 +74,15 @@ struct PublicsStream::HRFile { ulittle32_t CRef; }; +// This struct is defined as "SO" in langapi/include/pdb.h. +namespace { +struct SectionOffset { + ulittle32_t Off; + ulittle16_t Isect; + char Padding[2]; +}; +} + PublicsStream::PublicsStream(PDBFile &File, uint32_t StreamNum) : StreamNum(StreamNum), Stream(StreamNum, File) {} @@ -123,10 +132,37 @@ Error PublicsStream::reload() { for (uint8_t B : Bitmap) NumBuckets += countPopulation(B); - // Buckets follow. - if (Reader.bytesRemaining() < NumBuckets * sizeof(uint32_t)) + // We don't yet understand the following data structures completely, + // but we at least know the types and sizes. Here we are trying + // to read the stream till end so that we at least can detect + // corrupted streams. + + // Hash buckets follow. + HashBuckets.resize(NumBuckets); + if (auto EC = Reader.readArray<uint32_t>(HashBuckets)) return make_error<RawError>(raw_error_code::corrupt_file, "Hash buckets corrupted."); + // Something called "address map" follows. + AddressMap.resize(Header->AddrMap / sizeof(uint32_t)); + if (auto EC = Reader.readArray<uint32_t>(AddressMap)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Could not read an address map."); + + // Something called "thunk map" follows. + ThunkMap.resize(Header->NumThunks); + if (auto EC = Reader.readArray<uint32_t>(ThunkMap)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Could not read a thunk map."); + + // Something called "section map" follows. + std::vector<SectionOffset> SectionMap(Header->NumSections); + if (auto EC = Reader.readArray<SectionOffset>(SectionMap)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Could not read a section map."); + + if (Reader.bytesRemaining() > 0) + return make_error<RawError>(raw_error_code::corrupt_file, + "Corrupted publics stream."); return Error::success(); } |