1#include <dlfcn.h>
2#include <stdlib.h>
3#include <stdio.h>
4
5static int
6do_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 (s: modname, maxlen: sizeof modname, format: "tst-tlsmod18a%d.so", i);
13 h[i] = dlopen (file: modname, RTLD_LAZY);
14 if (h[i] == NULL)
15 {
16 printf (format: "unexpectedly failed to open %s", modname);
17 exit (status: 1);
18 }
19 }
20
21 for (int i = 0; i < 20; i++)
22 {
23 int (*fp) (void) = (int (*) (void)) dlsym (handle: h[i], name: "test");
24 if (fp == NULL)
25 {
26 printf (format: "cannot find test in tst-tlsmod18a%d.so", i);
27 exit (status: 1);
28 }
29
30 if (fp ())
31 exit (status: 1);
32 }
33
34 return 0;
35}
36
37#include <support/test-driver.c>
38

source code of glibc/elf/tst-tls18.c