summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-03-13 12:22:09 -0400
committerTom Stellard <tstellar@redhat.com>2020-04-16 12:05:11 -0700
commit6196695ec5819c0df7efe3fecca5c4ef9ea80b1c (patch)
treee1d5605bb16ca9b7ef3886e07ee1dbf80f7d0869 /llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
parentcc6e51a1414989ff1c2dcab30c00ac10ea19afa1 (diff)
downloadbcm5719-llvm-6196695ec5819c0df7efe3fecca5c4ef9ea80b1c.tar.gz
bcm5719-llvm-6196695ec5819c0df7efe3fecca5c4ef9ea80b1c.zip
[CodeView] Align type records on 4-bytes when emitting PDBs
When emitting PDBs, the TypeStreamMerger class is used to merge .debug$T records from the input .OBJ files into the output .PDB stream. Records in .OBJs are not required to be aligned on 4-bytes, and "The Netwide Assembler 2.14" generates non-aligned records. When compiling with -DLLVM_ENABLE_ASSERTIONS=ON, an assert was triggered in MergingTypeTableBuilder when non-ghash merging was used. With ghash merging there was no assert. As a result, LLD could potentially generate a non-aligned TPI stream. We now align records on 4-bytes when record indices are remapped, in TypeStreamMerger::remapIndices(). Differential Revision: https://reviews.llvm.org/D75081 (cherry picked from commit a7325298e1f311b383b8ce5ba8e2d3698fef472a)
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
index 4f10f8524a9..51a1f0a544e 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
@@ -44,6 +44,9 @@ void TpiStreamBuilder::setVersionHeader(PdbRaw_TpiVer Version) {
void TpiStreamBuilder::addTypeRecord(ArrayRef<uint8_t> Record,
Optional<uint32_t> Hash) {
// If we just crossed an 8KB threshold, add a type index offset.
+ assert(((Record.size() & 3) == 0) &&
+ "The type record's size is not a multiple of 4 bytes which will "
+ "cause misalignment in the output TPI stream!");
size_t NewSize = TypeRecordBytes + Record.size();
constexpr size_t EightKB = 8 * 1024;
if (NewSize / EightKB > TypeRecordBytes / EightKB || TypeRecords.empty()) {
@@ -153,8 +156,11 @@ Error TpiStreamBuilder::commit(const msf::MSFLayout &Layout,
return EC;
for (auto Rec : TypeRecords) {
- assert(!Rec.empty()); // An empty record will not write anything, but it
- // would shift all offsets from here on.
+ assert(!Rec.empty() && "Attempting to write an empty type record shifts "
+ "all offsets in the TPI stream!");
+ assert(((Rec.size() & 3) == 0) &&
+ "The type record's size is not a multiple of 4 bytes which will "
+ "cause misalignment in the output TPI stream!");
if (auto EC = Writer.writeBytes(Rec))
return EC;
}
OpenPOWER on IntegriCloud