Update.
[glibc.git] / elf / dl-debug.c
blobe0bf1fbbc46d864cf62dfc3a25b0d85dc802d9a5
1 /* Communicate dynamic linker state to the debugger at runtime.
2 Copyright (C) 1996, 1998 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <elf/ldsodefs.h>
22 /* This structure communicates dl state to the debugger. The debugger
23 normally finds it via the DT_DEBUG entry in the dynamic section, but in
24 a statically-linked program there is no dynamic section for the debugger
25 to examine and it looks for this particular symbol name. */
26 struct r_debug _r_debug;
29 /* Initialize _r_debug if it has not already been done. The argument is
30 the run-time load address of the dynamic linker, to be put in
31 _r_debug.r_ldbase. Returns the address of _r_debug. */
33 struct r_debug *
34 internal_function
35 _dl_debug_initialize (ElfW(Addr) ldbase)
37 if (_r_debug.r_brk == 0)
39 /* Tell the debugger where to find the map of loaded objects. */
40 _r_debug.r_version = 1 /* R_DEBUG_VERSION XXX */;
41 _r_debug.r_ldbase = ldbase;
42 _r_debug.r_map = _dl_loaded;
43 _r_debug.r_brk = (ElfW(Addr)) &_dl_debug_state;
46 return &_r_debug;
50 /* This function exists solely to have a breakpoint set on it by the
51 debugger. The debugger is supposed to find this function's address by
52 examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks
53 for this particular symbol name in the PT_INTERP file. */
54 void
55 _dl_debug_state (void)