From d66ee0f9a75e37a2836bd5e48154e8ae1958269c Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Tue, 27 Jun 2017 15:40:18 +0000 Subject: [DWARF] NFC: Make string-offset handling more like address-table handling; do the indirection and relocation all in the same method. llvm-svn: 306418 --- llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp | 1 - llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'llvm/lib/DebugInfo') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp index 861114bde1f..0075ef1a8a0 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -576,7 +576,6 @@ Optional DWARFFormValue::getAsCString() const { uint64_t StrOffset; if (!U->getStringOffsetSectionItem(Offset, StrOffset)) return None; - StrOffset += U->getStringOffsetSectionRelocation(Offset); Offset = StrOffset; } if (const char *Str = U->getStringExtractor().getCStr(&Offset)) { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index fd9c7c2b1d4..2e7c8f34677 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -74,24 +74,16 @@ bool DWARFUnit::getAddrOffsetSectionItem(uint32_t Index, bool DWARFUnit::getStringOffsetSectionItem(uint32_t Index, uint64_t &Result) const { - unsigned ItemSize = getFormat() == DWARF64 ? 8 : 4; + unsigned ItemSize = getDwarfOffsetByteSize(); uint32_t Offset = StringOffsetSectionBase + Index * ItemSize; if (StringOffsetSection.Data.size() < Offset + ItemSize) return false; DataExtractor DA(StringOffsetSection.Data, isLittleEndian, 0); - Result = ItemSize == 4 ? DA.getU32(&Offset) : DA.getU64(&Offset); + Result = getRelocatedValue(DA, ItemSize, &Offset, + &StringOffsetSection.Relocs); return true; } -uint64_t DWARFUnit::getStringOffsetSectionRelocation(uint32_t Index) const { - unsigned ItemSize = getFormat() == DWARF64 ? 8 : 4; - uint64_t ByteOffset = StringOffsetSectionBase + Index * ItemSize; - RelocAddrMap::const_iterator AI = getStringOffsetsRelocMap().find(ByteOffset); - if (AI != getStringOffsetsRelocMap().end()) - return AI->second.Value; - return 0; -} - bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) { Length = debug_info.getU32(offset_ptr); // FIXME: Support DWARF64. -- cgit v1.2.3