blob: 69d2a7d6b668aea5ea54a42803d7ba31b162842f [file] [log] [blame]
Lang Hamesf7acddd2014-07-22 22:47:39 +00001//===-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
11#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
Lang Hamesf7acddd2014-07-22 22:47:39 +000012
13#include "RuntimeDyldImpl.h"
14#include <set>
15
16namespace llvm {
17
18class RuntimeDyldCheckerImpl {
Lang Hames778ef5b2014-09-04 04:19:54 +000019 friend class RuntimeDyldChecker;
Lang Hamesf7acddd2014-07-22 22:47:39 +000020 friend class RuntimeDyldImpl;
21 friend class RuntimeDyldCheckerExprEval;
Keno Fischer02628de2015-04-14 02:10:35 +000022 friend class RuntimeDyldELF;
Lang Hamesf7acddd2014-07-22 22:47:39 +000023
24public:
25 RuntimeDyldCheckerImpl(RuntimeDyld &RTDyld, MCDisassembler *Disassembler,
26 MCInstPrinter *InstPrinter,
27 llvm::raw_ostream &ErrStream);
28
29 bool check(StringRef CheckExpr) const;
30 bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
31
32private:
Lang Hames587ee6a2014-09-03 05:01:46 +000033
34 // StubMap typedefs.
35 typedef std::map<std::string, uint64_t> StubOffsetsMap;
36 struct SectionAddressInfo {
37 uint64_t SectionID;
38 StubOffsetsMap StubOffsets;
39 };
40 typedef std::map<std::string, SectionAddressInfo> SectionMap;
41 typedef std::map<std::string, SectionMap> StubMap;
42
Lang Hamesf7acddd2014-07-22 22:47:39 +000043 RuntimeDyldImpl &getRTDyld() const { return *RTDyld.Dyld; }
44
45 bool isSymbolValid(StringRef Symbol) const;
Lang Hamesb1186032015-03-11 00:43:26 +000046 uint64_t getSymbolLocalAddr(StringRef Symbol) const;
Lang Hamesf7acddd2014-07-22 22:47:39 +000047 uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
48 uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
Lang Hames587ee6a2014-09-03 05:01:46 +000049
50 std::pair<const SectionAddressInfo*, std::string> findSectionAddrInfo(
51 StringRef FileName,
52 StringRef SectionName) const;
53
54 std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
55 StringRef SectionName,
56 bool IsInsideLoad) const;
57
58 std::pair<uint64_t, std::string> getStubAddrFor(StringRef FileName,
Lang Hamesf7acddd2014-07-22 22:47:39 +000059 StringRef SectionName,
60 StringRef Symbol,
61 bool IsInsideLoad) const;
62 StringRef getSubsectionStartingAt(StringRef Name) const;
63
Lang Hames587ee6a2014-09-03 05:01:46 +000064 void registerSection(StringRef FilePath, unsigned SectionID);
65 void registerStubMap(StringRef FilePath, unsigned SectionID,
Lang Hamesf7acddd2014-07-22 22:47:39 +000066 const RuntimeDyldImpl::StubMap &RTDyldStubs);
67
68 RuntimeDyld &RTDyld;
69 MCDisassembler *Disassembler;
70 MCInstPrinter *InstPrinter;
71 llvm::raw_ostream &ErrStream;
72
Lang Hamesf7acddd2014-07-22 22:47:39 +000073 StubMap Stubs;
74};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000075}
Lang Hamesf7acddd2014-07-22 22:47:39 +000076
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000077#endif