]> granicus.if.org Git - llvm/commitdiff
[DWARF] NFC: Make string-offset handling more like address-table handling;
authorPaul Robinson <paul.robinson@sony.com>
Tue, 27 Jun 2017 15:40:18 +0000 (15:40 +0000)
committerPaul Robinson <paul.robinson@sony.com>
Tue, 27 Jun 2017 15:40:18 +0000 (15:40 +0000)
do the indirection and relocation all in the same method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306418 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DWARF/DWARFUnit.h
lib/DebugInfo/DWARF/DWARFFormValue.cpp
lib/DebugInfo/DWARF/DWARFUnit.cpp

index d7ccaf82bc9a1ea0a4b67d63b609a0fcb19fc40a..48a255138157c24d78f806774ebecd604abd6226 100644 (file)
@@ -194,9 +194,7 @@ public:
   }
 
   bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
-  // FIXME: Result should be uint64_t in DWARF64.
   bool getStringOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
-  uint64_t getStringOffsetSectionRelocation(uint32_t Index) const;
 
   DataExtractor getDebugInfoExtractor() const {
     return DataExtractor(InfoSection.Data, isLittleEndian,
index 861114bde1f2b2a63cdc78ff532edb58c3794e42..0075ef1a8a0f658eab55bd34723a09dbc058d324 100644 (file)
@@ -576,7 +576,6 @@ Optional<const char *> 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)) {
index fd9c7c2b1d46ca0dd6c2c6b756805f84b7683d44..2e7c8f346773c8ec0eac444d9b1c1feee9245ff9 100644 (file)
@@ -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.