1#include <dlfcn.h>
2#include <stdio.h>
3
4int
5main (void)
6{
7 void *h = dlopen (file: "$ORIGIN/unload8mod1.so", RTLD_LAZY);
8 if (h == NULL)
9 {
10 puts (s: "dlopen unload8mod1.so failed");
11 return 1;
12 }
13
14 void *h2 = dlopen (file: "$ORIGIN/unload8mod1x.so", RTLD_LAZY);
15 if (h2 == NULL)
16 {
17 puts (s: "dlopen unload8mod1x.so failed");
18 return 1;
19 }
20 dlclose (handle: h2);
21
22 int (*mod1) (void) = dlsym (handle: h, name: "mod1");
23 if (mod1 == NULL)
24 {
25 puts (s: "dlsym failed");
26 return 1;
27 }
28
29 mod1 ();
30 dlclose (handle: h);
31
32 return 0;
33}
34

source code of glibc/elf/unload8.c