]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCheckerImpl.h
MFV r336944: 9286 want refreservation=auto
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / ExecutionEngine / RuntimeDyld / RuntimeDyldCheckerImpl.h
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
10 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
11 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
12
13 #include "RuntimeDyldImpl.h"
14
15 namespace llvm {
16
17 class RuntimeDyldCheckerImpl {
18   friend class RuntimeDyldChecker;
19   friend class RuntimeDyldImpl;
20   friend class RuntimeDyldCheckerExprEval;
21   friend class RuntimeDyldELF;
22
23 public:
24   RuntimeDyldCheckerImpl(RuntimeDyld &RTDyld, MCDisassembler *Disassembler,
25                          MCInstPrinter *InstPrinter,
26                          llvm::raw_ostream &ErrStream);
27
28   bool check(StringRef CheckExpr) const;
29   bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
30
31 private:
32
33   // StubMap typedefs.
34   typedef std::map<std::string, uint64_t> StubOffsetsMap;
35   struct SectionAddressInfo {
36     uint64_t SectionID;
37     StubOffsetsMap StubOffsets;
38   };
39   typedef std::map<std::string, SectionAddressInfo> SectionMap;
40   typedef std::map<std::string, SectionMap> StubMap;
41
42   RuntimeDyldImpl &getRTDyld() const { return *RTDyld.Dyld; }
43
44   bool isSymbolValid(StringRef Symbol) const;
45   uint64_t getSymbolLocalAddr(StringRef Symbol) const;
46   uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
47   uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
48
49   std::pair<const SectionAddressInfo*, std::string> findSectionAddrInfo(
50                                                    StringRef FileName,
51                                                    StringRef SectionName) const;
52
53   std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
54                                                   StringRef SectionName,
55                                                   bool IsInsideLoad) const;
56
57   std::pair<uint64_t, std::string> getStubAddrFor(StringRef FileName,
58                                                   StringRef SectionName,
59                                                   StringRef Symbol,
60                                                   bool IsInsideLoad) const;
61   StringRef getSubsectionStartingAt(StringRef Name) const;
62
63   Optional<uint64_t> getSectionLoadAddress(void *LocalAddr) const;
64
65   void registerSection(StringRef FilePath, unsigned SectionID);
66   void registerStubMap(StringRef FilePath, unsigned SectionID,
67                        const RuntimeDyldImpl::StubMap &RTDyldStubs);
68
69   RuntimeDyld &RTDyld;
70   MCDisassembler *Disassembler;
71   MCInstPrinter *InstPrinter;
72   llvm::raw_ostream &ErrStream;
73
74   StubMap Stubs;
75 };
76 }
77
78 #endif