]>
Commit | Line | Data |
---|---|---|
d0f07f7d FW |
1 | /* Test lazy binding during dlclose (bug 30425). |
2 | Copyright (C) 2023 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 | /* This test re-creates a situation that can arise naturally for C++ | |
20 | applications due to the use of vague linkage and differences in the | |
21 | set of compiler-emitted functions. A function in | |
22 | tst-dlclose-lazy-mod1.so (exported_function) interposes a function | |
23 | in tst-dlclose-lazy-mod2.so. This function is called from the | |
24 | destructor in tst-dlclose-lazy-mod2.so, after the destructor for | |
25 | tst-dlclose-lazy-mod1.so has already completed. Prior to the fix | |
26 | for bug 30425, this would lead to a lazy binding failure in | |
27 | tst-dlclose-lazy-mod1.so because dlclose had already marked the DSO | |
28 | as unavailable for binding (by setting l_removed). */ | |
29 | ||
30 | #include <dlfcn.h> | |
31 | #include <support/xdlfcn.h> | |
32 | #include <support/check.h> | |
33 | ||
34 | int | |
35 | main (void) | |
36 | { | |
37 | /* Load tst-dlclose-lazy-mod1.so, indirectly loading | |
38 | tst-dlclose-lazy-mod2.so. */ | |
39 | void *handle = xdlopen ("tst-dlclose-lazy-mod1.so", RTLD_GLOBAL | RTLD_LAZY); | |
40 | ||
41 | /* Invoke the destructor of tst-dlclose-lazy-mod2.so, which calls | |
42 | into tst-dlclose-lazy-mod1.so after its destructor has been | |
43 | called. */ | |
44 | xdlclose (handle); | |
45 | ||
46 | return 0; | |
47 | } |