|
Packit |
6c4009 |
/* Communicate dynamic linker state to the debugger at runtime.
|
|
Packit |
6c4009 |
Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <ldsodefs.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* These are the members in the public `struct link_map' type.
|
|
Packit |
6c4009 |
Sanity check that the internal type and the public type match. */
|
|
Packit |
6c4009 |
#define VERIFY_MEMBER(name) \
|
|
Packit |
6c4009 |
(offsetof (struct link_map_public, name) == offsetof (struct link_map, name))
|
|
Packit |
6c4009 |
extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr)
|
|
Packit |
6c4009 |
&& VERIFY_MEMBER (l_name)
|
|
Packit |
6c4009 |
&& VERIFY_MEMBER (l_ld)
|
|
Packit |
6c4009 |
&& VERIFY_MEMBER (l_next)
|
|
Packit |
6c4009 |
&& VERIFY_MEMBER (l_prev))
|
|
Packit |
6c4009 |
? 1 : -1];
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* This structure communicates dl state to the debugger. The debugger
|
|
Packit |
6c4009 |
normally finds it via the DT_DEBUG entry in the dynamic section, but in
|
|
Packit |
6c4009 |
a statically-linked program there is no dynamic section for the debugger
|
|
Packit |
6c4009 |
to examine and it looks for this particular symbol name. */
|
|
Packit |
6c4009 |
struct r_debug _r_debug;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Initialize _r_debug if it has not already been done. The argument is
|
|
Packit |
6c4009 |
the run-time load address of the dynamic linker, to be put in
|
|
Packit |
6c4009 |
_r_debug.r_ldbase. Returns the address of _r_debug. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct r_debug *
|
|
Packit |
6c4009 |
_dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
struct r_debug *r;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (ns == LM_ID_BASE)
|
|
Packit |
6c4009 |
r = &_r_debug;
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
r = &GL(dl_ns)[ns]._ns_debug;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (r->r_map == NULL || ldbase != 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Tell the debugger where to find the map of loaded objects. */
|
|
Packit |
6c4009 |
r->r_version = 1 /* R_DEBUG_VERSION XXX */;
|
|
Packit |
6c4009 |
r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
|
|
Packit |
6c4009 |
r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
|
|
Packit |
6c4009 |
r->r_brk = (ElfW(Addr)) &_dl_debug_state;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return r;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* This function exists solely to have a breakpoint set on it by the
|
|
Packit |
6c4009 |
debugger. The debugger is supposed to find this function's address by
|
|
Packit |
6c4009 |
examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks
|
|
Packit |
6c4009 |
for this particular symbol name in the PT_INTERP file. */
|
|
Packit |
6c4009 |
void
|
|
Packit |
6c4009 |
_dl_debug_state (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
rtld_hidden_def (_dl_debug_state)
|