1 //===-- RuntimeDyldCheckerImpl.h -- RuntimeDyld test framework --*- 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_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
10 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
12 #include "RuntimeDyldImpl.h"
16 /// Holds target-specific properties for a symbol.
17 using TargetFlagsType
= uint8_t;
19 class RuntimeDyldCheckerImpl
{
20 friend class RuntimeDyldChecker
;
21 friend class RuntimeDyldCheckerExprEval
;
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
;
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
);
39 bool check(StringRef CheckExpr
) const;
40 bool checkAllRulesInBuffer(StringRef RulePrefix
, MemoryBuffer
*MemBuf
) const;
46 Expected
<JITSymbolResolver::LookupResult
>
47 lookup(const JITSymbolResolver::LookupSet
&Symbols
) const;
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;
54 StringRef
getSymbolContent(StringRef Symbol
) const;
56 TargetFlagsType
getTargetFlag(StringRef Symbol
) const;
57 Triple
getTripleForSymbol(TargetFlagsType Flag
) const;
58 StringRef
getCPU() const { return CPU
; }
59 SubtargetFeatures
getFeatures() const { return TF
; }
61 std::pair
<uint64_t, std::string
> getSectionAddr(StringRef FileName
,
62 StringRef SectionName
,
63 bool IsInsideLoad
) const;
65 std::pair
<uint64_t, std::string
>
66 getStubOrGOTAddrFor(StringRef StubContainerName
, StringRef Symbol
,
67 StringRef StubKindFilter
, bool IsInsideLoad
,
68 bool IsStubAddr
) const;
70 std::optional
<uint64_t> getSectionLoadAddress(void *LocalAddr
) const;
72 IsSymbolValidFunction IsSymbolValid
;
73 GetSymbolInfoFunction GetSymbolInfo
;
74 GetSectionInfoFunction GetSectionInfo
;
75 GetStubInfoFunction GetStubInfo
;
76 GetGOTInfoFunction GetGOTInfo
;
77 llvm::endianness Endianness
;
81 llvm::raw_ostream
&ErrStream
;