2.3.3-76
[glibc/history.git] / elf / restest1.c
blobeb5aeca59ead015627386e055f218dad36cdb143
1 #include <dlfcn.h>
2 #include <error.h>
3 #include <mcheck.h>
4 #include <stdio.h>
5 #include <stdlib.h>
7 int
8 main (void)
10 void *h1;
11 int (*fp1) (int);
12 void *h2;
13 int (*fp2) (int);
14 int res1;
15 int res2;
17 mtrace ();
19 h1 = dlopen ("testobj1.so", RTLD_LAZY);
20 if (h1 == NULL)
21 error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1.so",
22 dlerror ());
24 h2 = dlopen ("testobj1_1.so", RTLD_LAZY);
25 if (h1 == NULL)
26 error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1_1.so",
27 dlerror ());
29 fp1 = dlsym (h1, "obj1func1");
30 if (fp1 == NULL)
31 error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
32 "testobj1.so", dlerror ());
34 fp2 = dlsym (h2, "obj1func1");
35 if (fp2 == NULL)
36 error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
37 "testobj1_1.so", dlerror ());
39 res1 = fp1 (10);
40 res2 = fp2 (10);
41 printf ("fp1(10) = %d\nfp2(10) = %d\n", res1, res2);
43 if (dlclose (h1) != 0)
44 error (EXIT_FAILURE, 0, "cannot close testobj1.so: %s\n", dlerror ());
45 if (dlclose (h2) != 0)
46 error (EXIT_FAILURE, 0, "cannot close testobj1_1.so: %s\n", dlerror ());
48 return res1 != 42 || res2 != 72;
52 extern int foo (int a);
53 int
54 foo (int a)
56 return a + 10;