LLVM  6.0.0svn
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 class DWARFObject;
18 
19 /// A DataExtractor (typically for an in-memory copy of an object-file section)
20 /// plus a relocation map for that section, if there is one.
22  const DWARFObject *Obj = nullptr;
23  const DWARFSection *Section = nullptr;
24 
25 public:
26  /// Constructor for the normal case of extracting data from a DWARF section.
27  /// The DWARFSection's lifetime must be at least as long as the extractor's.
28  DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section,
29  bool IsLittleEndian, uint8_t AddressSize)
30  : DataExtractor(Section.Data, IsLittleEndian, AddressSize), Obj(&Obj),
31  Section(&Section) {}
32 
33  /// Constructor for cases when there are no relocations.
34  DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
35  : DataExtractor(Data, IsLittleEndian, AddressSize) {}
36 
37  /// Extracts a value and applies a relocation to the result if
38  /// one exists for the given offset.
39  uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off,
40  uint64_t *SectionIndex = nullptr) const;
41 
42  /// Extracts an address-sized value and applies a relocation to the result if
43  /// one exists for the given offset.
44  uint64_t getRelocatedAddress(uint32_t *Off, uint64_t *SecIx = nullptr) const {
45  return getRelocatedValue(getAddressSize(), Off, SecIx);
46  }
47 };
48 
49 } // end namespace llvm
50 
51 #endif // LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
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...
DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
Constructor for cases when there are no relocations.
uint8_t getAddressSize() const
Get the address size for this extractor.
Definition: DataExtractor.h:59
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...
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.
DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section, bool IsLittleEndian, uint8_t AddressSize)
Constructor for the normal case of extracting data from a DWARF section.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49