diff options
author | Wolfgang Pieb <Wolfgang.Pieb@sony.com> | 2018-05-10 20:02:34 +0000 |
---|---|---|
committer | Wolfgang Pieb <Wolfgang.Pieb@sony.com> | 2018-05-10 20:02:34 +0000 |
commit | f2b6915ed46ebfc28f450b0fa0027b6666ebcb11 (patch) | |
tree | 15487910ebf87f90c4735bd81506c8d3f1aca116 /llvm/lib | |
parent | f489e2bfef7fca1959ad7e5cb223edc13cc1bc18 (diff) | |
download | bcm5719-llvm-f2b6915ed46ebfc28f450b0fa0027b6666ebcb11.tar.gz bcm5719-llvm-f2b6915ed46ebfc28f450b0fa0027b6666ebcb11.zip |
[DWARF] Fixing a bug in DWARF v5 string offsets tables where the length encoded the contribution
length excluding the table header. Instead it must encode the contribution length minus the length
field itself.
Reviewer: JDevliegehere
Differential Revision: https://reviews.llvm.org/D45922
llvm-svn: 332030
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 9 |
3 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp index a3ea96b72ba..f3a3cbdbc74 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -36,9 +36,9 @@ void DwarfFile::emitStringOffsetsTableHeader(MCSection *Section) { // FIXME: DWARF64 // We are emitting the header for a contribution to the string offsets // table. The header consists of an entry with the contribution's - // size (not including the size of the header), the DWARF version and + // size (not including the size of the length field), the DWARF version and // 2 bytes of padding. - Asm->emitInt32(StrPool.size() * EntrySize); + Asm->emitInt32(StrPool.size() * EntrySize + 4); Asm->emitInt16(Asm->getDwarfVersion()); Asm->emitInt16(0); // Define the symbol that marks the start of the contribution. It is diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 6fbe55bbdc7..8488fe8ced7 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -172,7 +172,11 @@ static void dumpDWARFv5StringOffsetsSection( OS << (ContributionHeader - Offset) << "\n"; } OS << format("0x%8.8x: ", (uint32_t)ContributionHeader); - OS << "Contribution size = " << Contribution->Size + // In DWARF v5 the contribution size in the descriptor does not equal + // the originally encoded length (it does not contain the length of the + // version field and the padding, a total of 4 bytes). Add them back in + // for reporting. + OS << "Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4)) << ", Format = " << (Format == DWARF32 ? "DWARF32" : "DWARF64") << ", Version = " << Version << "\n"; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index d54275d302f..2d456b4b530 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -517,7 +517,9 @@ parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { uint64_t Size = DA.getU64(&Offset); uint8_t Version = DA.getU16(&Offset); (void)DA.getU16(&Offset); // padding - return StrOffsetsContributionDescriptor(Offset, Size, Version, DWARF64); + // The encoded length includes the 2-byte version field and the 2-byte + // padding, so we need to subtract them out when we populate the descriptor. + return StrOffsetsContributionDescriptor(Offset, Size - 4, Version, DWARF64); //return Optional<StrOffsetsContributionDescriptor>(Descriptor); } @@ -532,7 +534,10 @@ parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { return Optional<StrOffsetsContributionDescriptor>(); uint8_t Version = DA.getU16(&Offset); (void)DA.getU16(&Offset); // padding - return StrOffsetsContributionDescriptor(Offset, ContributionSize, Version, DWARF32); + // The encoded length includes the 2-byte version field and the 2-byte + // padding, so we need to subtract them out when we populate the descriptor. + return StrOffsetsContributionDescriptor(Offset, ContributionSize - 4, Version, + DWARF32); //return Optional<StrOffsetsContributionDescriptor>(Descriptor); } |