LLVM 20.0.0git
Classes | Public Types | Public Member Functions | List of all members
llvm::RuntimeDyldChecker Class Reference

RuntimeDyld invariant checker for verifying that RuntimeDyld has correctly applied relocations. More...

#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"

Classes

class  MemoryRegionInfo
 

Public Types

using IsSymbolValidFunction = std::function< bool(StringRef Symbol)>
 
using GetSymbolInfoFunction = std::function< Expected< MemoryRegionInfo >(StringRef SymbolName)>
 
using GetSectionInfoFunction = std::function< Expected< MemoryRegionInfo >(StringRef FileName, StringRef SectionName)>
 
using GetStubInfoFunction = std::function< Expected< MemoryRegionInfo >(StringRef StubContainer, StringRef TargetName, StringRef StubKindFilter)>
 
using GetGOTInfoFunction = std::function< Expected< MemoryRegionInfo >(StringRef GOTContainer, StringRef TargetName)>
 

Public Member Functions

 RuntimeDyldChecker (IsSymbolValidFunction IsSymbolValid, GetSymbolInfoFunction GetSymbolInfo, GetSectionInfoFunction GetSectionInfo, GetStubInfoFunction GetStubInfo, GetGOTInfoFunction GetGOTInfo, llvm::endianness Endianness, Triple TT, StringRef CPU, SubtargetFeatures TF, raw_ostream &ErrStream)
 
 ~RuntimeDyldChecker ()
 
bool check (StringRef CheckExpr) const
 Check a single expression against the attached RuntimeDyld instance.
 
bool checkAllRulesInBuffer (StringRef RulePrefix, MemoryBuffer *MemBuf) const
 Scan the given memory buffer for lines beginning with the string in RulePrefix.
 
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 if the address cannot be found).
 
std::optional< uint64_tgetSectionLoadAddress (void *LocalAddress) const
 If there is a section at the given local address, return its load address, otherwise return std::nullopt.
 

Detailed Description

RuntimeDyld invariant checker for verifying that RuntimeDyld has correctly applied relocations.

The RuntimeDyldChecker class evaluates expressions against an attached RuntimeDyld instance to verify that relocations have been applied correctly.

The expression language supports basic pointer arithmetic and bit-masking, and has limited disassembler integration for accessing instruction operands and the next PC (program counter) address for each instruction.

The language syntax is:

check = expr '=' expr

expr = binary_expr | sliceable_expr

sliceable_expr = '*{' number '}' load_addr_expr [slice] | '(' expr ')' [slice] | ident_expr [slice] | number [slice]

slice = '[' high-bit-index ':' low-bit-index ']'

load_addr_expr = symbol | '(' symbol '+' number ')' | '(' symbol '-' number ')'

ident_expr = 'decode_operand' '(' symbol ',' operand-index ')' | 'next_pc' '(' symbol ')' | 'stub_addr' '(' stub-container-name ',' symbol ')' | 'got_addr' '(' stub-container-name ',' symbol ')' | 'section_addr' '(' stub-container-name ',' symbol ')' | symbol

binary_expr = expr '+' expr | expr '-' expr | expr '&' expr | expr '|' expr | expr '<<' expr | expr '>>' expr

Definition at line 79 of file RuntimeDyldChecker.h.

Member Typedef Documentation

◆ GetGOTInfoFunction

Definition at line 158 of file RuntimeDyldChecker.h.

◆ GetSectionInfoFunction

Definition at line 154 of file RuntimeDyldChecker.h.

◆ GetStubInfoFunction

using llvm::RuntimeDyldChecker::GetStubInfoFunction = std::function<Expected<MemoryRegionInfo>( StringRef StubContainer, StringRef TargetName, StringRef StubKindFilter)>

Definition at line 156 of file RuntimeDyldChecker.h.

◆ GetSymbolInfoFunction

Definition at line 152 of file RuntimeDyldChecker.h.

◆ IsSymbolValidFunction

Definition at line 151 of file RuntimeDyldChecker.h.

Constructor & Destructor Documentation

◆ RuntimeDyldChecker()

RuntimeDyldChecker::RuntimeDyldChecker ( IsSymbolValidFunction  IsSymbolValid,
GetSymbolInfoFunction  GetSymbolInfo,
GetSectionInfoFunction  GetSectionInfo,
GetStubInfoFunction  GetStubInfo,
GetGOTInfoFunction  GetGOTInfo,
llvm::endianness  Endianness,
Triple  TT,
StringRef  CPU,
SubtargetFeatures  TF,
raw_ostream ErrStream 
)

Definition at line 1035 of file RuntimeDyldChecker.cpp.

◆ ~RuntimeDyldChecker()

RuntimeDyldChecker::~RuntimeDyldChecker ( )
default

Member Function Documentation

◆ check()

bool RuntimeDyldChecker::check ( StringRef  CheckExpr) const

Check a single expression against the attached RuntimeDyld instance.

Definition at line 1048 of file RuntimeDyldChecker.cpp.

◆ checkAllRulesInBuffer()

bool RuntimeDyldChecker::checkAllRulesInBuffer ( StringRef  RulePrefix,
MemoryBuffer MemBuf 
) const

Scan the given memory buffer for lines beginning with the string in RulePrefix.

The remainder of the line is passed to the check method to be evaluated as an expression.

Definition at line 1052 of file RuntimeDyldChecker.cpp.

◆ getSectionAddr()

std::pair< uint64_t, std::string > RuntimeDyldChecker::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 if the address cannot be found).

if 'LocalAddress' is true, this returns the address of the section within the linker's memory. If 'LocalAddress' is false it returns the address within the target process (i.e. the load address).

Definition at line 1058 of file RuntimeDyldChecker.cpp.

◆ getSectionLoadAddress()

std::optional< uint64_t > llvm::RuntimeDyldChecker::getSectionLoadAddress ( void *  LocalAddress) const

If there is a section at the given local address, return its load address, otherwise return std::nullopt.


The documentation for this class was generated from the following files: