Add missing dependency for pt-crti.o
[glibc.git] / elf / noload.c
blobbcc85efc271470e225164871227d0967f61244fa
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <mcheck.h>
5 int
6 main (void)
8 int result = 0;
9 void *p;
11 mtrace ();
13 /* First try to load an object which is a dependency. This should
14 succeed. */
15 p = dlopen ("testobj1.so", RTLD_LAZY | RTLD_NOLOAD);
16 if (p == NULL)
18 printf ("cannot open \"testobj1.so\": %s\n", dlerror ());
19 result = 1;
21 else
23 puts ("loading \"testobj1.so\" succeeded, OK");
24 dlclose (p);
27 /* Now try loading an object which is not already loaded. */
28 if (dlopen ("testobj5.so", RTLD_LAZY | RTLD_NOLOAD) != NULL)
30 puts ("succeeded in loading \"testobj5.so\"");
31 result = 1;
33 else
35 /* Load the object and run the same test again. */
36 puts ("\"testobj5.so\" wasn't loaded and RTLD_NOLOAD prevented it, OK");
38 p = dlopen ("testobj5.so", RTLD_LAZY);
40 if (p == NULL)
42 printf ("cannot open \"testobj5.so\" without RTLD_NOLOAD: %s\n",
43 dlerror ());
44 result = 1;
46 else
48 puts ("loading \"testobj5.so\" succeeded, OK");
50 void *q = dlopen ("testobj5.so", RTLD_LAZY | RTLD_NOLOAD);
51 if (q == NULL)
53 printf ("cannot open \"testobj5.so\": %s\n", dlerror ());
54 result = 1;
56 else
58 puts ("loading \"testobj5.so\" with RTLD_NOLOAD succeeded, OK");
59 dlclose (q);
62 if (dlclose (p) != 0)
64 printf ("cannot close \"testobj5.so\": %s\n", dlerror ());
65 result = 1;
67 else
68 puts ("closing \"testobj5.so\" succeeded, OK");
72 return result;
76 extern int foo (int a);
77 int
78 foo (int a)
80 return 42 + a;