1//===- DWARFDataExtractor.h -------------------------------------*- C++ -*-===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9#ifndef LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H 10#define LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H 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. 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. 29bool IsLittleEndian,
uint8_t AddressSize)
30 :
DataExtractor(Section.Data, IsLittleEndian, AddressSize), Obj(&Obj),
33 /// Constructor for cases when there are no relocations. 40 IsLittleEndian, AddressSize) {}
42 /// Truncating constructor 48 /// Extracts the DWARF "initial length" field, which can either be a 32-bit 49 /// value smaller than 0xfffffff0, or the value 0xffffffff followed by a 50 /// 64-bit length. Returns the actual length, and the DWARF format which is 51 /// encoded in the field. In case of errors, it returns {0, DWARF32} and 52 /// leaves the offset unchanged. 53 std::pair<uint64_t, dwarf::DwarfFormat>
60 /// Extracts a value and applies a relocation to the result if 61 /// one exists for the given offset. 64Error *Err =
nullptr)
const;
66uint64_t *SectionIndex =
nullptr)
const{
70 /// Extracts an address-sized value and applies a relocation to the result if 71 /// one exists for the given offset. 80 /// Extracts a DWARF-encoded pointer in \p Offset using \p Encoding. 81 /// There is a DWARF encoding that uses a PC-relative adjustment. 82 /// For these values, \p AbsPosOffset is used to fix them, which should 83 /// reflect the absolute address of this pointer. 90#endif// LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H This file contains constants used for implementing Dwarf debug support.
static StringRef substr(StringRef Str, uint64_t Len)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
uint64_t getRelocatedAddress(uint64_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 getRelocatedAddress(Cursor &C, uint64_t *SecIx=nullptr) const
std::pair< uint64_t, dwarf::DwarfFormat > getInitialLength(uint64_t *Off, Error *Err=nullptr) const
Extracts the DWARF "initial length" field, which can either be a 32-bit value smaller than 0xfffffff0...
std::pair< uint64_t, dwarf::DwarfFormat > getInitialLength(Cursor &C) const
DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section, bool IsLittleEndian, uint8_t AddressSize)
Constructor for the normal case of extracting data from a DWARF section.
DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
Constructor for cases when there are no relocations.
DWARFDataExtractor(const DWARFDataExtractor &Other, size_t Length)
Truncating constructor.
uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off, uint64_t *SectionIndex=nullptr, Error *Err=nullptr) const
Extracts a value and applies a relocation to the result if one exists for the given offset.
DWARFDataExtractor(ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t AddressSize)
std::optional< uint64_t > getEncodedPointer(uint64_t *Offset, uint8_t Encoding, uint64_t AbsPosOffset=0) const
Extracts a DWARF-encoded pointer in Offset using Encoding.
uint64_t getRelocatedValue(Cursor &C, uint32_t Size, uint64_t *SectionIndex=nullptr) const
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
size_t size() const
Return the number of bytes in the underlying buffer.
static uint64_t & getOffset(Cursor &C)
uint8_t getAddressSize() const
Get the address size for this extractor.
StringRef getData() const
Get the data pointed to by this extractor.
static Error & getError(Cursor &C)
bool isLittleEndian() const
Get the endianness for this extractor.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.