| 1580 | } |
| 1581 | |
| 1582 | kitty_soinfo_t LinkerScannerMgr::infoFromSoInfo_(uintptr_t si, const std::vector<KittyMemoryEx::ProcMap> &maps) const |
| 1583 | { |
| 1584 | kitty_soinfo_t info{}; |
| 1585 | |
| 1586 | if (!_pMem || !isValid() || !_init) |
| 1587 | return info; |
| 1588 | |
| 1589 | std::vector<char> si_buf(KT_SOINFO_BUFFER_SZ, 0); |
| 1590 | if (!_pMem->Read(si, si_buf.data(), KT_SOINFO_BUFFER_SZ)) |
| 1591 | return info; |
| 1592 | |
| 1593 | info.ptr = si; |
| 1594 | info.base = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.base); |
| 1595 | info.size = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.size); |
| 1596 | info.phdr = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.phdr); |
| 1597 | info.phnum = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.phnum); |
| 1598 | info.dyn = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.dyn); |
| 1599 | info.strtab = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.strtab); |
| 1600 | info.symtab = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.symtab); |
| 1601 | info.strsz = _soinfo_offsets.strsz ? *(uintptr_t *)(si_buf.data() + _soinfo_offsets.strsz) : 0; |
| 1602 | info.bias = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.bias); |
| 1603 | info.next = *(uintptr_t *)(si_buf.data() + _soinfo_offsets.next); |
| 1604 | info.e_machine = header().e_machine; |
| 1605 | |
| 1606 | uintptr_t start_map_addr = info.base; |
| 1607 | if (start_map_addr == 0) |
| 1608 | start_map_addr = info.base; |
| 1609 | if (start_map_addr == 0) |
| 1610 | start_map_addr = info.bias; |
| 1611 | if (start_map_addr == 0) |
| 1612 | start_map_addr = info.phdr; |
| 1613 | if (start_map_addr == 0) |
| 1614 | start_map_addr = info.dyn; |
| 1615 | if (start_map_addr == 0) |
| 1616 | start_map_addr = info.strtab; |
| 1617 | if (start_map_addr == 0) |
| 1618 | start_map_addr = info.symtab; |
| 1619 | |
| 1620 | auto si_map = KittyMemoryEx::getAddressMap(_pMem->processID(), start_map_addr, maps); |
| 1621 | if (si_map.isValid()) |
| 1622 | { |
| 1623 | info.path = si_map.pathname; |
| 1624 | info.realpath = si_map.pathname; |
| 1625 | if (si_map.offset != 0) |
| 1626 | { |
| 1627 | KittyUtils::Zip::ZipEntryInfo ent{}; |
| 1628 | if (KittyUtils::Zip::findEntryInfoByDataOffset(si_map.pathname, si_map.offset, &ent) && |
| 1629 | !ent.fileName.empty()) |
| 1630 | { |
| 1631 | info.realpath += '!'; |
| 1632 | info.realpath += ent.fileName; |
| 1633 | } |
| 1634 | } |
| 1635 | } |
| 1636 | |
| 1637 | return info; |
| 1638 | } |
| 1639 |
nothing calls this directly
no test coverage detected