1#include <dlfcn.h>
2#include <stdio.h>
3
4int
5main (void)
6{
7 void *h = dlopen (file: "unload6mod1.so", RTLD_LAZY);
8 if (h == NULL)
9 {
10 puts (s: "dlopen unload6mod1.so failed");
11 return 1;
12 }
13
14 int (*fn) (int);
15 fn = dlsym (handle: h, name: "foo");
16 if (fn == NULL)
17 {
18 puts (s: "dlsym failed");
19 return 1;
20 }
21
22 int val = fn (16);
23 if (val != 24)
24 {
25 printf (format: "foo returned %d != 24\n", val);
26 return 1;
27 }
28
29 return 0;
30}
31

source code of glibc/elf/unload6.c