RuntimeDyldCheckerImpl.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //===-- RuntimeDyldCheckerImpl.h -- RuntimeDyld test framework --*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
  10. #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
  11. #include "RuntimeDyldImpl.h"
  12. #include <set>
  13. namespace llvm {
  14. class RuntimeDyldCheckerImpl {
  15. friend class RuntimeDyldChecker;
  16. friend class RuntimeDyldImpl;
  17. friend class RuntimeDyldCheckerExprEval;
  18. friend class RuntimeDyldELF;
  19. public:
  20. RuntimeDyldCheckerImpl(RuntimeDyld &RTDyld, MCDisassembler *Disassembler,
  21. MCInstPrinter *InstPrinter,
  22. llvm::raw_ostream &ErrStream);
  23. bool check(StringRef CheckExpr) const;
  24. bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
  25. private:
  26. // StubMap typedefs.
  27. typedef std::map<std::string, uint64_t> StubOffsetsMap;
  28. struct SectionAddressInfo {
  29. uint64_t SectionID;
  30. StubOffsetsMap StubOffsets;
  31. };
  32. typedef std::map<std::string, SectionAddressInfo> SectionMap;
  33. typedef std::map<std::string, SectionMap> StubMap;
  34. RuntimeDyldImpl &getRTDyld() const { return *RTDyld.Dyld; }
  35. bool isSymbolValid(StringRef Symbol) const;
  36. uint64_t getSymbolLocalAddr(StringRef Symbol) const;
  37. uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
  38. uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
  39. std::pair<const SectionAddressInfo*, std::string> findSectionAddrInfo(
  40. StringRef FileName,
  41. StringRef SectionName) const;
  42. std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
  43. StringRef SectionName,
  44. bool IsInsideLoad) const;
  45. std::pair<uint64_t, std::string> getStubAddrFor(StringRef FileName,
  46. StringRef SectionName,
  47. StringRef Symbol,
  48. bool IsInsideLoad) const;
  49. StringRef getSubsectionStartingAt(StringRef Name) const;
  50. void registerSection(StringRef FilePath, unsigned SectionID);
  51. void registerStubMap(StringRef FilePath, unsigned SectionID,
  52. const RuntimeDyldImpl::StubMap &RTDyldStubs);
  53. RuntimeDyld &RTDyld;
  54. MCDisassembler *Disassembler;
  55. MCInstPrinter *InstPrinter;
  56. llvm::raw_ostream &ErrStream;
  57. StubMap Stubs;
  58. };
  59. }
  60. #endif