Mention IFUNC enhancements to testsuite in NEWS.
[platform/upstream/glibc.git] / elf / reldep7.c
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 int
6 main (void)
7 {
8   void *h1;
9   void *h2;
10   void *mod1_bar, *mod2_bar;
11
12   h1 = dlopen ("reldep7mod1.so", RTLD_GLOBAL | RTLD_LAZY);
13   if (h1 == NULL)
14     {
15       printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
16       exit (1);
17     }
18
19   h2 = dlopen ("reldep7mod2.so", RTLD_GLOBAL | RTLD_LAZY);
20   if (h2 == NULL)
21     {
22       printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
23       exit (1);
24     }
25
26   mod1_bar = dlsym (h1, "mod1_bar");
27   if (mod1_bar == NULL)
28     {
29       printf ("cannot get address of \"mod1_bar\": %s\n", dlerror ());
30       exit (1);
31     }
32
33   mod2_bar = dlsym (h2, "mod2_bar");
34   if (mod2_bar == NULL)
35     {
36       printf ("cannot get address of \"mod2_bar\": %s\n", dlerror ());
37       exit (1);
38     }
39
40   printf ("%d\n", ((int (*) (void)) mod1_bar) ());
41   printf ("%d\n", ((int (*) (void)) mod2_bar) ());
42
43   if (dlclose (h1) != 0)
44     {
45       printf ("closing h1 failed: %s\n", dlerror ());
46       exit (1);
47     }
48
49   printf ("%d\n", ((int (*) (void)) mod2_bar) ());
50
51   if (dlclose (h2) != 0)
52     {
53       printf ("closing h2 failed: %s\n", dlerror ());
54       exit (1);
55     }
56
57   return 0;
58 }