[llvm] r306418 - [DWARF] NFC: Make string-offset handling more like address-table handling;

Paul Robinson via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 08:40:18 PDT 2017


Author: probinson
Date: Tue Jun 27 08:40:18 2017
New Revision: 306418

URL: http://llvm.org/viewvc/llvm-project?rev=306418&view=rev
Log:
[DWARF] NFC: Make string-offset handling more like address-table handling; 
do the indirection and relocation all in the same method.

Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=306418&r1=306417&r2=306418&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Tue Jun 27 08:40:18 2017
@@ -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,

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=306418&r1=306417&r2=306418&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Tue Jun 27 08:40:18 2017
@@ -576,7 +576,6 @@ Optional<const char *> DWARFFormValue::g
     uint64_t StrOffset;
     if (!U->getStringOffsetSectionItem(Offset, StrOffset))
       return None;
-    StrOffset += U->getStringOffsetSectionRelocation(Offset);
     Offset = StrOffset;
   }
   if (const char *Str = U->getStringExtractor().getCStr(&Offset)) {

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=306418&r1=306417&r2=306418&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Tue Jun 27 08:40:18 2017
@@ -74,24 +74,16 @@ bool DWARFUnit::getAddrOffsetSectionItem
 
 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.




More information about the llvm-commits mailing list