Blame elf/dl-debug.c

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