Skip to content

Instantly share code, notes, and snippets.

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

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");
if (dladdr(sym, &dlip) == 0) {
perror("dladdr failed");
printf("malloc: 0x%x in %s\n", sym, dlip.dli_fname);
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.