1 /* dlinfo -- Get information from the dynamic linker.
2 Copyright (C) 2003-2024 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/>. */
24 #include <shlib-compat.h>
32 /* This is the value that is returned from dlinfo if no error is
38 dlinfo_doit (void *argsblock)
40 struct dlinfo_args *const args = argsblock;
41 struct link_map *l = args->handle;
43 switch (args->request)
45 case RTLD_DI_CONFIGADDR:
48 _dl_signal_error (0, NULL, NULL, N_("unsupported dlinfo request"));
52 *(Lmid_t *) args->arg = l->l_ns;
56 *(struct link_map **) args->arg = l;
60 _dl_rtld_di_serinfo (l, args->arg, false);
62 case RTLD_DI_SERINFOSIZE:
63 _dl_rtld_di_serinfo (l, args->arg, true);
67 strcpy (args->arg, l->l_origin);
70 case RTLD_DI_TLS_MODID:
71 *(size_t *) args->arg = 0;
72 *(size_t *) args->arg = l->l_tls_modid;
75 case RTLD_DI_TLS_DATA:
78 if (l->l_tls_modid != 0)
79 data = GLRO(dl_tls_get_addr_soft) (l);
80 *(void **) args->arg = data;
85 *(const ElfW(Phdr) **) args->arg = l->l_phdr;
86 args->result = l->l_phnum;
92 dlinfo_implementation (void *handle, int request, void *arg)
94 struct dlinfo_args args = { handle, request, arg };
95 _dlerror_run (&dlinfo_doit, &args);
101 ___dlinfo (void *handle, int request, void *arg)
103 if (GLRO (dl_dlfcn_hook) != NULL)
104 return GLRO (dl_dlfcn_hook)->dlinfo (handle, request, arg);
106 return dlinfo_implementation (handle, request, arg);
108 versioned_symbol (libc, ___dlinfo, dlinfo, GLIBC_2_34);
110 # if OTHER_SHLIB_COMPAT (libdl, GLIBC_2_3_3, GLIBC_2_34)
111 compat_symbol (libc, ___dlinfo, dlinfo, GLIBC_2_3_3);
114 /* Also used with _dlfcn_hook. */
116 __dlinfo (void *handle, int request, void *arg)
118 return dlinfo_implementation (handle, request, arg);
120 weak_alias (__dlinfo, dlinfo)