1 | /* Test unrelated dlopen after dlopen failure involving NODELETE. |
2 | Copyright (C) 2019-2024 Free Software Foundation, Inc. |
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 | TEST_VERIFY (dlsym (NULL, "no_delete_mod_function" ) == NULL); |
32 | |
33 | /* This is expected to fail because of the missing dependency. */ |
34 | puts (s: "info: attempting to load tst-dlopenfailmod1.so" ); |
35 | TEST_VERIFY (dlopen ("tst-dlopenfailmod1.so" , RTLD_LAZY) == NULL); |
36 | const char *message = dlerror (); |
37 | TEST_COMPARE_STRING (message, |
38 | "tst-dlopenfail-missingmod.so:" |
39 | " cannot open shared object file:" |
40 | " No such file or directory" ); |
41 | |
42 | /* Open a small shared object. With a dangling GL (dl_initfirst) |
43 | pointer, this is likely to crash because there is no longer any |
44 | mapped text segment there (bug 25396). */ |
45 | |
46 | puts (s: "info: attempting to load tst-dlopenfailmod3.so" ); |
47 | xdlclose (handle: xdlopen (filename: "tst-dlopenfailmod3.so" , RTLD_NOW)); |
48 | |
49 | return 0; |
50 | } |
51 | |
52 | /* Do not perturb the dangling link map. With M_PERTURB, the link map |
53 | appears to have l_init_called set, so there are no constructor |
54 | calls and no crashes. */ |
55 | #define TEST_NO_MALLOPT |
56 | #include <support/test-driver.c> |
57 | |