1#include "../dlfcn/dlfcn.h"
2#include <stdio.h>
3#include <stdlib.h>
4
5static int
6do_test (void)
7{
8 int result = 0;
9
10 /* This is a test for correct handling of dlopen failures for library that
11 is loaded with RTLD_NODELETE flag. The first dlopen should fail because
12 of undefined symbols in shared library. The second dlopen then verifies
13 that library was properly unloaded. */
14 if (dlopen (file: "tst-nodelete-rtldmod.so", RTLD_NOW | RTLD_NODELETE) != NULL
15 || dlopen (file: "tst-nodelete-rtldmod.so", RTLD_LAZY | RTLD_NOLOAD) != NULL)
16 {
17 printf (format: "RTLD_NODELETE test failed\n");
18 result = 1;
19 }
20
21 /* This is a test for correct handling of dlopen failures for library that
22 is linked with '-z nodelete' option and hence has DF_1_NODELETE flag.
23 The first dlopen should fail because of undefined symbols in shared
24 library. The second dlopen then verifies that library was properly
25 unloaded. */
26 if (dlopen (file: "tst-nodelete-zmod.so", RTLD_NOW) != NULL
27 || dlopen (file: "tst-nodelete-zmod.so", RTLD_LAZY | RTLD_NOLOAD) != NULL)
28 {
29 printf (format: "-z nodelete test failed\n");
30 result = 1;
31 }
32
33 /* This is a test for correct handling of dlopen failures for library
34 with unique symbols. The first dlopen should fail because of undefined
35 symbols in shared library. The second dlopen then verifies that library
36 was properly unloaded. */
37 if (dlopen (file: "tst-nodelete-uniquemod.so", RTLD_NOW) != NULL
38 || dlopen (file: "tst-nodelete-uniquemod.so", RTLD_LAZY | RTLD_NOLOAD) != NULL)
39 {
40 printf (format: "Unique symbols test failed\n");
41 result = 1;
42 }
43
44 if (result == 0)
45 printf (format: "SUCCESS\n");
46
47 return result;
48}
49
50#include <support/test-driver.c>
51

source code of glibc/elf/tst-nodelete.cc