MCPcopy Create free account
hub / github.com/InoriRus/Kyty / FindProgramByAddr

Method FindProgramByAddr

source/emulator/src/Loader/RuntimeLinker.cpp:950–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

948}
949
950Program* RuntimeLinker::FindProgramByAddr(uint64_t vaddr)
951{
952 Core::LockGuard lock(m_mutex);
953
954 for (auto* p: m_programs)
955 {
956 const auto* ehdr = p->elf->GetEhdr();
957 const auto* phdr = p->elf->GetPhdr();
958
959 EXIT_IF(phdr == nullptr || ehdr == nullptr);
960
961 for (Elf64_Half i = 0; i < ehdr->e_phnum; i++)
962 {
963 if (phdr[i].p_memsz != 0 && (phdr[i].p_type == PT_LOAD || phdr[i].p_type == PT_OS_RELRO))
964 {
965 uint64_t segment_addr = phdr[i].p_vaddr + p->base_vaddr;
966 uint64_t segment_size = get_aligned_size(phdr + i);
967
968 if (vaddr >= segment_addr && vaddr < segment_addr + segment_size)
969 {
970 return p;
971 }
972 }
973 }
974 }
975
976 return nullptr;
977}
978
979void RuntimeLinker::StackTrace(uint64_t frame_ptr)
980{

Callers 3

CreateObjectMethod · 0.80
elf_phdr_match_addrFunction · 0.80

Calls 3

GetEhdrMethod · 0.80
GetPhdrMethod · 0.80
get_aligned_sizeFunction · 0.70

Tested by

no test coverage detected