]>
Commit | Line | Data |
---|---|---|
a332bd15 | 1 | /* Test unrelated dlopen after dlopen failure involving NODELETE. |
2b778ceb | 2 | Copyright (C) 2019-2021 Free Software Foundation, Inc. |
a332bd15 FW |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
17 | <https://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #include <dlfcn.h> | |
20 | #include <errno.h> | |
21 | #include <gnu/lib-names.h> | |
22 | #include <stddef.h> | |
23 | #include <stdio.h> | |
24 | #include <string.h> | |
25 | #include <support/check.h> | |
26 | #include <support/xdlfcn.h> | |
27 | ||
28 | static int | |
29 | do_test (void) | |
30 | { | |
31 | /* This test uses libpthread as the canonical NODELETE module. If | |
32 | libpthread is no longer NODELETE because it has been merged into | |
33 | libc, the test needs to be updated. */ | |
34 | TEST_VERIFY (dlsym (NULL, "pthread_create") == NULL); | |
35 | ||
36 | /* This is expected to fail because of the missing dependency. */ | |
37 | puts ("info: attempting to load tst-dlopenfailmod1.so"); | |
38 | TEST_VERIFY (dlopen ("tst-dlopenfailmod1.so", RTLD_LAZY) == NULL); | |
39 | const char *message = dlerror (); | |
40 | TEST_COMPARE_STRING (message, | |
41 | "tst-dlopenfail-missingmod.so:" | |
42 | " cannot open shared object file:" | |
43 | " No such file or directory"); | |
44 | ||
45 | /* Open a small shared object. With a dangling GL (dl_initfirst) | |
46 | pointer, this is likely to crash because there is no longer any | |
47 | mapped text segment there (bug 25396). */ | |
48 | ||
49 | puts ("info: attempting to load tst-dlopenfailmod3.so"); | |
50 | xdlclose (xdlopen ("tst-dlopenfailmod3.so", RTLD_NOW)); | |
51 | ||
52 | return 0; | |
53 | } | |
54 | ||
55 | /* Do not perturb the dangling link map. With M_PERTURB, the link map | |
56 | appears to have l_init_called set, so there are no constructor | |
57 | calls and no crashes. */ | |
58 | #define TEST_NO_MALLOPT | |
59 | #include <support/test-driver.c> |