diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 19:17:14 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 19:17:14 +0000 | 
| commit | db17bf38c59bc172953ed66cfe1b10c03c6bc383 (patch) | |
| tree | 2712281fec99b99c2fcafd5b46439dfdd93261aa /contrib/llvm/lib/DebugInfo/PDB/Native | |
| parent | 686fb94a00297bf9ff49d93b948925552a2ce8e0 (diff) | |
| parent | 7ab83427af0f77b59941ceba41d509d7d097b065 (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/lib/DebugInfo/PDB/Native')
5 files changed, 22 insertions, 16 deletions
diff --git a/contrib/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/contrib/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp index 22c2ef31bd71..396dffaa68b1 100644 --- a/contrib/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp +++ b/contrib/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp @@ -10,6 +10,7 @@  #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h"  #include "llvm/ADT/ArrayRef.h" +#include "llvm/BinaryFormat/COFF.h"  #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"  #include "llvm/DebugInfo/MSF/MSFBuilder.h"  #include "llvm/DebugInfo/MSF/MSFCommon.h" @@ -19,7 +20,6 @@  #include "llvm/DebugInfo/PDB/Native/RawError.h"  #include "llvm/Support/BinaryItemStream.h"  #include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/COFF.h"  using namespace llvm;  using namespace llvm::codeview; @@ -38,12 +38,12 @@ template <> struct BinaryItemTraits<CVSymbol> {  static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize,                                              uint32_t C13Size) { -  uint32_t Size = sizeof(uint32_t); // Signature -  Size += SymbolByteSize;           // Symbol Data -  Size += 0;                        // TODO: Layout.C11Bytes -  Size += C13Size;                  // C13 Debug Info Size -  Size += sizeof(uint32_t);         // GlobalRefs substream size (always 0) -  Size += 0;                        // GlobalRefs substream bytes +  uint32_t Size = sizeof(uint32_t);   // Signature +  Size += alignTo(SymbolByteSize, 4); // Symbol Data +  Size += 0;                          // TODO: Layout.C11Bytes +  Size += C13Size;                    // C13 Debug Info Size +  Size += sizeof(uint32_t);           // GlobalRefs substream size (always 0) +  Size += 0;                          // GlobalRefs substream bytes    return Size;  } @@ -156,6 +156,8 @@ Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter,      BinaryStreamRef RecordsRef(Records);      if (auto EC = SymbolWriter.writeStreamRef(RecordsRef))        return EC; +    if (auto EC = SymbolWriter.padToAlignment(4)) +      return EC;      // TODO: Write C11 Line data      assert(SymbolWriter.getOffset() % alignOf(CodeViewContainer::Pdb) == 0 &&             "Invalid debug section alignment!"); diff --git a/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp b/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp index 320b11dc5cab..24322d942fac 100644 --- a/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp +++ b/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp @@ -216,10 +216,12 @@ FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {  void DbiStream::visitSectionContributions(      ISectionContribVisitor &Visitor) const { -  if (SectionContribVersion == DbiSecContribVer60) { +  if (!SectionContribs.empty()) { +    assert(SectionContribVersion == DbiSecContribVer60);      for (auto &SC : SectionContribs)        Visitor.visit(SC); -  } else if (SectionContribVersion == DbiSecContribV2) { +  } else if (!SectionContribs2.empty()) { +    assert(SectionContribVersion == DbiSecContribV2);      for (auto &SC : SectionContribs2)        Visitor.visit(SC);    } diff --git a/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp index 55c20fdb9af6..355c7b57f4d1 100644 --- a/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp +++ b/contrib/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp @@ -10,6 +10,7 @@  #include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h"  #include "llvm/ADT/ArrayRef.h" +#include "llvm/BinaryFormat/COFF.h"  #include "llvm/DebugInfo/MSF/MSFBuilder.h"  #include "llvm/DebugInfo/MSF/MappedBlockStream.h"  #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h" @@ -17,7 +18,6 @@  #include "llvm/DebugInfo/PDB/Native/RawError.h"  #include "llvm/Object/COFF.h"  #include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/COFF.h"  using namespace llvm;  using namespace llvm::codeview; diff --git a/contrib/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp b/contrib/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp index c4ff30011a17..4186f2eb6ba0 100644 --- a/contrib/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp +++ b/contrib/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp @@ -90,14 +90,14 @@ Error ModuleDebugStreamRef::commit() { return Error::success(); }  Expected<codeview::DebugChecksumsSubsectionRef>  ModuleDebugStreamRef::findChecksumsSubsection() const { +  codeview::DebugChecksumsSubsectionRef Result;    for (const auto &SS : subsections()) {      if (SS.kind() != DebugSubsectionKind::FileChecksums)        continue; -    codeview::DebugChecksumsSubsectionRef Result;      if (auto EC = Result.initialize(SS.getRecordData()))        return std::move(EC);      return Result;    } -  return make_error<RawError>(raw_error_code::no_entry); +  return Result;  } diff --git a/contrib/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp b/contrib/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp index 58202577672a..091ac67035dc 100644 --- a/contrib/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp +++ b/contrib/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp @@ -105,10 +105,12 @@ Error PublicsStream::reload() {                                             "Could not read a thunk map."));    // Something called "section map" follows. -  if (auto EC = Reader.readArray(SectionOffsets, Header->NumSections)) -    return joinErrors(std::move(EC), -                      make_error<RawError>(raw_error_code::corrupt_file, -                                           "Could not read a section map.")); +  if (Reader.bytesRemaining() > 0) { +    if (auto EC = Reader.readArray(SectionOffsets, Header->NumSections)) +      return joinErrors(std::move(EC), +                        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,  | 
