1 /* Test struct r_debug_extended via DT_DEBUG.
2 Copyright (C) 2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
23 #include <gnu/lib-names.h>
24 #include <support/xdlfcn.h>
25 #include <support/check.h>
26 #include <support/test-driver.h>
28 #ifndef ELF_MACHINE_GET_R_DEBUG
29 # define ELF_MACHINE_GET_R_DEBUG(d) \
31 struct r_debug_extended *debug; \
32 if ((d)->d_tag == DT_DEBUG) \
33 debug = (struct r_debug_extended *) (d)->d_un.d_ptr; \
43 struct r_debug_extended
*debug
= NULL
;
45 for (d
= _DYNAMIC
; d
->d_tag
!= DT_NULL
; ++d
)
47 debug
= ELF_MACHINE_GET_R_DEBUG (d
);
52 TEST_VERIFY_EXIT (debug
!= NULL
);
53 TEST_COMPARE (debug
->base
.r_version
, 1);
54 TEST_VERIFY_EXIT (debug
->r_next
== NULL
);
56 void *h
= xdlmopen (LM_ID_NEWLM
, "$ORIGIN/tst-dlmopen1mod.so",
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");
72 #include <support/test-driver.c>