RuntimeDyldCheckerImpl.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
  9. #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
  10. #include "RuntimeDyldImpl.h"
  11. namespace llvm {
  12. class RuntimeDyldCheckerImpl {
  13. friend class RuntimeDyldChecker;
  14. friend class RuntimeDyldCheckerExprEval;
  15. using IsSymbolValidFunction =
  16. RuntimeDyldChecker::IsSymbolValidFunction;
  17. using GetSymbolInfoFunction = RuntimeDyldChecker::GetSymbolInfoFunction;
  18. using GetSectionInfoFunction = RuntimeDyldChecker::GetSectionInfoFunction;
  19. using GetStubInfoFunction = RuntimeDyldChecker::GetStubInfoFunction;
  20. using GetGOTInfoFunction = RuntimeDyldChecker::GetGOTInfoFunction;
  21. public:
  22. RuntimeDyldCheckerImpl(
  23. IsSymbolValidFunction IsSymbolValid, GetSymbolInfoFunction GetSymbolInfo,
  24. GetSectionInfoFunction GetSectionInfo, GetStubInfoFunction GetStubInfo,
  25. GetGOTInfoFunction GetGOTInfo, support::endianness Endianness,
  26. MCDisassembler *Disassembler, MCInstPrinter *InstPrinter,
  27. llvm::raw_ostream &ErrStream);
  28. bool check(StringRef CheckExpr) const;
  29. bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
  30. private:
  31. // StubMap typedefs.
  32. Expected<JITSymbolResolver::LookupResult>
  33. lookup(const JITSymbolResolver::LookupSet &Symbols) const;
  34. bool isSymbolValid(StringRef Symbol) const;
  35. uint64_t getSymbolLocalAddr(StringRef Symbol) const;
  36. uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
  37. uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
  38. StringRef getSymbolContent(StringRef Symbol) const;
  39. std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
  40. StringRef SectionName,
  41. bool IsInsideLoad) const;
  42. std::pair<uint64_t, std::string>
  43. getStubOrGOTAddrFor(StringRef StubContainerName, StringRef Symbol,
  44. bool IsInsideLoad, bool IsStubAddr) const;
  45. Optional<uint64_t> getSectionLoadAddress(void *LocalAddr) const;
  46. IsSymbolValidFunction IsSymbolValid;
  47. GetSymbolInfoFunction GetSymbolInfo;
  48. GetSectionInfoFunction GetSectionInfo;
  49. GetStubInfoFunction GetStubInfo;
  50. GetGOTInfoFunction GetGOTInfo;
  51. support::endianness Endianness;
  52. MCDisassembler *Disassembler;
  53. MCInstPrinter *InstPrinter;
  54. llvm::raw_ostream &ErrStream;
  55. };
  56. }
  57. #endif