blob: b7263be09934aaa6f5115d52d0aa15f3fb5bf7d9 [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"
Lang Hamesf7acddd2014-07-22 22:47:39 +000014
15namespace llvm {
16
17class RuntimeDyldCheckerImpl {
Lang Hames778ef5b2014-09-04 04:19:54 +000018 friend class RuntimeDyldChecker;
Lang Hamesf7acddd2014-07-22 22:47:39 +000019 friend class RuntimeDyldImpl;
20 friend class RuntimeDyldCheckerExprEval;
Keno Fischer02628de2015-04-14 02:10:35 +000021 friend class RuntimeDyldELF;
Lang Hamesf7acddd2014-07-22 22:47:39 +000022
23public:
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
31private:
Lang Hames587ee6a2014-09-03 05:01:46 +000032
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
Lang Hamesf7acddd2014-07-22 22:47:39 +000042 RuntimeDyldImpl &getRTDyld() const { return *RTDyld.Dyld; }
43
44 bool isSymbolValid(StringRef Symbol) const;
Lang Hamesb1186032015-03-11 00:43:26 +000045 uint64_t getSymbolLocalAddr(StringRef Symbol) const;
Lang Hamesf7acddd2014-07-22 22:47:39 +000046 uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
47 uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
Lang Hames587ee6a2014-09-03 05:01:46 +000048
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,
Lang Hamesf7acddd2014-07-22 22:47:39 +000058 StringRef SectionName,
59 StringRef Symbol,
60 bool IsInsideLoad) const;
61 StringRef getSubsectionStartingAt(StringRef Name) const;
62
Lang Hames587ee6a2014-09-03 05:01:46 +000063 void registerSection(StringRef FilePath, unsigned SectionID);
64 void registerStubMap(StringRef FilePath, unsigned SectionID,
Lang Hamesf7acddd2014-07-22 22:47:39 +000065 const RuntimeDyldImpl::StubMap &RTDyldStubs);
66
67 RuntimeDyld &RTDyld;
68 MCDisassembler *Disassembler;
69 MCInstPrinter *InstPrinter;
70 llvm::raw_ostream &ErrStream;
71
Lang Hamesf7acddd2014-07-22 22:47:39 +000072 StubMap Stubs;
73};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000074}
Lang Hamesf7acddd2014-07-22 22:47:39 +000075
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000076#endif