LLVM 20.0.0git
RuntimeDyldCheckerImpl.h
Go to the documentation of this file.
1//===-- RuntimeDyldCheckerImpl.h -- RuntimeDyld test framework --*- 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_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
10#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
11
12#include "RuntimeDyldImpl.h"
13
14namespace llvm {
15
16/// Holds target-specific properties for a symbol.
17using TargetFlagsType = uint8_t;
18
20 friend class RuntimeDyldChecker;
22
23 using IsSymbolValidFunction =
25 using GetSymbolInfoFunction = RuntimeDyldChecker::GetSymbolInfoFunction;
26 using GetSectionInfoFunction = RuntimeDyldChecker::GetSectionInfoFunction;
27 using GetStubInfoFunction = RuntimeDyldChecker::GetStubInfoFunction;
28 using GetGOTInfoFunction = RuntimeDyldChecker::GetGOTInfoFunction;
29
30public:
31 RuntimeDyldCheckerImpl(IsSymbolValidFunction IsSymbolValid,
32 GetSymbolInfoFunction GetSymbolInfo,
33 GetSectionInfoFunction GetSectionInfo,
34 GetStubInfoFunction GetStubInfo,
35 GetGOTInfoFunction GetGOTInfo,
36 llvm::endianness Endianness, Triple TT, StringRef CPU,
38
39 bool check(StringRef CheckExpr) const;
40 bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
41
42private:
43
44 // StubMap typedefs.
45
47 lookup(const JITSymbolResolver::LookupSet &Symbols) const;
48
49 bool isSymbolValid(StringRef Symbol) const;
50 uint64_t getSymbolLocalAddr(StringRef Symbol) const;
51 uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
52 uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
53
54 StringRef getSymbolContent(StringRef Symbol) const;
55
56 TargetFlagsType getTargetFlag(StringRef Symbol) const;
57 Triple getTripleForSymbol(TargetFlagsType Flag) const;
58 StringRef getCPU() const { return CPU; }
59 SubtargetFeatures getFeatures() const { return TF; }
60
61 std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
63 bool IsInsideLoad) const;
64
65 std::pair<uint64_t, std::string>
66 getStubOrGOTAddrFor(StringRef StubContainerName, StringRef Symbol,
67 StringRef StubKindFilter, bool IsInsideLoad,
68 bool IsStubAddr) const;
69
70 std::optional<uint64_t> getSectionLoadAddress(void *LocalAddr) const;
71
72 IsSymbolValidFunction IsSymbolValid;
73 GetSymbolInfoFunction GetSymbolInfo;
74 GetSectionInfoFunction GetSectionInfo;
75 GetStubInfoFunction GetStubInfo;
76 GetGOTInfoFunction GetGOTInfo;
77 llvm::endianness Endianness;
78 Triple TT;
79 std::string CPU;
81 llvm::raw_ostream &ErrStream;
82};
83}
84
85#endif
uint64_t Addr
uint64_t Size
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
Definition: InlineInfo.cpp:109
static FeatureBitset getFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
Tagged union holding either a T or a Error.
Definition: Error.h:481
std::set< StringRef > LookupSet
Definition: JITSymbol.h:373
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:51
bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const
bool check(StringRef CheckExpr) const
RuntimeDyld invariant checker for verifying that RuntimeDyld has correctly applied relocations.
std::function< bool(StringRef Symbol)> IsSymbolValidFunction
std::function< Expected< MemoryRegionInfo >(StringRef StubContainer, StringRef TargetName, StringRef StubKindFilter)> GetStubInfoFunction
std::function< Expected< MemoryRegionInfo >(StringRef FileName, StringRef SectionName)> GetSectionInfoFunction
std::function< Expected< MemoryRegionInfo >(StringRef GOTContainer, StringRef TargetName)> GetGOTInfoFunction
std::function< Expected< MemoryRegionInfo >(StringRef SymbolName)> GetSymbolInfoFunction
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static StringRef getCPU(StringRef CPU)
Processes a CPU name.
uint8_t TargetFlagsType
Holds target-specific properties for a symbol.
endianness
Definition: bit.h:70