blob: b64c000bcc82ff8771451bed95f806159cb180b0 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <dlfcn.h>
2#include <stdlib.h>
3#include <stdio.h>
4#include <string.h>
5
6int main(int argc, char **argv)
7{
8 Dl_info info;
9 int res = 0;
10
11 memset(&info, '\0', sizeof(Dl_info));
12 res = dladdr((void *)1, &info);
13 if (res != 0) {
14 fprintf(stderr, "dladdr() should fail\n");
15 fprintf(stderr, "dli_fname = %s\n", info.dli_fname);
16 fprintf(stderr, "dli_fbase = 0x%08x\n", (unsigned int)info.dli_fbase);
17 fprintf(stderr, "dli_sname = %s\n", info.dli_sname);
18 fprintf(stderr, "dli_saddr = 0x%08x\n", (unsigned int)info.dli_saddr);
19 exit(1);
20 }
21
22 fprintf(stderr, "dladdr() failed as expected\n");
23 return EXIT_SUCCESS;
24}
25