LLVM  3.7.0
RuntimeDyldCheckerImpl.h
Go to the documentation of this file.
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 #include <set>
15 
16 namespace llvm {
17 
19  friend class RuntimeDyldChecker;
20  friend class RuntimeDyldImpl;
22  friend class RuntimeDyldELF;
23 
24 public:
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 
32 private:
33 
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 
43  RuntimeDyldImpl &getRTDyld() const { return *RTDyld.Dyld; }
44 
45  bool isSymbolValid(StringRef Symbol) const;
46  uint64_t getSymbolLocalAddr(StringRef Symbol) const;
47  uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
48  uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
49 
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,
59  StringRef SectionName,
61  bool IsInsideLoad) const;
62  StringRef getSubsectionStartingAt(StringRef Name) const;
63 
64  void registerSection(StringRef FilePath, unsigned SectionID);
65  void registerStubMap(StringRef FilePath, unsigned SectionID,
66  const RuntimeDyldImpl::StubMap &RTDyldStubs);
67 
68  RuntimeDyld &RTDyld;
69  MCDisassembler *Disassembler;
70  MCInstPrinter *InstPrinter;
71  llvm::raw_ostream &ErrStream;
72 
73  StubMap Stubs;
74 };
75 }
76 
77 #endif
RuntimeDyldCheckerImpl(RuntimeDyld &RTDyld, MCDisassembler *Disassembler, MCInstPrinter *InstPrinter, llvm::raw_ostream &ErrStream)
Superclass for all disassemblers.
std::map< RelocationValueRef, uintptr_t > StubMap
RuntimeDyld invariant checker for verifying that RuntimeDyld has correctly applied relocations...
bool check(StringRef CheckExpr) const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:37
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:38
bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40