(root)/
glibc-2.38/
elf/
tst-tls4.c
       1  #include <dlfcn.h>
       2  #include <stdio.h>
       3  #include <stdlib.h>
       4  
       5  
       6  static int
       7  do_test (void)
       8  {
       9    static const char modname[] = "tst-tlsmod2.so";
      10    int result = 0;
      11    int *foop;
      12    int (*fp) (int, int *);
      13    void *h;
      14  
      15    h = dlopen (modname, RTLD_LAZY);
      16    if (h == NULL)
      17      {
      18        printf ("cannot open '%s': %s\n", modname, dlerror ());
      19        exit (1);
      20      }
      21  
      22    fp = dlsym (h, "in_dso");
      23    if (fp == NULL)
      24      {
      25        printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
      26        exit (1);
      27      }
      28  
      29    result |= fp (0, NULL);
      30  
      31    foop = dlsym (h, "foo");
      32    if (foop == NULL)
      33      {
      34        printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
      35        exit (1);
      36      }
      37    if (*foop != 16)
      38      {
      39        puts ("foo != 16");
      40        result = 1;
      41      }
      42  
      43    dlclose (h);
      44  
      45    return result;
      46  }
      47  
      48  
      49  #include <support/test-driver.c>