dwarfdump: support indexed string dumping in dwp based on the STR_OFFSETS component of the index

llvm-svn: 253392
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 51c6c09..53a149b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -37,7 +37,11 @@
                      const DWARFUnitSectionBase &UnitSection,
                      const DWARFUnitIndex::Entry *IndexEntry)
     : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
-      LineSection(LS), StringSection(SS), StringOffsetSection(SOS),
+      LineSection(LS), StringSection(SS), StringOffsetSection([&]() {
+        if (const auto *C = IndexEntry->getOffset(DW_SECT_STR_OFFSETS))
+          return SOS.slice(C->Offset, C->Offset + C->Length);
+        return SOS;
+      }()),
       AddrOffsetSection(AOS), isLittleEndian(LE), UnitSection(UnitSection),
       IndexEntry(IndexEntry) {
   clear();