#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCInst.h"
-#include "llvm/Support/StringRefMemoryObject.h"
#include "llvm/Support/Path.h"
#include "RuntimeDyldCheckerImpl.h"
#include "RuntimeDyldImpl.h"
bool decodeInst(StringRef Symbol, MCInst &Inst, uint64_t &Size) const {
MCDisassembler *Dis = Checker.Disassembler;
StringRef SectionMem = Checker.getSubsectionStartingAt(Symbol);
- StringRefMemoryObject SectionBytes(SectionMem, 0);
+ ArrayRef<uint8_t> SectionBytes(
+ reinterpret_cast<const uint8_t *>(SectionMem.data()),
+ SectionMem.size());
MCDisassembler::DecodeStatus S =
Dis->getInstruction(Inst, Size, SectionBytes, 0, nulls(), nulls());
}
uint64_t RuntimeDyldCheckerImpl::getSymbolRemoteAddr(StringRef Symbol) const {
- return getRTDyld().getAnySymbolRemoteAddress(Symbol);
+ if (uint64_t InternalSymbolAddr = getRTDyld().getSymbolLoadAddress(Symbol))
+ return InternalSymbolAddr;
+ return getRTDyld().MemMgr->getSymbolAddress(Symbol);
}
uint64_t RuntimeDyldCheckerImpl::readMemoryAtAddr(uint64_t SrcAddr,
auto StubOffsetItr = SymbolStubs.find(SymbolName);
if (StubOffsetItr == SymbolStubs.end())
return std::make_pair(0,
- ("Symbol '" + SymbolName + "' not found.\n").str());
+ ("Stub for symbol '" + SymbolName + "' not found. "
+ "If '" + SymbolName + "' is an internal symbol this "
+ "may indicate that the stub target offset is being "
+ "computed incorrectly.\n").str());
uint64_t StubOffset = StubOffsetItr->second;
const SectionEntry &Section = getRTDyld().Sections[SectionID];
StringRef SectionName = Section.Name;
- dbgs() << "Registering " << SectionName << "\n";
Stubs[FileName][SectionName].SectionID = SectionID;
}
for (auto &GSTEntry : getRTDyld().GlobalSymbolTable) {
if (GSTEntry.second.first == StubMapEntry.first.SectionID &&
GSTEntry.second.second ==
- static_cast<uint64_t>(StubMapEntry.first.Addend)) {
+ static_cast<uint64_t>(StubMapEntry.first.Offset)) {
SymbolName = GSTEntry.first();
break;
}
RuntimeDyldChecker::~RuntimeDyldChecker() {}
+RuntimeDyld& RuntimeDyldChecker::getRTDyld() {
+ return Impl->RTDyld;
+}
+
+const RuntimeDyld& RuntimeDyldChecker::getRTDyld() const {
+ return Impl->RTDyld;
+}
+
bool RuntimeDyldChecker::check(StringRef CheckExpr) const {
return Impl->check(CheckExpr);
}
MemoryBuffer *MemBuf) const {
return Impl->checkAllRulesInBuffer(RulePrefix, MemBuf);
}
+
+std::pair<uint64_t, std::string>
+RuntimeDyldChecker::getSectionAddr(StringRef FileName, StringRef SectionName,
+ bool LinkerAddress) {
+ return Impl->getSectionAddr(FileName, SectionName, LinkerAddress);
+}