]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/loadfail.c
test-container: Fix "unused code" warnings on HURD
[thirdparty/glibc.git] / elf / loadfail.c
CommitLineData
1e262312
UD
1#include <dlfcn.h>
2#include <error.h>
fc7f617d 3#include <mcheck.h>
1e262312
UD
4#include <stdio.h>
5#include <stdlib.h>
6
7int
8main (void)
9{
fc7f617d 10 void *su[5];
1e262312 11 void *h;
fc7f617d 12 int n;
1e262312 13
fc7f617d
UD
14 mtrace ();
15
16 if ((su[0] = dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW)) == NULL
17 || (su[1] = dlopen ("testobj2.so", RTLD_GLOBAL | RTLD_NOW)) == NULL
18 || (su[2] = dlopen ("testobj3.so", RTLD_GLOBAL | RTLD_NOW)) == NULL
19 || (su[3] = dlopen ("testobj4.so", RTLD_GLOBAL | RTLD_NOW)) == NULL
20 || (su[4] = dlopen ("testobj5.so", RTLD_GLOBAL | RTLD_NOW)) == NULL)
1e262312
UD
21 error (EXIT_FAILURE, 0, "failed to load shared object: %s", dlerror ());
22
23 h = dlopen ("failobj.so", RTLD_GLOBAL | RTLD_NOW);
24
25 printf ("h = %p, %s\n", h, h == NULL ? "ok" : "fail");
26
fc7f617d
UD
27 for (n = 0; n < 5; ++n)
28 if (dlclose (su[n]) != 0)
29 {
30 printf ("failed to unload su[%d]: %s\n", n, dlerror ());
31 exit (EXIT_FAILURE);
32 }
33
1e262312
UD
34 return h != NULL;
35}
36
a850e77f 37extern int foo (int a);
1e262312
UD
38int
39foo (int a)
40{
41 return 10;
42}