[PATCH] D64209: [DWARF] Make DWARFDataExtractor possible to be used with both 32- and 64-bit offsets.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 08:03:18 PDT 2019


ikudrin created this revision.
ikudrin added reviewers: dblaikie, aprantl.
Herald added a project: LLVM.
ikudrin added a parent revision: D64006: [Support] Support 64-bit offsets in DataExtractor..

This is a temporary patch to make the transition to 64-bit offsets in DebugInfo/DWARF more smooth.


Repository:
  rL LLVM

https://reviews.llvm.org/D64209

Files:
  include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
  lib/DebugInfo/DWARF/DWARFDataExtractor.cpp


Index: lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
+++ lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
@@ -12,7 +12,8 @@
 
 using namespace llvm;
 
-uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off,
+template <typename TOff>
+uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, TOff *Off,
                                                uint64_t *SecNdx) const {
   if (SecNdx)
     *SecNdx = object::SectionedAddress::UndefSection;
@@ -27,14 +28,15 @@
   return E->Resolver(E->Reloc, E->SymbolValue, A);
 }
 
+template <typename TOff>
 Optional<uint64_t>
-DWARFDataExtractor::getEncodedPointer(uint32_t *Offset, uint8_t Encoding,
+DWARFDataExtractor::getEncodedPointer(TOff *Offset, uint8_t Encoding,
                                       uint64_t PCRelOffset) const {
   if (Encoding == dwarf::DW_EH_PE_omit)
     return None;
 
   uint64_t Result = 0;
-  uint32_t OldOffset = *Offset;
+  TOff OldOffset = *Offset;
   // First get value
   switch (Encoding & 0x0F) {
   case dwarf::DW_EH_PE_absptr:
@@ -94,3 +96,14 @@
 
   return Result;
 }
+
+template uint64_t
+DWARFDataExtractor::getRelocatedValue<uint32_t>(uint32_t Size, uint32_t *Off,
+                                                uint64_t *SecNdx) const;
+template uint64_t
+DWARFDataExtractor::getRelocatedValue<uint64_t>(uint32_t Size, uint64_t *Off,
+                                                uint64_t *SecNdx) const;
+template Optional<uint64_t> DWARFDataExtractor::getEncodedPointer<uint32_t>(
+    uint32_t *Offset, uint8_t Encoding, uint64_t PCRelOffset) const;
+template Optional<uint64_t> DWARFDataExtractor::getEncodedPointer<uint64_t>(
+    uint64_t *Offset, uint8_t Encoding, uint64_t PCRelOffset) const;
Index: include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
+++ include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
@@ -35,12 +35,14 @@
 
   /// Extracts a value and applies a relocation to the result if
   /// one exists for the given offset.
-  uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off,
+  template <typename TOff>
+  uint64_t getRelocatedValue(uint32_t Size, TOff *Off,
                              uint64_t *SectionIndex = nullptr) const;
 
   /// Extracts an address-sized value and applies a relocation to the result if
   /// one exists for the given offset.
-  uint64_t getRelocatedAddress(uint32_t *Off, uint64_t *SecIx = nullptr) const {
+  template <typename TOff>
+  uint64_t getRelocatedAddress(TOff *Off, uint64_t *SecIx = nullptr) const {
     return getRelocatedValue(getAddressSize(), Off, SecIx);
   }
 
@@ -48,7 +50,8 @@
   /// There is a DWARF encoding that uses a PC-relative adjustment.
   /// For these values, \p AbsPosOffset is used to fix them, which should
   /// reflect the absolute address of this pointer.
-  Optional<uint64_t> getEncodedPointer(uint32_t *Offset, uint8_t Encoding,
+  template <typename TOff>
+  Optional<uint64_t> getEncodedPointer(TOff *Offset, uint8_t Encoding,
                                        uint64_t AbsPosOffset = 0) const;
 
   size_t size() const { return Section == nullptr ? 0 : Section->Data.size(); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64209.208044.patch
Type: text/x-patch
Size: 3335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190704/b9b1d3cf/attachment.bin>


More information about the llvm-commits mailing list