File indexing completed on 2026-05-10 08:43:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
0010 #define LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
0011
0012 #include "llvm/BinaryFormat/Dwarf.h"
0013 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
0014 #include "llvm/Support/DataExtractor.h"
0015
0016 namespace llvm {
0017 class DWARFObject;
0018
0019
0020
0021 class DWARFDataExtractor : public DataExtractor {
0022 const DWARFObject *Obj = nullptr;
0023 const DWARFSection *Section = nullptr;
0024
0025 public:
0026
0027
0028 DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section,
0029 bool IsLittleEndian, uint8_t AddressSize)
0030 : DataExtractor(Section.Data, IsLittleEndian, AddressSize), Obj(&Obj),
0031 Section(&Section) {}
0032
0033
0034 DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
0035 : DataExtractor(Data, IsLittleEndian, AddressSize) {}
0036 DWARFDataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian,
0037 uint8_t AddressSize)
0038 : DataExtractor(
0039 StringRef(reinterpret_cast<const char *>(Data.data()), Data.size()),
0040 IsLittleEndian, AddressSize) {}
0041
0042
0043 DWARFDataExtractor(const DWARFDataExtractor &Other, size_t Length)
0044 : DataExtractor(Other.getData().substr(0, Length), Other.isLittleEndian(),
0045 Other.getAddressSize()),
0046 Obj(Other.Obj), Section(Other.Section) {}
0047
0048
0049
0050
0051
0052
0053 std::pair<uint64_t, dwarf::DwarfFormat>
0054 getInitialLength(uint64_t *Off, Error *Err = nullptr) const;
0055
0056 std::pair<uint64_t, dwarf::DwarfFormat> getInitialLength(Cursor &C) const {
0057 return getInitialLength(&getOffset(C), &getError(C));
0058 }
0059
0060
0061
0062 uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off,
0063 uint64_t *SectionIndex = nullptr,
0064 Error *Err = nullptr) const;
0065 uint64_t getRelocatedValue(Cursor &C, uint32_t Size,
0066 uint64_t *SectionIndex = nullptr) const {
0067 return getRelocatedValue(Size, &getOffset(C), SectionIndex, &getError(C));
0068 }
0069
0070
0071
0072 uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const {
0073 return getRelocatedValue(getAddressSize(), Off, SecIx);
0074 }
0075 uint64_t getRelocatedAddress(Cursor &C, uint64_t *SecIx = nullptr) const {
0076 return getRelocatedValue(getAddressSize(), &getOffset(C), SecIx,
0077 &getError(C));
0078 }
0079
0080
0081
0082
0083
0084 std::optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
0085 uint64_t AbsPosOffset = 0) const;
0086 };
0087
0088 }
0089
0090 #endif