LLVM  5.0.0
DWARFDataExtractor.h
Go to the documentation of this file.
1 //===- DWARFDataExtractor.h -------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H
11 #define LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H
12 
15 
16 namespace llvm {
17 
18 /// A DataExtractor (typically for an in-memory copy of an object-file section)
19 /// plus a relocation map for that section, if there is one.
21  const RelocAddrMap *RelocMap = nullptr;
22 public:
23  /// Constructor for the normal case of extracting data from a DWARF section.
24  /// The DWARFSection's lifetime must be at least as long as the extractor's.
25  DWARFDataExtractor(const DWARFSection &Section, bool IsLittleEndian,
26  uint8_t AddressSize)
27  : DataExtractor(Section.Data, IsLittleEndian, AddressSize),
28  RelocMap(&Section.Relocs) {}
29 
30  /// Constructor for cases when there are no relocations.
31  DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
32  : DataExtractor(Data, IsLittleEndian, AddressSize) {}
33 
34  /// Extracts a value and applies a relocation to the result if
35  /// one exists for the given offset.
36  uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off,
37  uint64_t *SectionIndex = nullptr) const;
38 
39  /// Extracts an address-sized value and applies a relocation to the result if
40  /// one exists for the given offset.
41  uint64_t getRelocatedAddress(uint32_t *Off, uint64_t *SecIx = nullptr) const {
42  return getRelocatedValue(getAddressSize(), Off, SecIx);
43  }
44 };
45 
46 } // end namespace llvm
47 
48 #endif // LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H
uint8_t getAddressSize() const
Get the address size for this extractor.
Definition: DataExtractor.h:59
DWARFDataExtractor(const DWARFSection &Section, bool IsLittleEndian, uint8_t AddressSize)
Constructor for the normal case of extracting data from a DWARF section.
uint64_t getRelocatedAddress(uint32_t *Off, uint64_t *SecIx=nullptr) const
Extracts an address-sized value and applies a relocation to the result if one exists for the given of...
uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off, uint64_t *SectionIndex=nullptr) const
Extracts a value and applies a relocation to the result if one exists for the given offset...
DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
Constructor for cases when there are no relocations.
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49