mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-23 11:20:07 +00:00
d78efd9f36
* elf/Makefile (tests): Add it. ($(objpfx)tst-tls-dlinfo): Depend on $(libdl). ($(objpfx)tst-tls-dlinfo.out): Depend on $(objpfx)tst-tlsmod2.so. * dlfcn/dlfcn.h (RTLD_DI_PROFILENAME, RTLD_DI_PROFILEOUT): New enum values, reserve unsupported requested names used on Solaris. (RTLD_DI_TLS_MODID, RTLD_DI_TLS_DATA): New enum values. (RTLD_DI_MAX): Likewise. * dlfcn/dlinfo.c (dlinfo_doit): Handle RTLD_DI_TLS_MODID and RTLD_DI_TLS_DATA. * elf/dl-tls.c (_dl_tls_get_addr_soft): New function. * sysdeps/generic/ldsodefs.h: Declare it. * elf/Versions (ld: GLIBC_PRIVATE): Add it. * elf/link.h (struct dl_phdr_info): New members dlpi_tls_modid, dlpi_tls_data. * elf/dl-iteratephdr.c (__dl_iterate_phdr): Fill them in. * include/link.h: Don't copy contents from elf/link.h. Instead, #include it while #define'ing around link_map. * elf/dl-debug.c (_dl_debug_initialize): Add a cast. Add bogus extern decl to verify link_map members. * elf/loadtest.c (MAPS): New macro, cast _r_debug._r_map. (OUT, main): Use it in place of _r_debug._r_map. * elf/unload.c: Likewise. * elf/unload2.c: Likewise. * elf/neededtest.c (check_loaded_objects): Likewise. * elf/neededtest2.c (check_loaded_objects): Likewise. * elf/neededtest3.c (check_loaded_objects): Likewise. * elf/neededtest4.c (check_loaded_objects): Likewise. * elf/circleload1.c (check_loaded_objects): Likewise.
135 lines
3.3 KiB
C
135 lines
3.3 KiB
C
/* dlinfo -- Get information from the dynamic linker.
|
|
Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#include <dlfcn.h>
|
|
#include <link.h>
|
|
#include <ldsodefs.h>
|
|
#include <libintl.h>
|
|
|
|
#if !defined SHARED && defined IS_IN_libdl
|
|
|
|
int
|
|
dlinfo (void *handle, int request, void *arg)
|
|
{
|
|
return __dlinfo (handle, request, arg, RETURN_ADDRESS (0));
|
|
}
|
|
|
|
#else
|
|
|
|
# ifdef USE_TLS
|
|
# include <dl-tls.h>
|
|
# endif
|
|
|
|
struct dlinfo_args
|
|
{
|
|
ElfW(Addr) caller;
|
|
void *handle;
|
|
int request;
|
|
void *arg;
|
|
};
|
|
|
|
static void
|
|
dlinfo_doit (void *argsblock)
|
|
{
|
|
struct dlinfo_args *const args = argsblock;
|
|
struct link_map *l = args->handle;
|
|
|
|
# if 0
|
|
if (args->handle == RTLD_SELF)
|
|
{
|
|
Lmid_t nsid;
|
|
|
|
/* Find the highest-addressed object that CALLER is not below. */
|
|
for (nsid = 0; nsid < DL_NNS; ++nsid)
|
|
for (l = GL(dl_ns)[nsid]._ns_loaded; l != NULL; l = l->l_next)
|
|
if (caller >= l->l_map_start && caller < l->l_map_end)
|
|
/* There must be exactly one DSO for the range of the virtual
|
|
memory. Otherwise something is really broken. */
|
|
break;
|
|
|
|
if (l == NULL)
|
|
GLRO(dl_signal_error) (0, NULL, NULL, N_("\
|
|
RTLD_SELF used in code not dynamically loaded"));
|
|
}
|
|
# endif
|
|
|
|
switch (args->request)
|
|
{
|
|
case RTLD_DI_CONFIGADDR:
|
|
default:
|
|
GLRO(dl_signal_error) (0, NULL, NULL, N_("unsupported dlinfo request"));
|
|
break;
|
|
|
|
case RTLD_DI_LMID:
|
|
*(Lmid_t *) args->arg = l->l_ns;
|
|
break;
|
|
|
|
case RTLD_DI_LINKMAP:
|
|
*(struct link_map **) args->arg = l;
|
|
break;
|
|
|
|
case RTLD_DI_SERINFO:
|
|
_dl_rtld_di_serinfo (l, args->arg, false);
|
|
break;
|
|
case RTLD_DI_SERINFOSIZE:
|
|
_dl_rtld_di_serinfo (l, args->arg, true);
|
|
break;
|
|
|
|
case RTLD_DI_ORIGIN:
|
|
strcpy (args->arg, l->l_origin);
|
|
break;
|
|
|
|
case RTLD_DI_TLS_MODID:
|
|
*(size_t *) args->arg = 0;
|
|
#ifdef USE_TLS
|
|
*(size_t *) args->arg = l->l_tls_modid;
|
|
#endif
|
|
break;
|
|
|
|
case RTLD_DI_TLS_DATA:
|
|
{
|
|
void *data = NULL;
|
|
#ifdef USE_TLS
|
|
if (l->l_tls_modid != 0)
|
|
data = _dl_tls_get_addr_soft (l);
|
|
#endif
|
|
*(void **) args->arg = data;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
int
|
|
__dlinfo (void *handle, int request, void *arg DL_CALLER_DECL)
|
|
{
|
|
# ifdef SHARED
|
|
if (__builtin_expect (_dlfcn_hook != NULL, 0))
|
|
return _dlfcn_hook->dlinfo (handle, request, arg,
|
|
DL_CALLER);
|
|
# endif
|
|
|
|
struct dlinfo_args args = { (ElfW(Addr)) DL_CALLER,
|
|
handle, request, arg };
|
|
return _dlerror_run (&dlinfo_doit, &args) ? -1 : 0;
|
|
}
|
|
# ifdef SHARED
|
|
strong_alias (__dlinfo, dlinfo)
|
|
# endif
|
|
#endif
|