#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"
#include <cctype>
if (LHSResult.getValue() != RHSResult.getValue()) {
Checker.ErrStream << "Expression '" << Expr << "' is false: "
- << format("0x%lx", LHSResult.getValue())
- << " != " << format("0x%lx", RHSResult.getValue())
+ << format("0x%" PRIx64, LHSResult.getValue())
+ << " != " << format("0x%" PRIx64, RHSResult.getValue())
<< "\n";
return false;
}
std::tie(SubExprResult, RemainingExpr) = evalParensExpr(Expr, PCtx);
else if (Expr[0] == '*')
std::tie(SubExprResult, RemainingExpr) = evalLoadExpr(Expr);
- else if (isalpha(Expr[0]))
+ else if (isalpha(Expr[0]) || Expr[0] == '_')
std::tie(SubExprResult, RemainingExpr) = evalIdentifierExpr(Expr, PCtx);
else if (isdigit(Expr[0]))
std::tie(SubExprResult, RemainingExpr) = evalNumberExpr(Expr);
bool IsInsideLoad) const {
auto SI1 = Stubs.find(FileName);
- if (SI1 == Stubs.end())
- return std::make_pair(0, ("File '" + FileName + "' not found.\n").str());
+ if (SI1 == Stubs.end()) {
+ std::string ErrorMsg = "File '";
+ ErrorMsg += FileName;
+ ErrorMsg += "' not found. ";
+ if (Stubs.empty())
+ ErrorMsg += "No stubs registered.";
+ else {
+ ErrorMsg += "Available files are:";
+ for (const auto& StubEntry : Stubs) {
+ ErrorMsg += " '";
+ ErrorMsg += StubEntry.first;
+ ErrorMsg += "'";
+ }
+ }
+ ErrorMsg += "\n";
+ return std::make_pair(0, ErrorMsg);
+ }
const SectionStubMap &SectionStubs = SI1->second;
auto SI2 = SectionStubs.find(SectionName);
uint64_t Addr;
if (IsInsideLoad) {
- uint64_t SectionBase = getRTDyld().Sections[SectionID].LoadAddress;
- Addr = SectionBase + StubOffset;
- } else {
uintptr_t SectionBase =
reinterpret_cast<uintptr_t>(getRTDyld().Sections[SectionID].Address);
Addr = static_cast<uint64_t>(SectionBase) + StubOffset;
+ } else {
+ uint64_t SectionBase = getRTDyld().Sections[SectionID].LoadAddress;
+ Addr = SectionBase + StubOffset;
}
return std::make_pair(Addr, std::string(""));
}
void RuntimeDyldCheckerImpl::registerStubMap(
- StringRef FileName, unsigned SectionID,
+ StringRef FilePath, unsigned SectionID,
const RuntimeDyldImpl::StubMap &RTDyldStubs) {
+ StringRef FileName = sys::path::filename(FilePath);
const SectionEntry &Section = getRTDyld().Sections[SectionID];
StringRef SectionName = Section.Name;
for (auto &StubMapEntry : RTDyldStubs) {