diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-06-02 18:20:20 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-06-02 18:20:20 +0000 |
| commit | 90db78816b9cc285254b8a4d8fcf5c0499dc2dad (patch) | |
| tree | f7a7513d8fa11addb8583b293eb75342b61b8ca8 /llvm/lib/DebugInfo | |
| parent | c5f6a9df5f2a9bea3a69cbc01c3724d3cc606246 (diff) | |
| download | bcm5719-llvm-90db78816b9cc285254b8a4d8fcf5c0499dc2dad.tar.gz bcm5719-llvm-90db78816b9cc285254b8a4d8fcf5c0499dc2dad.zip | |
pdbdump: print out COFF section headers.
Unlike other sections that can grow to any size, the COFF section header
stream has maximum length because each record is fixed size and the COFF
file format limits the maximum number of sections. So I decided to not
create a specific stream class for it. Instead, I added a member function
to DbiStream class which returns a vector of COFF headers.
Differential Revision: http://reviews.llvm.org/D20717
llvm-svn: 271557
Diffstat (limited to 'llvm/lib/DebugInfo')
| -rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp index 96a68b6caa6..8c46957706e 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp @@ -6,6 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" #include "llvm/DebugInfo/CodeView/StreamArray.h" @@ -18,6 +19,7 @@ #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" +#include "llvm/Object/COFF.h" using namespace llvm; using namespace llvm::codeview; @@ -180,7 +182,8 @@ Error DbiStream::reload() { if (auto EC = initializeSectionContributionData()) return EC; - + if (auto EC = initializeSectionHeadersData()) + return EC; if (auto EC = initializeSectionMapData()) return EC; @@ -244,6 +247,11 @@ PDB_Machine DbiStream::getMachineType() const { return static_cast<PDB_Machine>(Machine); } +codeview::FixedStreamArray<object::coff_section> +DbiStream::getSectionHeaders() { + return SectionHeaders; +} + ArrayRef<ModuleInfoEx> DbiStream::modules() const { return ModuleInfos; } codeview::FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const { return SectionMap; @@ -274,6 +282,24 @@ Error DbiStream::initializeSectionContributionData() { "Unsupported DBI Section Contribution version"); } +// Initializes this->SectionHeaders. +Error DbiStream::initializeSectionHeadersData() { + uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::SectionHdr); + SectionHeaderStream.reset(new MappedBlockStream(StreamNum, Pdb)); + + size_t StreamLen = SectionHeaderStream->getLength(); + if (StreamLen % sizeof(object::coff_section)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Corrupted section header stream."); + + size_t NumSections = StreamLen / sizeof(object::coff_section); + codeview::StreamReader Reader(*SectionHeaderStream); + if (auto EC = Reader.readArray(SectionHeaders, NumSections)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Could not read a bitmap."); + return Error::success(); +} + Error DbiStream::initializeSectionMapData() { StreamReader SMReader(SecMapSubstream); const SecMapHeader *Header; |

