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 + 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 + 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 getEncodedPointer(uint32_t *Offset, uint8_t Encoding, + template + Optional getEncodedPointer(TOff *Offset, uint8_t Encoding, uint64_t AbsPosOffset = 0) const; size_t size() const { return Section == nullptr ? 0 : Section->Data.size(); } 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 +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 Optional -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 Size, uint32_t *Off, + uint64_t *SecNdx) const; +template uint64_t +DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint64_t *Off, + uint64_t *SecNdx) const; +template Optional DWARFDataExtractor::getEncodedPointer( + uint32_t *Offset, uint8_t Encoding, uint64_t PCRelOffset) const; +template Optional DWARFDataExtractor::getEncodedPointer( + uint64_t *Offset, uint8_t Encoding, uint64_t PCRelOffset) const;