(root)/
glibc-2.38/
elf/
tst-tls18.c
       1  #include <dlfcn.h>
       2  #include <stdlib.h>
       3  #include <stdio.h>
       4  
       5  static int
       6  do_test (void)
       7  {
       8    char modname[sizeof "tst-tlsmod18aXX.so"];
       9    void *h[20];
      10    for (int i = 0; i < 20; i++)
      11      {
      12        snprintf (modname, sizeof modname, "tst-tlsmod18a%d.so", i);
      13        h[i] = dlopen (modname, RTLD_LAZY);
      14        if (h[i] == NULL)
      15  	{
      16  	  printf ("unexpectedly failed to open %s", modname);
      17  	  exit (1);
      18  	}
      19      }
      20  
      21    for (int i = 0; i < 20; i++)
      22      {
      23        int (*fp) (void) = (int (*) (void)) dlsym (h[i], "test");
      24        if (fp == NULL)
      25  	{
      26  	  printf ("cannot find test in tst-tlsmod18a%d.so", i);
      27  	  exit (1);
      28  	}
      29  
      30        if (fp ())
      31  	exit (1);
      32      }
      33  
      34    return 0;
      35  }
      36  
      37  #include <support/test-driver.c>