]>
Commit | Line | Data |
---|---|---|
a42faf59 PP |
1 | /* Test case for BZ #16634. |
2 | ||
55a81e3b PP |
3 | Verify that incorrectly dlopen()ing an executable without |
4 | __RTLD_OPENEXEC does not cause assertion in ld.so. | |
5 | ||
688903eb | 6 | Copyright (C) 2014-2018 Free Software Foundation, Inc. |
a42faf59 PP |
7 | This file is part of the GNU C Library. |
8 | ||
9 | The GNU C Library is free software; you can redistribute it and/or | |
10 | modify it under the terms of the GNU Lesser General Public | |
11 | License as published by the Free Software Foundation; either | |
12 | version 2.1 of the License, or (at your option) any later version. | |
13 | ||
14 | The GNU C Library is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public | |
20 | License along with the GNU C Library; if not, see | |
21 | <http://www.gnu.org/licenses/>. | |
22 | ||
23 | Note: this test currently only fails when glibc is configured with | |
24 | --enable-hardcoded-path-in-tests. */ | |
25 | ||
26 | #include <assert.h> | |
27 | #include <dlfcn.h> | |
28 | #include <stdio.h> | |
29 | #include <pthread.h> | |
30 | ||
31 | __thread int x; | |
32 | ||
33 | void * | |
34 | fn (void *p) | |
35 | { | |
36 | return p; | |
37 | } | |
38 | ||
55a81e3b PP |
39 | static int |
40 | do_test (int argc, char *argv[]) | |
a42faf59 PP |
41 | { |
42 | int j; | |
43 | ||
44 | for (j = 0; j < 100; ++j) | |
45 | { | |
46 | pthread_t thr; | |
47 | void *p; | |
48 | int rc; | |
49 | ||
50 | p = dlopen (argv[0], RTLD_LAZY); | |
51 | if (p != NULL) | |
52 | { | |
53 | fprintf (stderr, "dlopen unexpectedly succeeded\n"); | |
54 | return 1; | |
55 | } | |
56 | rc = pthread_create (&thr, NULL, fn, NULL); | |
57 | assert (rc == 0); | |
58 | ||
59 | rc = pthread_join (thr, NULL); | |
60 | assert (rc == 0); | |
61 | } | |
62 | ||
63 | return 0; | |
64 | } | |
55a81e3b | 65 | |
12fb1801 | 66 | #define TEST_FUNCTION_ARGV do_test |
36fe25fd | 67 | #include <support/test-driver.c> |