projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[Orc][MCJIT][RuntimeDyld] Re-apply r231726 and r231724 with fix suggested by
[oota-llvm.git]
/
lib
/
ExecutionEngine
/
RuntimeDyld
/
RuntimeDyldChecker.cpp
diff --git
a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index 07e0d3ab64528e8896f2a972358eba652a0f7400..c99140897f60d674bf67974485c90048c0119a6f 100644
(file)
--- a/
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@
-8,14
+8,13
@@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
+#include "RuntimeDyldCheckerImpl.h"
+#include "RuntimeDyldImpl.h"
#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCInst.h"
#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
#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 "llvm/Support/Path.h"
-#include "RuntimeDyldCheckerImpl.h"
-#include "RuntimeDyldImpl.h"
#include <cctype>
#include <memory>
#include <cctype>
#include <memory>
@@
-261,9
+260,7
@@
private:
<< "'. Instruction has only "
<< format("%i", Inst.getNumOperands())
<< " operands.\nInstruction is:\n ";
<< "'. Instruction has only "
<< format("%i", Inst.getNumOperands())
<< " operands.\nInstruction is:\n ";
- Inst.dump_pretty(ErrMsgStream,
- Checker.Disassembler->getContext().getAsmInfo(),
- Checker.InstPrinter);
+ Inst.dump_pretty(ErrMsgStream, Checker.InstPrinter);
return std::make_pair(EvalResult(ErrMsgStream.str()), "");
}
return std::make_pair(EvalResult(ErrMsgStream.str()), "");
}
@@
-273,9
+270,7
@@
private:
raw_string_ostream ErrMsgStream(ErrMsg);
ErrMsgStream << "Operand '" << format("%i", OpIdx) << "' of instruction '"
<< Symbol << "' is not an immediate.\nInstruction is:\n ";
raw_string_ostream ErrMsgStream(ErrMsg);
ErrMsgStream << "Operand '" << format("%i", OpIdx) << "' of instruction '"
<< Symbol << "' is not an immediate.\nInstruction is:\n ";
- Inst.dump_pretty(ErrMsgStream,
- Checker.Disassembler->getContext().getAsmInfo(),
- Checker.InstPrinter);
+ Inst.dump_pretty(ErrMsgStream, Checker.InstPrinter);
return std::make_pair(EvalResult(ErrMsgStream.str()), "");
}
return std::make_pair(EvalResult(ErrMsgStream.str()), "");
}
@@
-315,7
+310,7
@@
private:
"");
uint64_t SymbolAddr = PCtx.IsInsideLoad
"");
uint64_t SymbolAddr = PCtx.IsInsideLoad
- ? Checker.getSymbolL
inker
Addr(Symbol)
+ ? Checker.getSymbolL
ocal
Addr(Symbol)
: Checker.getSymbolRemoteAddr(Symbol);
uint64_t NextPC = SymbolAddr + InstSize;
: Checker.getSymbolRemoteAddr(Symbol);
uint64_t NextPC = SymbolAddr + InstSize;
@@
-442,7
+437,7
@@
private:
// The value for the symbol depends on the context we're evaluating in:
// Inside a load this is the address in the linker's memory, outside a
// load it's the address in the target processes memory.
// The value for the symbol depends on the context we're evaluating in:
// Inside a load this is the address in the linker's memory, outside a
// load it's the address in the target processes memory.
- uint64_t Value = PCtx.IsInsideLoad ? Checker.getSymbolL
inker
Addr(Symbol)
+ uint64_t Value = PCtx.IsInsideLoad ? Checker.getSymbolL
ocal
Addr(Symbol)
: Checker.getSymbolRemoteAddr(Symbol);
// Looks like a plain symbol reference.
: Checker.getSymbolRemoteAddr(Symbol);
// Looks like a plain symbol reference.
@@
-668,7
+663,9
@@
private:
bool decodeInst(StringRef Symbol, MCInst &Inst, uint64_t &Size) const {
MCDisassembler *Dis = Checker.Disassembler;
StringRef SectionMem = Checker.getSubsectionStartingAt(Symbol);
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());
MCDisassembler::DecodeStatus S =
Dis->getInstruction(Inst, Size, SectionBytes, 0, nulls(), nulls());
@@
-730,16
+727,18
@@
bool RuntimeDyldCheckerImpl::checkAllRulesInBuffer(StringRef RulePrefix,
}
bool RuntimeDyldCheckerImpl::isSymbolValid(StringRef Symbol) const {
}
bool RuntimeDyldCheckerImpl::isSymbolValid(StringRef Symbol) const {
- return getRTDyld().getSymbolAddress(Symbol) != nullptr;
+ return getRTDyld().getSymbol
Local
Address(Symbol) != nullptr;
}
}
-uint64_t RuntimeDyldCheckerImpl::getSymbolL
inker
Addr(StringRef Symbol) const {
+uint64_t RuntimeDyldCheckerImpl::getSymbolL
ocal
Addr(StringRef Symbol) const {
return static_cast<uint64_t>(
return static_cast<uint64_t>(
- reinterpret_cast<uintptr_t>(getRTDyld().getSymbolAddress(Symbol)));
+ reinterpret_cast<uintptr_t>(getRTDyld().getSymbol
Local
Address(Symbol)));
}
uint64_t RuntimeDyldCheckerImpl::getSymbolRemoteAddr(StringRef Symbol) const {
}
uint64_t RuntimeDyldCheckerImpl::getSymbolRemoteAddr(StringRef Symbol) const {
- return getRTDyld().getAnySymbolRemoteAddress(Symbol);
+ if (auto InternalSymbol = getRTDyld().getSymbol(Symbol))
+ return InternalSymbol.getAddress();
+ return getRTDyld().MemMgr->getSymbolAddress(Symbol);
}
uint64_t RuntimeDyldCheckerImpl::readMemoryAtAddr(uint64_t SrcAddr,
}
uint64_t RuntimeDyldCheckerImpl::readMemoryAtAddr(uint64_t SrcAddr,
@@
-825,7
+824,10
@@
std::pair<uint64_t, std::string> RuntimeDyldCheckerImpl::getStubAddrFor(
auto StubOffsetItr = SymbolStubs.find(SymbolName);
if (StubOffsetItr == SymbolStubs.end())
return std::make_pair(0,
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;
uint64_t StubOffset = StubOffsetItr->second;
@@
-844,14
+846,16
@@
std::pair<uint64_t, std::string> RuntimeDyldCheckerImpl::getStubAddrFor(
StringRef
RuntimeDyldCheckerImpl::getSubsectionStartingAt(StringRef Name) const {
StringRef
RuntimeDyldCheckerImpl::getSubsectionStartingAt(StringRef Name) const {
- R
untimeDyldImpl::SymbolTableMap
::const_iterator pos =
+ R
TDyldSymbolTable
::const_iterator pos =
getRTDyld().GlobalSymbolTable.find(Name);
if (pos == getRTDyld().GlobalSymbolTable.end())
return StringRef();
getRTDyld().GlobalSymbolTable.find(Name);
if (pos == getRTDyld().GlobalSymbolTable.end())
return StringRef();
- RuntimeDyldImpl::SymbolLoc Loc = pos->second;
- uint8_t *SectionAddr = getRTDyld().getSectionAddress(Loc.first);
- return StringRef(reinterpret_cast<const char *>(SectionAddr) + Loc.second,
- getRTDyld().Sections[Loc.first].Size - Loc.second);
+ const auto &SymInfo = pos->second;
+ uint8_t *SectionAddr = getRTDyld().getSectionAddress(SymInfo.getSectionID());
+ return StringRef(reinterpret_cast<const char *>(SectionAddr) +
+ SymInfo.getOffset(),
+ getRTDyld().Sections[SymInfo.getSectionID()].Size -
+ SymInfo.getOffset());
}
void RuntimeDyldCheckerImpl::registerSection(
}
void RuntimeDyldCheckerImpl::registerSection(
@@
-881,9
+885,10
@@
void RuntimeDyldCheckerImpl::registerStubMap(
// If this is a (Section, Offset) pair, do a reverse lookup in the
// global symbol table to find the name.
for (auto &GSTEntry : getRTDyld().GlobalSymbolTable) {
// If this is a (Section, Offset) pair, do a reverse lookup in the
// global symbol table to find the name.
for (auto &GSTEntry : getRTDyld().GlobalSymbolTable) {
- if (GSTEntry.second.first == StubMapEntry.first.SectionID &&
- GSTEntry.second.second ==
- static_cast<uint64_t>(StubMapEntry.first.Addend)) {
+ const auto &SymInfo = GSTEntry.second;
+ if (SymInfo.getSectionID() == StubMapEntry.first.SectionID &&
+ SymInfo.getOffset() ==
+ static_cast<uint64_t>(StubMapEntry.first.Offset)) {
SymbolName = GSTEntry.first();
break;
}
SymbolName = GSTEntry.first();
break;
}
@@
-905,6
+910,14
@@
RuntimeDyldChecker::RuntimeDyldChecker(RuntimeDyld &RTDyld,
RuntimeDyldChecker::~RuntimeDyldChecker() {}
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);
}
bool RuntimeDyldChecker::check(StringRef CheckExpr) const {
return Impl->check(CheckExpr);
}
@@
-913,3
+926,9
@@
bool RuntimeDyldChecker::checkAllRulesInBuffer(StringRef RulePrefix,
MemoryBuffer *MemBuf) const {
return Impl->checkAllRulesInBuffer(RulePrefix, MemBuf);
}
MemoryBuffer *MemBuf) const {
return Impl->checkAllRulesInBuffer(RulePrefix, MemBuf);
}
+
+std::pair<uint64_t, std::string>
+RuntimeDyldChecker::getSectionAddr(StringRef FileName, StringRef SectionName,
+ bool LocalAddress) {
+ return Impl->getSectionAddr(FileName, SectionName, LocalAddress);
+}