
1: /* Communicate dynamic linker state to the debugger at runtime. 2: Copyright (C) 1996, 1998,2000,2002,2004,2005,2006 3: Free Software Foundation, Inc. 4: This file is part of the GNU C Library. 5: 6: The GNU C Library is free software; you can redistribute it and/or 7: modify it under the terms of the GNU Lesser General Public 8: License as published by the Free Software Foundation; either 9: version 2.1 of the License, or (at your option) any later version. 10: 11: The GNU C Library is distributed in the hope that it will be useful, 12: but WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: Lesser General Public License for more details. 15: 16: You should have received a copy of the GNU Lesser General Public 17: License along with the GNU C Library; if not, write to the Free 18: Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19: 02111-1307 USA. */ 20: 21: #include <ldsodefs.h> 22: 23: 24: /* These are the members in the public `struct link_map' type. 25: Sanity check that the internal type and the public type match. */ 26: #define VERIFY_MEMBER(name) \ 27: (offsetof (struct link_map_public, name) == offsetof (struct link_map, name)) 28: extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr) 29: && VERIFY_MEMBER (l_name) 30: && VERIFY_MEMBER (l_ld) 31: && VERIFY_MEMBER (l_next) 32: && VERIFY_MEMBER (l_prev)) 33: ? 1 : -1]; 34: 35: /* This structure communicates dl state to the debugger. The debugger 36: normally finds it via the DT_DEBUG entry in the dynamic section, but in 37: a statically-linked program there is no dynamic section for the debugger 38: to examine and it looks for this particular symbol name. */ 39: struct r_debug _r_debug; 40: 41: 42: /* Initialize _r_debug if it has not already been done. The argument is 43: the run-time load address of the dynamic linker, to be put in 44: _r_debug.r_ldbase. Returns the address of _r_debug. */ 45: 46: struct r_debug * 47: internal_function 48: _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) 49: { 50: struct r_debug *r; 51: 52: if (ns == LM_ID_BASE) 53: r = &_r_debug; 54: else 55: r = &GL(dl_ns)[ns]._ns_debug; 56: 57: if (r->r_map == NULL || ldbase != 0) 58: { 59: /* Tell the debugger where to find the map of loaded objects. */ 60: r->r_version = 1 /* R_DEBUG_VERSION XXX */; 61: r->r_ldbase = ldbase ?: _r_debug.r_ldbase; 62: r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded; 63: r->r_brk = (ElfW(Addr)) &_dl_debug_state; 64: } 65: 66: return r; 67: } 68: 69: 70: /* This function exists solely to have a breakpoint set on it by the 71: debugger. The debugger is supposed to find this function's address by 72: examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks 73: for this particular symbol name in the PT_INTERP file. */ 74: void 75: _dl_debug_state (void) 76: { 77: } 78: rtld_hidden_def (_dl_debug_state)