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