[BZ #14898]
[glibc.git] / elf / constload1.c
blob7381beea88037344214dba9b2e7a10b5b5c92a3f
1 #include <dlfcn.h>
2 #include <errno.h>
3 #include <error.h>
4 #include <mcheck.h>
5 #include <stdio.h>
6 #include <stdlib.h>
8 int
9 main (void)
11 int (*foo) (void);
12 void *h;
13 int ret;
15 mtrace ();
17 h = dlopen ("constload2.so", RTLD_LAZY | RTLD_GLOBAL);
18 if (h == NULL)
19 error (EXIT_FAILURE, errno, "cannot load module \"constload2.so\"");
20 foo = dlsym (h, "foo");
21 ret = foo ();
22 /* Note that the following dlclose() call cannot unload the objects.
23 Due to the introduced relocation dependency constload2.so depends
24 on constload3.so and the dependencies of constload2.so on constload3.so
25 is not visible to ld.so since it's done using dlopen(). */
26 if (dlclose (h) != 0)
28 puts ("failed to close");
29 exit (EXIT_FAILURE);
31 return ret;