mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 21:10:07 +00:00
5f21997b9d
2004-10-18 Jakub Jelinek <jakub@redhat.com> * elf/dl-libc.c (__libc_dlsym_private, __libc_register_dl_open_hook): New functions. (__libc_dlopen_mode): Call __libc_register_dl_open_hook and __libc_register_dlfcn_hook. * dlfcn/Makefile (routines, elide-routines.os): Set. Add rules to build and test tststatic2. * dlfcn/tststatic2.c: New test. * dlfcn/modstatic2.c: New test module. * dlfcn/dladdr.c: Call _dlfcn_hook from libdl.so if not NULL. Define __ prefixed routine in libc.a and in libdl.a just call it. * dlfcn/dladdr1.c: Likewise. * dlfcn/dlclose.c: Likewise. * dlfcn/dlerror.c: Likewise. * dlfcn/dlinfo.c: Likewise. * dlfcn/dlmopen.c: Likewise. * dlfcn/dlopen.c: Likewise. * dlfcn/dlopenold.c: Likewise. * dlfcn/dlsym.c: Likewise. * dlfcn/dlvsym.c: Likewise. * dlfcn/sdladdr.c: New file. * dlfcn/sdladdr1.c: New file. * dlfcn/sdlclose.c: New file. * dlfcn/sdlerror.c: New file. * dlfcn/sdlinfo.c: New file. * dlfcn/sdlopen.c: New file. * dlfcn/sdlsym.c: New file. * dlfcn/sdlvsym.c: New file. * dlfcn/Versions (libdl): Export _dlfcn_hook@GLIBC_PRIVATE. * include/dlfcn.h (DL_CALLER_DECL, DL_CALLER RETURN_ADDRESS): Define. (struct dlfcn_hook): New type. (_dlfcn_hook): New extern decl. (__dlopen, __dlclose, __dlsym, __dlerror, __dladdr, __dladdr1, __dlinfo, __dlmopen, __libc_dlsym_private, __libc_register_dl_open_hook, __libc_register_dlfcn_hook): New prototypes. (__dlvsym): Use DL_CALLER_DECL. * include/libc-symbols.h: Define libdl_hidden_proto and friends. * malloc/arena.c (_dl_open_hook): Extern decl. (ptmalloc_init): Don't call _dl_addr when dlopened from statically linked programs but don't use brk for them either.
113 lines
2.9 KiB
C
113 lines
2.9 KiB
C
/* dlinfo -- Get information from the dynamic linker.
|
|
Copyright (C) 2003, 2004 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
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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
|