56 uintptr_t addr_int = (uintptr_t)addr;
58 uint32_t image_count = _dyld_image_count();
59 for (uint32_t i = 0; i < image_count && count < max_matches; i++) {
60 const char *image_name = _dyld_get_image_name(i);
61 const struct mach_header_64 *header = (
const struct mach_header_64 *)_dyld_get_image_header(i);
62 intptr_t slide = _dyld_get_image_vmaddr_slide(i);
64 if (!header || !image_name) {
69 uint64_t image_size = get_image_size_from_header(header);
70 if (image_size == 0) {
75 uintptr_t base = (uintptr_t)header + slide;
76 uintptr_t end = base + image_size;
79 if (addr_int >= base && addr_int < end) {
82 matches[count].file_offset = addr_int - base;
85 log_debug(
"[macOS dyld] addr=%p matches %s (offset=%lx, base=%p, slide=%ld)", addr, image_name,
86 matches[count].file_offset, (
void *)base, slide);