MachoResolveAddress
Description
Look up the symbol whose value is closest-not-greater than vaddr and within a reasonable function span (next symbol’s value or the segment end).
vaddr is the file-relative virtual address: for a runtime IP in a PIE binary, subtract the slide first.
Success
Returns a pointer to the matching MachoSymbol.
Failure
Returns NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
MachO.c:162:
// Address at the function start.
const MachoSymbol *s = MachoResolveAddress(&m, 0x100000010ull);
bool ok = s && s->name && ZstrCompare(s->name, "my_function") == 0;- In
MachO.c:166:
// Address just past the start, still inside the function body.
s = MachoResolveAddress(&m, 0x100000020ull);
ok = ok && s && ZstrCompare(s->name, "my_function") == 0;- In
MachO.c:170:
// Address below the symbol value: no match.
s = MachoResolveAddress(&m, 0x100000000ull);
ok = ok && s == NULL;- In
MachO.c:258:
u64 vaddr = runtime_addr - slide;
const MachoSymbol *sym = MachoResolveAddress(&m, vaddr);
bool ok = sym != NULL && sym->name != NULL &&
ZstrFindSubstring(sym->name, "test_macho_resolves_running_binary_symbol") != NULL;- In
MachoCache.c:214:
// (1) Main file's LC_SYMTAB.
const MachoSymbol *s = MachoResolveAddress(&entry->main, file_relative);
if (s && s->name && s->name[0]) {
*out_name = s->name;- In
MachoCache.c:224:
// (2) Sidecar dSYM's LC_SYMTAB.
if (entry_open_dsym(entry, self->allocator)) {
s = MachoResolveAddress(&entry->dsym, file_relative);
if (s && s->name && s->name[0]) {
*out_name = s->name;- In
MachO.c:482:
// same section (or the section end). N_STAB entries are skipped:
// stab iff any of the high three bits of n_type is set.
const MachoSymbol *MachoResolveAddress(const Macho *self, u64 vaddr) {
if (!self || self->symbols.length == 0)
return NULL;
Last updated on