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
19class RuntimeDyldCheckerImpl {
20 friend class RuntimeDyldChecker;
21 friend class RuntimeDyldCheckerExprEval;
22
23 using IsSymbolValidFunction =
24 RuntimeDyldChecker::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,
37 SubtargetFeatures TF, llvm::raw_ostream &ErrStream);
38
39 bool check(StringRef CheckExpr) const;
40 bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
41
42private:
43
44 // StubMap typedefs.
45
46 bool isSymbolValid(StringRef Symbol) const;
47 uint64_t getSymbolLocalAddr(StringRef Symbol) const;
48 uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
49 uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
50
51 StringRef getSymbolContent(StringRef Symbol) const;
52
53 TargetFlagsType getTargetFlag(StringRef Symbol) const;
54 Triple getTripleForSymbol(TargetFlagsType Flag) const;
55 StringRef getCPU() const { return CPU; }
56 SubtargetFeatures getFeatures() const { return TF; }
57
58 std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
59 StringRef SectionName,
60 bool IsInsideLoad) const;
61
62 std::pair<uint64_t, std::string>
63 getStubOrGOTAddrFor(StringRef StubContainerName, StringRef Symbol,
64 StringRef StubKindFilter, bool IsInsideLoad,
65 bool IsStubAddr) const;
66
67 IsSymbolValidFunction IsSymbolValid;
68 GetSymbolInfoFunction GetSymbolInfo;
69 GetSectionInfoFunction GetSectionInfo;
70 GetStubInfoFunction GetStubInfo;
71 GetGOTInfoFunction GetGOTInfo;
72 llvm::endianness Endianness;
73 Triple TT;
74 std::string CPU;
75 SubtargetFeatures TF;
76 llvm::raw_ostream &ErrStream;
77};
78}
79
80#endif
81