diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include using namespace llvm; @@ -114,9 +115,9 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) { uint64_t Offset = 0; - // Only version 7 is supported at this moment. + // Only version 7 and 8 are supported at this moment. Version = Data.getU32(&Offset); - if (Version != 7) + if (Version != 7 && Version != 8) return false; CuListOffset = Data.getU32(&Offset); @@ -166,25 +167,26 @@ // for both a string and a CU vector. uint32_t SymTableSize = (ConstantPoolOffset - SymbolTableOffset) / 8; SymbolTable.reserve(SymTableSize); - uint32_t CuVectorsTotal = 0; + std::set CUOffsets; for (uint32_t i = 0; i < SymTableSize; ++i) { uint32_t NameOffset = Data.getU32(&Offset); uint32_t CuVecOffset = Data.getU32(&Offset); SymbolTable.push_back({NameOffset, CuVecOffset}); if (NameOffset || CuVecOffset) - ++CuVectorsTotal; + CUOffsets.insert(CuVecOffset); } // The constant pool. CU vectors are stored first, followed by strings. // The first value is the number of CU indices in the vector. Each subsequent // value is the index and symbol attributes of a CU in the CU list. - for (uint32_t i = 0; i < CuVectorsTotal; ++i) { + for (auto CUOffset : CUOffsets) { + Offset = ConstantPoolOffset + CUOffset; ConstantPoolVectors.emplace_back(0, SmallVector()); auto &Vec = ConstantPoolVectors.back(); Vec.first = Offset - ConstantPoolOffset; uint32_t Num = Data.getU32(&Offset); - for (uint32_t j = 0; j < Num; ++j) + for (uint32_t J = 0; J < Num; ++J) Vec.second.push_back(Data.getU32(&Offset)); } diff --git a/llvm/test/DebugInfo/Inputs/dwarfdump-gdbindex-v8.elf-x86-64 b/llvm/test/DebugInfo/Inputs/dwarfdump-gdbindex-v8.elf-x86-64 new file mode 100755 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@