Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
DWARFDataExtractor.h
Go to the documentation of this file.
1//===- DWARFDataExtractor.h -------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
10#define LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
11
18
19namespace llvm {
20
21/// A DWARFDataExtractor (typically for an in-memory copy of an object-file
22/// section) plus a relocation map for that section, if there is one.
23class DWARFDataExtractor : public DWARFDataExtractorBase<DWARFDataExtractor> {
24 const DWARFObject *Obj = nullptr;
25 const DWARFSection *Section = nullptr;
26
27public:
29
30 /// Constructor for the normal case of extracting data from a DWARF section.
31 /// The DWARFSection's lifetime must be at least as long as the extractor's.
32 DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section,
33 bool IsLittleEndian, uint8_t AddressSize)
34 : DWARFDataExtractorBase(Section.Data, IsLittleEndian, AddressSize),
35 Obj(&Obj), Section(&Section) {}
36
37 /// Truncating constructor
42
43 /// Extracts a value and applies a relocation to the result if
44 /// one exists for the given offset.
46 Error *Err) const {
47 if (SecNdx)
49 if (!Section)
50 return getUnsigned(Off, Size, Err);
51 ErrorAsOutParameter ErrAsOut(Err);
52 std::optional<RelocAddrEntry> E = Obj->find(*Section, *Off);
53 uint64_t LocData = getUnsigned(Off, Size, Err);
54 if (!E || (Err && *Err))
55 return LocData;
56 if (SecNdx)
57 *SecNdx = E->SectionIndex;
58
59 uint64_t R = object::resolveRelocation(E->Resolver, E->Reloc,
60 E->SymbolValue, LocData);
61 if (E->Reloc2)
62 R = object::resolveRelocation(E->Resolver, *E->Reloc2, E->SymbolValue2,
63 R);
64 return R;
65 }
66};
67
68} // end namespace llvm
69
70#endif // LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains constants used for implementing Dwarf debug support.
static StringRef substr(StringRef Str, uint64_t Len)
DWARFDataExtractorBase(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
uint64_t getRelocatedValueImpl(uint32_t Size, uint64_t *Off, uint64_t *SecNdx, Error *Err) const
Extracts a value and applies a relocation to the result if one exists for the given offset.
DWARFDataExtractorBase(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
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(const DWARFDataExtractor &Other, size_t Length)
Truncating constructor.
LLVM_ABI uint64_t getUnsigned(uint64_t *offset_ptr, uint32_t byte_size, Error *Err=nullptr) const
Extract an unsigned integer of size byte_size from *offset_ptr.
uint8_t getAddressSize() const
Get the address size for this extractor.
StringRef getData() const
Get the data pointed to by this extractor.
bool isLittleEndian() const
Get the endianness for this extractor.
Helper for Errors used as out-parameters.
Definition Error.h:1144
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
LLVM_ABI uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, uint64_t S, uint64_t LocData)
This is an optimization pass for GlobalISel generic memory operations.
@ Length
Definition DWP.cpp:477
@ Other
Any other memory.
Definition ModRef.h:68
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
static const uint64_t UndefSection
Definition ObjectFile.h:148