]>
Commit | Line | Data |
---|---|---|
a93d9e03 | 1 | /* Test struct r_debug_extended via DT_DEBUG. |
581c785b | 2 | Copyright (C) 2021-2022 Free Software Foundation, Inc. |
a93d9e03 L |
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 <stdio.h> | |
20 | #include <link.h> | |
21 | #include <stdlib.h> | |
22 | #include <string.h> | |
23 | #include <gnu/lib-names.h> | |
24 | #include <support/xdlfcn.h> | |
25 | #include <support/check.h> | |
26 | #include <support/test-driver.h> | |
27 | ||
28 | #ifndef ELF_MACHINE_GET_R_DEBUG | |
29 | # define ELF_MACHINE_GET_R_DEBUG(d) \ | |
30 | (__extension__ ({ \ | |
31 | struct r_debug_extended *debug; \ | |
32 | if ((d)->d_tag == DT_DEBUG) \ | |
33 | debug = (struct r_debug_extended *) (d)->d_un.d_ptr; \ | |
34 | else \ | |
35 | debug = NULL; \ | |
36 | debug; })) | |
37 | #endif | |
38 | ||
39 | static int | |
40 | do_test (void) | |
41 | { | |
42 | ElfW(Dyn) *d; | |
43 | struct r_debug_extended *debug = NULL; | |
44 | ||
45 | for (d = _DYNAMIC; d->d_tag != DT_NULL; ++d) | |
46 | { | |
47 | debug = ELF_MACHINE_GET_R_DEBUG (d); | |
48 | if (debug != NULL) | |
49 | break; | |
50 | } | |
51 | ||
52 | TEST_VERIFY_EXIT (debug != NULL); | |
53 | TEST_COMPARE (debug->base.r_version, 1); | |
54 | TEST_VERIFY_EXIT (debug->r_next == NULL); | |
55 | ||
56 | void *h = xdlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", | |
57 | RTLD_LAZY); | |
58 | ||
59 | TEST_COMPARE (debug->base.r_version, 2); | |
60 | TEST_VERIFY_EXIT (debug->r_next != NULL); | |
61 | TEST_VERIFY_EXIT (debug->r_next->r_next == NULL); | |
62 | TEST_VERIFY_EXIT (debug->r_next->base.r_map != NULL); | |
63 | TEST_VERIFY_EXIT (debug->r_next->base.r_map->l_name != NULL); | |
64 | const char *name = basename (debug->r_next->base.r_map->l_name); | |
65 | TEST_COMPARE_STRING (name, "tst-dlmopen1mod.so"); | |
66 | ||
67 | xdlclose (h); | |
68 | ||
69 | return 0; | |
70 | } | |
71 | ||
72 | #include <support/test-driver.c> |