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