(root)/
glibc-2.38/
elf/
unload7.c
       1  #include <dlfcn.h>
       2  #include <stdio.h>
       3  
       4  int
       5  main (void)
       6  {
       7    void *h = dlopen ("$ORIGIN/unload7mod1.so", RTLD_LAZY);
       8    if (h == NULL)
       9      {
      10        puts ("dlopen unload7mod1.so failed");
      11        return 1;
      12      }
      13  
      14    int (*fn) (void);
      15    fn = dlsym (h, "foo");
      16    if (fn == NULL)
      17      {
      18        puts ("dlsym failed");
      19        return 1;
      20      }
      21  
      22    int ret = 0;
      23    if (fn () == 0)
      24      ++ret;
      25  
      26    void *h2 = dlopen ("$ORIGIN/unload7mod2.so", RTLD_LAZY);
      27    if (h2 == NULL)
      28      {
      29        puts ("dlopen unload7mod2.so failed");
      30        return 1;
      31      }
      32    dlclose (h2);
      33  
      34    if (fn () == 0)
      35      ++ret;
      36  
      37    dlclose (h);
      38    return ret;
      39  }