1277323Sdim//===-- RuntimeDyldCheckerImpl.h -- RuntimeDyld test framework --*- C++ -*-===//
2277323Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6277323Sdim//
7277323Sdim//===----------------------------------------------------------------------===//
8277323Sdim
9277323Sdim#ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
10277323Sdim#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
11277323Sdim
12277323Sdim#include "RuntimeDyldImpl.h"
13277323Sdim
14277323Sdimnamespace llvm {
15277323Sdim
16277323Sdimclass RuntimeDyldCheckerImpl {
17277323Sdim  friend class RuntimeDyldChecker;
18277323Sdim  friend class RuntimeDyldCheckerExprEval;
19277323Sdim
20353358Sdim  using IsSymbolValidFunction =
21353358Sdim    RuntimeDyldChecker::IsSymbolValidFunction;
22353358Sdim  using GetSymbolInfoFunction = RuntimeDyldChecker::GetSymbolInfoFunction;
23353358Sdim  using GetSectionInfoFunction = RuntimeDyldChecker::GetSectionInfoFunction;
24353358Sdim  using GetStubInfoFunction = RuntimeDyldChecker::GetStubInfoFunction;
25353358Sdim  using GetGOTInfoFunction = RuntimeDyldChecker::GetGOTInfoFunction;
26353358Sdim
27277323Sdimpublic:
28353358Sdim  RuntimeDyldCheckerImpl(
29353358Sdim      IsSymbolValidFunction IsSymbolValid, GetSymbolInfoFunction GetSymbolInfo,
30353358Sdim      GetSectionInfoFunction GetSectionInfo, GetStubInfoFunction GetStubInfo,
31353358Sdim      GetGOTInfoFunction GetGOTInfo, support::endianness Endianness,
32353358Sdim      MCDisassembler *Disassembler, MCInstPrinter *InstPrinter,
33353358Sdim      llvm::raw_ostream &ErrStream);
34277323Sdim
35277323Sdim  bool check(StringRef CheckExpr) const;
36277323Sdim  bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
37277323Sdim
38277323Sdimprivate:
39277323Sdim
40277323Sdim  // StubMap typedefs.
41277323Sdim
42344779Sdim  Expected<JITSymbolResolver::LookupResult>
43344779Sdim  lookup(const JITSymbolResolver::LookupSet &Symbols) const;
44344779Sdim
45277323Sdim  bool isSymbolValid(StringRef Symbol) const;
46288943Sdim  uint64_t getSymbolLocalAddr(StringRef Symbol) const;
47277323Sdim  uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
48277323Sdim  uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
49277323Sdim
50353358Sdim  StringRef getSymbolContent(StringRef Symbol) const;
51277323Sdim
52277323Sdim  std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
53277323Sdim                                                  StringRef SectionName,
54277323Sdim                                                  bool IsInsideLoad) const;
55277323Sdim
56353358Sdim  std::pair<uint64_t, std::string>
57353358Sdim  getStubOrGOTAddrFor(StringRef StubContainerName, StringRef Symbol,
58353358Sdim                      bool IsInsideLoad, bool IsStubAddr) const;
59277323Sdim
60321369Sdim  Optional<uint64_t> getSectionLoadAddress(void *LocalAddr) const;
61321369Sdim
62353358Sdim  IsSymbolValidFunction IsSymbolValid;
63353358Sdim  GetSymbolInfoFunction GetSymbolInfo;
64353358Sdim  GetSectionInfoFunction GetSectionInfo;
65353358Sdim  GetStubInfoFunction GetStubInfo;
66353358Sdim  GetGOTInfoFunction GetGOTInfo;
67353358Sdim  support::endianness Endianness;
68277323Sdim  MCDisassembler *Disassembler;
69277323Sdim  MCInstPrinter *InstPrinter;
70277323Sdim  llvm::raw_ostream &ErrStream;
71277323Sdim};
72277323Sdim}
73277323Sdim
74277323Sdim#endif
75