Skip to content

Instantly share code, notes, and snippets.

@alanc alanc/dlmalloc.c
Created Feb 1, 2019

Embed
What would you like to do?
How to tell which library a function is from
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
void *sym;
Dl_info_t dlip;
sym = dlsym(RTLD_PROBE, "malloc");
if (sym == NULL) {
perror("dlsym failed");
exit(1);
}
if (dladdr(sym, &dlip) == 0) {
perror("dladdr failed");
exit(1);
}
printf("malloc: 0x%x in %s\n", sym, dlip.dli_fname);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.