28#define DEBUG_TYPE "rtdyld"
35 std::unique_ptr<MCSubtargetInfo> STI;
36 std::unique_ptr<MCRegisterInfo>
MRI;
37 std::unique_ptr<MCAsmInfo> MAI;
38 std::unique_ptr<MCContext> Ctx;
39 std::unique_ptr<MCDisassembler> Disassembler;
40 std::unique_ptr<MCInstrInfo> MII;
41 std::unique_ptr<MCInstPrinter> InstPrinter;
57 size_t EQIdx = Expr.
find(
'=');
59 ParseContext OutsideLoad(
false);
65 std::tie(LHSResult, RemainingExpr) =
66 evalComplexExpr(evalSimpleExpr(LHSExpr, OutsideLoad), OutsideLoad);
67 if (LHSResult.hasError())
68 return handleError(Expr, LHSResult);
69 if (RemainingExpr !=
"")
70 return handleError(Expr, unexpectedToken(RemainingExpr, LHSExpr,
""));
75 std::tie(RHSResult, RemainingExpr) =
76 evalComplexExpr(evalSimpleExpr(RHSExpr, OutsideLoad), OutsideLoad);
77 if (RHSResult.hasError())
78 return handleError(Expr, RHSResult);
79 if (RemainingExpr !=
"")
80 return handleError(Expr, unexpectedToken(RemainingExpr, RHSExpr,
""));
82 if (LHSResult.getValue() != RHSResult.getValue()) {
83 Checker.ErrStream <<
"Expression '" << Expr <<
"' is false: "
84 <<
format(
"0x%" PRIx64, LHSResult.getValue())
85 <<
" != " <<
format(
"0x%" PRIx64, RHSResult.getValue())
101 ParseContext(
bool IsInsideLoad) : IsInsideLoad(IsInsideLoad) {}
106 enum class BinOpToken :
unsigned {
118 EvalResult() :
Value(0) {}
120 EvalResult(std::string ErrorMsg)
123 bool hasError()
const {
return ErrorMsg !=
""; }
124 const std::string &getErrorMsg()
const {
return ErrorMsg; }
128 std::string ErrorMsg;
136 if (isalpha(Expr[0]))
137 std::tie(
Token, Remaining) = parseSymbol(Expr);
138 else if (isdigit(Expr[0]))
139 std::tie(
Token, Remaining) = parseNumberString(Expr);
151 std::string ErrorMsg(
"Encountered unexpected token '");
152 ErrorMsg += getTokenForError(TokenStart);
154 ErrorMsg +=
"' while parsing subexpression '";
162 return EvalResult(std::move(ErrorMsg));
165 bool handleError(
StringRef Expr,
const EvalResult &R)
const {
166 assert(
R.hasError() &&
"Not an error result.");
167 Checker.ErrStream <<
"Error evaluating expression '" << Expr
168 <<
"': " <<
R.getErrorMsg() <<
"\n";
172 std::pair<BinOpToken, StringRef> parseBinOpToken(
StringRef Expr)
const {
174 return std::make_pair(BinOpToken::Invalid,
"");
178 return std::make_pair(BinOpToken::ShiftLeft, Expr.
substr(2).
ltrim());
180 return std::make_pair(BinOpToken::ShiftRight, Expr.
substr(2).
ltrim());
186 return std::make_pair(BinOpToken::Invalid, Expr);
188 Op = BinOpToken::Add;
191 Op = BinOpToken::Sub;
194 Op = BinOpToken::BitwiseAnd;
197 Op = BinOpToken::BitwiseOr;
204 EvalResult computeBinOpResult(BinOpToken
Op,
const EvalResult &LHSResult,
205 const EvalResult &RHSResult)
const {
209 case BinOpToken::Add:
210 return EvalResult(LHSResult.getValue() + RHSResult.getValue());
211 case BinOpToken::Sub:
212 return EvalResult(LHSResult.getValue() - RHSResult.getValue());
213 case BinOpToken::BitwiseAnd:
214 return EvalResult(LHSResult.getValue() & RHSResult.getValue());
215 case BinOpToken::BitwiseOr:
216 return EvalResult(LHSResult.getValue() | RHSResult.getValue());
217 case BinOpToken::ShiftLeft:
218 return EvalResult(LHSResult.getValue() << RHSResult.getValue());
219 case BinOpToken::ShiftRight:
220 return EvalResult(LHSResult.getValue() >> RHSResult.getValue());
226 std::pair<StringRef, StringRef> parseSymbol(
StringRef Expr)
const {
228 "abcdefghijklmnopqrstuvwxyz"
229 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
231 return std::make_pair(Expr.
substr(0, FirstNonSymbol),
241 std::pair<EvalResult, StringRef> evalDecodeOperand(
StringRef Expr)
const {
243 return std::make_pair(unexpectedToken(Expr, Expr,
"expected '('"),
"");
246 std::tie(Symbol, RemainingExpr) = parseSymbol(RemainingExpr);
248 if (!Checker.isSymbolValid(Symbol))
249 return std::make_pair(
250 EvalResult((
"Cannot decode unknown symbol '" + Symbol +
"'").str()),
256 std::tie(BinOp, RemainingExpr) = parseBinOpToken(RemainingExpr);
258 case BinOpToken::Add: {
260 std::tie(
Number, RemainingExpr) = evalNumberExpr(RemainingExpr);
264 case BinOpToken::Invalid:
267 return std::make_pair(
268 unexpectedToken(RemainingExpr, RemainingExpr,
269 "expected '+' for offset or ',' if no offset"),
274 return std::make_pair(
275 unexpectedToken(RemainingExpr, RemainingExpr,
"expected ','"),
"");
278 EvalResult OpIdxExpr;
279 std::tie(OpIdxExpr, RemainingExpr) = evalNumberExpr(RemainingExpr);
280 if (OpIdxExpr.hasError())
281 return std::make_pair(OpIdxExpr,
"");
284 return std::make_pair(
285 unexpectedToken(RemainingExpr, RemainingExpr,
"expected ')'"),
"");
291 return std::make_pair(
292 EvalResult((
"Couldn't decode instruction at '" + Symbol +
"'").str()),
295 unsigned OpIdx = OpIdxExpr.getValue();
299 auto TT = Checker.getTripleForSymbol(Checker.getTargetFlag(Symbol));
300 auto TI = getTargetInfo(TT, Checker.getCPU(), Checker.getFeatures());
301 if (
auto E = TI.takeError()) {
302 errs() <<
"Error obtaining instruction printer: "
306 Inst.dump_pretty(ErrMsgStream, TI->InstPrinter.get());
310 if (OpIdx >= Inst.getNumOperands()) {
313 ErrMsgStream <<
"Invalid operand index '" <<
format(
"%i", OpIdx)
314 <<
"' for instruction '" <<
Symbol
315 <<
"'. Instruction has only "
316 <<
format(
"%i", Inst.getNumOperands())
317 <<
" operands.\nInstruction is:\n ";
319 printInst(Symbol, Inst, ErrMsgStream);
320 return {EvalResult(std::move(ErrMsg)),
""};
327 ErrMsgStream <<
"Operand '" <<
format(
"%i", OpIdx) <<
"' of instruction '"
328 <<
Symbol <<
"' is not an immediate.\nInstruction is:\n ";
330 printInst(Symbol, Inst, ErrMsgStream);
331 return {EvalResult(std::move(ErrMsg)),
""};
334 return std::make_pair(EvalResult(
Op.getImm()), RemainingExpr);
343 std::pair<EvalResult, StringRef> evalNextPC(
StringRef Expr,
344 ParseContext PCtx)
const {
346 return std::make_pair(unexpectedToken(Expr, Expr,
"expected '('"),
"");
349 std::tie(Symbol, RemainingExpr) = parseSymbol(RemainingExpr);
351 if (!Checker.isSymbolValid(Symbol))
352 return std::make_pair(
353 EvalResult((
"Cannot decode unknown symbol '" + Symbol +
"'").str()),
357 return std::make_pair(
358 unexpectedToken(RemainingExpr, RemainingExpr,
"expected ')'"),
"");
363 if (!decodeInst(Symbol, Inst, InstSize, 0))
364 return std::make_pair(
365 EvalResult((
"Couldn't decode instruction at '" + Symbol +
"'").str()),
368 uint64_t SymbolAddr = PCtx.IsInsideLoad
369 ? Checker.getSymbolLocalAddr(Symbol)
370 : Checker.getSymbolRemoteAddr(Symbol);
374 auto TT = Checker.getTripleForSymbol(Checker.getTargetFlag(Symbol));
377 uint64_t NextPC = SymbolAddr + InstSize + PCOffset;
379 return std::make_pair(EvalResult(NextPC), RemainingExpr);
387 std::pair<EvalResult, StringRef>
388 evalStubOrGOTAddr(
StringRef Expr, ParseContext PCtx,
bool IsStubAddr)
const {
390 return std::make_pair(unexpectedToken(Expr, Expr,
"expected '('"),
"");
396 size_t ComaIdx = RemainingExpr.
find(
',');
397 StubContainerName = RemainingExpr.
substr(0, ComaIdx).
rtrim();
398 RemainingExpr = RemainingExpr.
substr(ComaIdx).
ltrim();
401 return std::make_pair(
402 unexpectedToken(RemainingExpr, Expr,
"expected ','"),
"");
406 std::tie(Symbol, RemainingExpr) = parseSymbol(RemainingExpr);
412 size_t ClosingBracket = RemainingExpr.
find(
")");
413 KindNameFilter = RemainingExpr.
substr(0, ClosingBracket);
414 RemainingExpr = RemainingExpr.
substr(ClosingBracket);
418 return std::make_pair(
419 unexpectedToken(RemainingExpr, Expr,
"expected ')'"),
"");
423 std::string ErrorMsg;
424 std::tie(StubAddr, ErrorMsg) =
425 Checker.getStubOrGOTAddrFor(StubContainerName, Symbol, KindNameFilter,
426 PCtx.IsInsideLoad, IsStubAddr);
429 return std::make_pair(EvalResult(ErrorMsg),
"");
431 return std::make_pair(EvalResult(StubAddr), RemainingExpr);
434 std::pair<EvalResult, StringRef> evalSectionAddr(
StringRef Expr,
435 ParseContext PCtx)
const {
437 return std::make_pair(unexpectedToken(Expr, Expr,
"expected '('"),
"");
443 size_t ComaIdx = RemainingExpr.
find(
',');
444 FileName = RemainingExpr.
substr(0, ComaIdx).
rtrim();
445 RemainingExpr = RemainingExpr.
substr(ComaIdx).
ltrim();
448 return std::make_pair(
449 unexpectedToken(RemainingExpr, Expr,
"expected ','"),
"");
453 size_t CloseParensIdx = RemainingExpr.
find(
')');
455 RemainingExpr = RemainingExpr.
substr(CloseParensIdx).
ltrim();
458 return std::make_pair(
459 unexpectedToken(RemainingExpr, Expr,
"expected ')'"),
"");
463 std::string ErrorMsg;
464 std::tie(StubAddr, ErrorMsg) = Checker.getSectionAddr(
468 return std::make_pair(EvalResult(ErrorMsg),
"");
470 return std::make_pair(EvalResult(StubAddr), RemainingExpr);
476 std::pair<EvalResult, StringRef> evalIdentifierExpr(
StringRef Expr,
477 ParseContext PCtx)
const {
480 std::tie(Symbol, RemainingExpr) = parseSymbol(Expr);
483 if (Symbol ==
"decode_operand")
484 return evalDecodeOperand(RemainingExpr);
485 else if (Symbol ==
"next_pc")
486 return evalNextPC(RemainingExpr, PCtx);
487 else if (Symbol ==
"stub_addr")
488 return evalStubOrGOTAddr(RemainingExpr, PCtx,
true);
489 else if (Symbol ==
"got_addr")
490 return evalStubOrGOTAddr(RemainingExpr, PCtx,
false);
491 else if (Symbol ==
"section_addr")
492 return evalSectionAddr(RemainingExpr, PCtx);
494 if (!Checker.isSymbolValid(Symbol)) {
495 std::string ErrMsg(
"No known address for symbol '");
498 if (
Symbol.starts_with(
"L"))
499 ErrMsg +=
" (this appears to be an assembler local label - "
500 " perhaps drop the 'L'?)";
502 return std::make_pair(EvalResult(ErrMsg),
"");
508 uint64_t Value = PCtx.IsInsideLoad ? Checker.getSymbolLocalAddr(Symbol)
509 : Checker.getSymbolRemoteAddr(Symbol);
512 return std::make_pair(EvalResult(
Value), RemainingExpr);
517 std::pair<StringRef, StringRef> parseNumberString(
StringRef Expr)
const {
522 FirstNonDigit = Expr.
size();
526 FirstNonDigit = Expr.
size();
528 return std::make_pair(Expr.
substr(0, FirstNonDigit),
529 Expr.
substr(FirstNonDigit));
535 std::pair<EvalResult, StringRef> evalNumberExpr(
StringRef Expr)
const {
538 std::tie(ValueStr, RemainingExpr) = parseNumberString(Expr);
540 if (ValueStr.
empty() || !isdigit(ValueStr[0]))
541 return std::make_pair(
542 unexpectedToken(RemainingExpr, RemainingExpr,
"expected number"),
"");
545 return std::make_pair(EvalResult(
Value), RemainingExpr);
551 std::pair<EvalResult, StringRef> evalParensExpr(
StringRef Expr,
552 ParseContext PCtx)
const {
554 EvalResult SubExprResult;
556 std::tie(SubExprResult, RemainingExpr) =
557 evalComplexExpr(evalSimpleExpr(Expr.
substr(1).
ltrim(), PCtx), PCtx);
558 if (SubExprResult.hasError())
559 return std::make_pair(SubExprResult,
"");
561 return std::make_pair(
562 unexpectedToken(RemainingExpr, Expr,
"expected ')'"),
"");
564 return std::make_pair(SubExprResult, RemainingExpr);
571 std::pair<EvalResult, StringRef> evalLoadExpr(
StringRef Expr)
const {
577 return std::make_pair(EvalResult(
"Expected '{' following '*'."),
"");
579 EvalResult ReadSizeExpr;
580 std::tie(ReadSizeExpr, RemainingExpr) = evalNumberExpr(RemainingExpr);
581 if (ReadSizeExpr.hasError())
582 return std::make_pair(ReadSizeExpr, RemainingExpr);
583 uint64_t ReadSize = ReadSizeExpr.getValue();
584 if (ReadSize < 1 || ReadSize > 8)
585 return std::make_pair(EvalResult(
"Invalid size for dereference."),
"");
587 return std::make_pair(EvalResult(
"Missing '}' for dereference."),
"");
591 ParseContext LoadCtx(
true);
592 EvalResult LoadAddrExprResult;
593 std::tie(LoadAddrExprResult, RemainingExpr) =
594 evalComplexExpr(evalSimpleExpr(RemainingExpr, LoadCtx), LoadCtx);
596 if (LoadAddrExprResult.hasError())
597 return std::make_pair(LoadAddrExprResult,
"");
599 uint64_t LoadAddr = LoadAddrExprResult.getValue();
604 return std::make_pair(0, RemainingExpr);
606 return std::make_pair(
607 EvalResult(Checker.readMemoryAtAddr(LoadAddr, ReadSize)),
618 std::pair<EvalResult, StringRef> evalSimpleExpr(
StringRef Expr,
619 ParseContext PCtx)
const {
620 EvalResult SubExprResult;
624 return std::make_pair(EvalResult(
"Unexpected end of expression"),
"");
627 std::tie(SubExprResult, RemainingExpr) = evalParensExpr(Expr, PCtx);
628 else if (Expr[0] ==
'*')
629 std::tie(SubExprResult, RemainingExpr) = evalLoadExpr(Expr);
630 else if (isalpha(Expr[0]) || Expr[0] ==
'_')
631 std::tie(SubExprResult, RemainingExpr) = evalIdentifierExpr(Expr, PCtx);
632 else if (isdigit(Expr[0]))
633 std::tie(SubExprResult, RemainingExpr) = evalNumberExpr(Expr);
635 return std::make_pair(
636 unexpectedToken(Expr, Expr,
637 "expected '(', '*', identifier, or number"),
"");
639 if (SubExprResult.hasError())
640 return std::make_pair(SubExprResult, RemainingExpr);
644 std::tie(SubExprResult, RemainingExpr) =
645 evalSliceExpr(std::make_pair(SubExprResult, RemainingExpr));
647 return std::make_pair(SubExprResult, RemainingExpr);
657 std::pair<EvalResult, StringRef>
658 evalSliceExpr(
const std::pair<EvalResult, StringRef> &Ctx)
const {
659 EvalResult SubExprResult;
661 std::tie(SubExprResult, RemainingExpr) = Ctx;
666 EvalResult HighBitExpr;
667 std::tie(HighBitExpr, RemainingExpr) = evalNumberExpr(RemainingExpr);
669 if (HighBitExpr.hasError())
670 return std::make_pair(HighBitExpr, RemainingExpr);
673 return std::make_pair(
674 unexpectedToken(RemainingExpr, RemainingExpr,
"expected ':'"),
"");
677 EvalResult LowBitExpr;
678 std::tie(LowBitExpr, RemainingExpr) = evalNumberExpr(RemainingExpr);
680 if (LowBitExpr.hasError())
681 return std::make_pair(LowBitExpr, RemainingExpr);
684 return std::make_pair(
685 unexpectedToken(RemainingExpr, RemainingExpr,
"expected ']'"),
"");
688 unsigned HighBit = HighBitExpr.getValue();
689 unsigned LowBit = LowBitExpr.getValue();
691 uint64_t SlicedValue = (SubExprResult.getValue() >> LowBit) & Mask;
692 return std::make_pair(EvalResult(SlicedValue), RemainingExpr);
701 std::pair<EvalResult, StringRef>
702 evalComplexExpr(
const std::pair<EvalResult, StringRef> &LHSAndRemaining,
703 ParseContext PCtx)
const {
704 EvalResult LHSResult;
706 std::tie(LHSResult, RemainingExpr) = LHSAndRemaining;
710 if (LHSResult.hasError() || RemainingExpr ==
"")
711 return std::make_pair(LHSResult, RemainingExpr);
715 std::tie(BinOp, RemainingExpr) = parseBinOpToken(RemainingExpr);
718 if (BinOp == BinOpToken::Invalid)
719 return std::make_pair(LHSResult, RemainingExpr);
722 EvalResult RHSResult;
723 std::tie(RHSResult, RemainingExpr) = evalSimpleExpr(RemainingExpr, PCtx);
726 if (RHSResult.hasError())
727 return std::make_pair(RHSResult, RemainingExpr);
731 EvalResult ThisResult(computeBinOpResult(BinOp, LHSResult, RHSResult));
733 return evalComplexExpr(std::make_pair(ThisResult, RemainingExpr), PCtx);
738 auto TT = Checker.getTripleForSymbol(Checker.getTargetFlag(Symbol));
739 auto TI = getTargetInfo(TT, Checker.getCPU(), Checker.getFeatures());
741 if (
auto E = TI.takeError()) {
742 errs() <<
"Error obtaining disassembler: " <<
toString(std::move(E))
747 StringRef SymbolMem = Checker.getSymbolContent(Symbol);
752 TI->Disassembler->getInstruction(Inst,
Size, SymbolBytes, 0,
nulls());
760 auto TripleName =
TT.str();
761 std::string ErrorStr;
765 return make_error<StringError>(
"Error accessing target '" + TripleName +
769 std::unique_ptr<MCSubtargetInfo> STI(
772 return make_error<StringError>(
"Unable to create subtarget for " +
778 return make_error<StringError>(
"Unable to create target register info "
784 std::unique_ptr<MCAsmInfo> MAI(
787 return make_error<StringError>(
"Unable to create target asm info " +
791 auto Ctx = std::make_unique<MCContext>(
Triple(TripleName), MAI.get(),
792 MRI.get(), STI.get());
794 std::unique_ptr<MCDisassembler> Disassembler(
797 return make_error<StringError>(
"Unable to create disassembler for " +
803 return make_error<StringError>(
"Unable to create instruction info for" +
808 Triple(TripleName), 0, *MAI, *MII, *
MRI));
810 return make_error<StringError>(
811 "Unable to create instruction printer for" + TripleName,
814 return TargetInfo({TheTarget, std::move(STI), std::move(
MRI),
815 std::move(MAI), std::move(Ctx), std::move(Disassembler),
816 std::move(MII), std::move(InstPrinter)});
822 IsSymbolValidFunction IsSymbolValid, GetSymbolInfoFunction GetSymbolInfo,
823 GetSectionInfoFunction GetSectionInfo, GetStubInfoFunction GetStubInfo,
826 : IsSymbolValid(
std::
move(IsSymbolValid)),
827 GetSymbolInfo(
std::
move(GetSymbolInfo)),
828 GetSectionInfo(
std::
move(GetSectionInfo)),
829 GetStubInfo(
std::
move(GetStubInfo)), GetGOTInfo(
std::
move(GetGOTInfo)),
831 TF(
std::
move(TF)), ErrStream(ErrStream) {}
834 CheckExpr = CheckExpr.
trim();
835 LLVM_DEBUG(
dbgs() <<
"RuntimeDyldChecker: Checking '" << CheckExpr
838 bool Result =
P.evaluate(CheckExpr);
841 << (Result ?
"passed" :
"FAILED") <<
".\n");
847 bool DidAllTestsPass =
true;
848 unsigned NumRules = 0;
850 std::string CheckExpr;
854 while (LineStart != MemBuf->
getBufferEnd() && isSpace(*LineStart))
857 while (LineStart != MemBuf->
getBufferEnd() && *LineStart !=
'\0') {
858 const char *LineEnd = LineStart;
859 while (LineEnd != MemBuf->
getBufferEnd() && *LineEnd !=
'\r' &&
863 StringRef Line(LineStart, LineEnd - LineStart);
864 if (Line.starts_with(RulePrefix))
865 CheckExpr += Line.substr(RulePrefix.
size()).str();
868 if (!CheckExpr.empty()) {
870 if (CheckExpr.back() !=
'\\') {
871 DidAllTestsPass &=
check(CheckExpr);
875 CheckExpr.pop_back();
880 while (LineStart != MemBuf->
getBufferEnd() && isSpace(*LineStart))
883 return DidAllTestsPass && (NumRules != 0);
886bool RuntimeDyldCheckerImpl::isSymbolValid(
StringRef Symbol)
const {
887 return IsSymbolValid(Symbol);
891 auto SymInfo = GetSymbolInfo(Symbol);
901 reinterpret_cast<uintptr_t
>(
SymInfo->getContent().data()));
905 auto SymInfo = GetSymbolInfo(Symbol);
911 return SymInfo->getTargetAddress();
915 unsigned Size)
const {
916 uintptr_t PtrSizedAddr =
static_cast<uintptr_t
>(SrcAddr);
917 assert(PtrSizedAddr == SrcAddr &&
"Linker memory pointer out-of-range.");
918 void *
Ptr =
reinterpret_cast<void*
>(PtrSizedAddr);
922 return support::endian::read<uint8_t>(
Ptr, Endianness);
924 return support::endian::read<uint16_t>(
Ptr, Endianness);
926 return support::endian::read<uint32_t>(
Ptr, Endianness);
928 return support::endian::read<uint64_t>(
Ptr, Endianness);
934 auto SymInfo = GetSymbolInfo(Symbol);
939 return {
SymInfo->getContent().data(),
SymInfo->getContent().size()};
943 auto SymInfo = GetSymbolInfo(Symbol);
948 return SymInfo->getTargetFlags();
952RuntimeDyldCheckerImpl::getTripleForSymbol(
TargetFlagsType Flag)
const {
955 switch (
TT.getArch()) {
972std::pair<uint64_t, std::string> RuntimeDyldCheckerImpl::getSectionAddr(
975 auto SecInfo = GetSectionInfo(FileName,
SectionName);
983 return std::make_pair(0, std::move(ErrMsg));
992 if (SecInfo->isZeroFill())
997 Addr = SecInfo->getTargetAddress();
999 return std::make_pair(
Addr,
"");
1002std::pair<uint64_t, std::string> RuntimeDyldCheckerImpl::getStubOrGOTAddrFor(
1004 bool IsInsideLoad,
bool IsStubAddr)
const {
1007 "Kind name filter only supported for stubs");
1009 IsStubAddr ? GetStubInfo(StubContainerName, SymbolName, StubKindFilter)
1019 return std::make_pair((
uint64_t)0, std::move(ErrMsg));
1025 if (StubInfo->isZeroFill())
1026 return std::make_pair((
uint64_t)0,
"Detected zero-filled stub/GOT entry");
1029 Addr = StubInfo->getTargetAddress();
1031 return std::make_pair(
Addr,
"");
1048 return Impl->check(CheckExpr);
1053 return Impl->checkAllRulesInBuffer(RulePrefix, MemBuf);
1056std::pair<uint64_t, std::string>
1058 bool LocalAddress) {
1059 return Impl->getSectionAddr(FileName,
SectionName, LocalAddress);
unsigned const MachineRegisterInfo * MRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents an Operation in the Expression.
Tagged union holding either a T or a Error.
DecodeStatus
Ternary decode status.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent operands of the MCInst class.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
const char * getBufferEnd() const
const char * getBufferStart() const
bool evaluate(StringRef Expr) const
RuntimeDyldCheckerExprEval(const RuntimeDyldCheckerImpl &Checker, raw_ostream &ErrStream)
bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const
bool check(StringRef CheckExpr) const
RuntimeDyldCheckerImpl(IsSymbolValidFunction IsSymbolValid, GetSymbolInfoFunction GetSymbolInfo, GetSectionInfoFunction GetSectionInfo, GetStubInfoFunction GetStubInfo, GetGOTInfoFunction GetGOTInfo, llvm::endianness Endianness, Triple TT, StringRef CPU, SubtargetFeatures TF, llvm::raw_ostream &ErrStream)
std::pair< uint64_t, std::string > getSectionAddr(StringRef FileName, StringRef SectionName, bool LocalAddress)
Returns the address of the requested section (or an error message in the second element of the pair i...
bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const
Scan the given memory buffer for lines beginning with the string in RulePrefix.
bool check(StringRef CheckExpr) const
Check a single expression against the attached RuntimeDyld instance.
std::function< bool(StringRef Symbol)> IsSymbolValidFunction
RuntimeDyldChecker(IsSymbolValidFunction IsSymbolValid, GetSymbolInfoFunction GetSymbolInfo, GetSectionInfoFunction GetSectionInfo, GetStubInfoFunction GetStubInfo, GetGOTInfoFunction GetGOTInfo, llvm::endianness Endianness, Triple TT, StringRef CPU, SubtargetFeatures TF, raw_ostream &ErrStream)
std::function< Expected< MemoryRegionInfo >(StringRef StubContainer, StringRef TargetName, StringRef StubKindFilter)> GetStubInfoFunction
std::function< Expected< MemoryRegionInfo >(StringRef FileName, StringRef SectionName)> GetSectionInfoFunction
std::function< Expected< MemoryRegionInfo >(StringRef GOTContainer, StringRef TargetName)> GetGOTInfoFunction
std::function< Expected< MemoryRegionInfo >(StringRef SymbolName)> GetSymbolInfoFunction
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
static constexpr size_t npos
const unsigned char * bytes_begin() const
size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
Manages the enabling and disabling of subtarget specific features.
std::string getString() const
Returns features as a string.
Target - Wrapper for Target specific information.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Triple - Helper class for working with autoconf configuration names.
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
This is an optimization pass for GlobalISel generic memory operations.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
uint8_t TargetFlagsType
Holds target-specific properties for a symbol.
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DWARFExpression::Operation Op
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
const char * toString(DWARFSectionKind Kind)
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
Convert a pointer to a JITTargetAddress.
Implement std::hash so that hash_code can be used in STL containers.
SymInfo contains information about symbol: it's address and section index which is -1LL for absolute ...
static const Target * lookupTarget(StringRef Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.