[e86079]: tools-for-build / os-provides-dladdr-test.c Maximize Restore History

Download this file

os-provides-dladdr-test.c    21 lines (17 with data), 459 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
/* test to build and run so that we know if we have dladdr
*/
/* bloody FSF dlcfn.h won't give us dladdr without this */
#define _GNU_SOURCE
#include <dlfcn.h>
int main ()
{
void * handle = dlopen((void*)0, RTLD_GLOBAL | RTLD_NOW);
void * addr = dlsym(handle, "printf");
Dl_info * info = (Dl_info*) malloc(sizeof(Dl_info));
dladdr(addr, info);
if (strcmp(info->dli_sname, "printf")) {
return 1;
} else {
return 104;
}
}