1 /* Test struct r_debug_extended via DT_DEBUG. 2 Copyright (C) 2021-2022 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 <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 #define E(x) x 29 #define EW(x) ElfW(x) 30 #include <dl-r_debug.h> 31 32 static int do_test(void)33do_test (void) 34 { 35 ElfW(Dyn) *d; 36 struct r_debug_extended *debug = NULL; 37 38 for (d = _DYNAMIC; d->d_tag != DT_NULL; ++d) 39 { 40 debug = (struct r_debug_extended *) r_debug_address (d); 41 if (debug != NULL) 42 break; 43 } 44 45 TEST_VERIFY_EXIT (debug != NULL); 46 TEST_COMPARE (debug->base.r_version, 1); 47 TEST_VERIFY_EXIT (debug->r_next == NULL); 48 49 void *h = xdlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", 50 RTLD_LAZY); 51 52 TEST_COMPARE (debug->base.r_version, 2); 53 TEST_VERIFY_EXIT (debug->r_next != NULL); 54 TEST_VERIFY_EXIT (debug->r_next->r_next == NULL); 55 TEST_VERIFY_EXIT (debug->r_next->base.r_map != NULL); 56 TEST_VERIFY_EXIT (debug->r_next->base.r_map->l_name != NULL); 57 const char *name = basename (debug->r_next->base.r_map->l_name); 58 TEST_COMPARE_STRING (name, "tst-dlmopen1mod.so"); 59 60 xdlclose (h); 61 62 return 0; 63 } 64 65 #include <support/test-driver.c> 66