diff options
author | Zachary Turner <zturner@google.com> | 2017-06-01 21:52:41 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-01 21:52:41 +0000 |
commit | ebd3ae8371b4ca7b4c9c0bd62f28babaaf25a633 (patch) | |
tree | 17fdc737dd47911abd76029d670ff96b10860285 /llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp | |
parent | 678aa336fa8d0cfac176d3bd95ddb96f545bbe68 (diff) | |
download | bcm5719-llvm-ebd3ae8371b4ca7b4c9c0bd62f28babaaf25a633.tar.gz bcm5719-llvm-ebd3ae8371b4ca7b4c9c0bd62f28babaaf25a633.zip |
[CodeView] Properly align symbol records on read/write.
Object files have symbol records not aligned to any particular
boundary (e.g. 1-byte aligned), while PDB files have symbol
records padded to 4-byte aligned boundaries. Since they share
the same reading / writing code, we have to provide an option to
specify the alignment and propagate it up to the producer or
consumer who knows what the alignment is supposed to be for the
given container type.
Added a test for this by modifying the existing PDB -> YAML -> PDB
round-tripping code to round trip symbol records as well as types.
Differential Revision: https://reviews.llvm.org/D33785
llvm-svn: 304484
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp index b28ec2ff33a..bf3f83741ae 100644 --- a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp @@ -66,7 +66,11 @@ void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) { void DbiModuleDescriptorBuilder::addSymbol(CVSymbol Symbol) { Symbols.push_back(Symbol); - SymbolByteSize += Symbol.data().size(); + // Symbols written to a PDB file are required to be 4 byte aligned. The same + // is not true of object files. + assert(Symbol.length() % alignOf(CodeViewContainer::Pdb) == 0 && + "Invalid Symbol alignment!"); + SymbolByteSize += Symbol.length(); } void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) { @@ -153,7 +157,8 @@ Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter, if (auto EC = SymbolWriter.writeStreamRef(RecordsRef)) return EC; // TODO: Write C11 Line data - + assert(SymbolWriter.getOffset() % alignOf(CodeViewContainer::Pdb) == 0 && + "Invalid debug section alignment!"); for (const auto &Builder : C13Builders) { assert(Builder && "Empty C13 Fragment Builder!"); if (auto EC = Builder->commit(SymbolWriter)) @@ -179,8 +184,8 @@ void DbiModuleDescriptorBuilder::addC13Fragment( C13Builders.push_back(nullptr); this->LineInfo.push_back(std::move(Lines)); - C13Builders.push_back( - llvm::make_unique<DebugSubsectionRecordBuilder>(Frag.kind(), Frag)); + C13Builders.push_back(llvm::make_unique<DebugSubsectionRecordBuilder>( + Frag.kind(), Frag, CodeViewContainer::Pdb)); } void DbiModuleDescriptorBuilder::addC13Fragment( @@ -193,8 +198,8 @@ void DbiModuleDescriptorBuilder::addC13Fragment( C13Builders.push_back(nullptr); this->Inlinees.push_back(std::move(Inlinees)); - C13Builders.push_back( - llvm::make_unique<DebugSubsectionRecordBuilder>(Frag.kind(), Frag)); + C13Builders.push_back(llvm::make_unique<DebugSubsectionRecordBuilder>( + Frag.kind(), Frag, CodeViewContainer::Pdb)); } void DbiModuleDescriptorBuilder::setC13FileChecksums( @@ -206,5 +211,5 @@ void DbiModuleDescriptorBuilder::setC13FileChecksums( ChecksumInfo = std::move(Checksums); C13Builders[0] = llvm::make_unique<DebugSubsectionRecordBuilder>( - ChecksumInfo->kind(), *ChecksumInfo); + ChecksumInfo->kind(), *ChecksumInfo, CodeViewContainer::Pdb); } |