]>
Commit | Line | Data |
---|---|---|
4d6acc61 | 1 | /* Communicate dynamic linker state to the debugger at runtime. |
04277e02 | 2 | Copyright (C) 1996-2019 Free Software Foundation, Inc. |
afd4eb37 | 3 | This file is part of the GNU C Library. |
4d6acc61 | 4 | |
afd4eb37 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
4d6acc61 | 9 | |
afd4eb37 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
4d6acc61 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
4d6acc61 | 18 | |
a42195db | 19 | #include <ldsodefs.h> |
4d6acc61 | 20 | |
d78efd9f RM |
21 | |
22 | /* These are the members in the public `struct link_map' type. | |
23 | Sanity check that the internal type and the public type match. */ | |
24 | #define VERIFY_MEMBER(name) \ | |
25 | (offsetof (struct link_map_public, name) == offsetof (struct link_map, name)) | |
26 | extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr) | |
27 | && VERIFY_MEMBER (l_name) | |
28 | && VERIFY_MEMBER (l_ld) | |
29 | && VERIFY_MEMBER (l_next) | |
30 | && VERIFY_MEMBER (l_prev)) | |
31 | ? 1 : -1]; | |
32 | ||
4d6acc61 RM |
33 | /* This structure communicates dl state to the debugger. The debugger |
34 | normally finds it via the DT_DEBUG entry in the dynamic section, but in | |
35 | a statically-linked program there is no dynamic section for the debugger | |
36 | to examine and it looks for this particular symbol name. */ | |
37 | struct r_debug _r_debug; | |
38 | ||
39 | ||
40 | /* Initialize _r_debug if it has not already been done. The argument is | |
41 | the run-time load address of the dynamic linker, to be put in | |
42 | _r_debug.r_ldbase. Returns the address of _r_debug. */ | |
43 | ||
44 | struct r_debug * | |
29f97654 | 45 | _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) |
4d6acc61 | 46 | { |
29f97654 UD |
47 | struct r_debug *r; |
48 | ||
49 | if (ns == LM_ID_BASE) | |
50 | r = &_r_debug; | |
51 | else | |
52 | r = &GL(dl_ns)[ns]._ns_debug; | |
53 | ||
2692deea | 54 | if (r->r_map == NULL || ldbase != 0) |
4d6acc61 RM |
55 | { |
56 | /* Tell the debugger where to find the map of loaded objects. */ | |
29f97654 UD |
57 | r->r_version = 1 /* R_DEBUG_VERSION XXX */; |
58 | r->r_ldbase = ldbase ?: _r_debug.r_ldbase; | |
d78efd9f | 59 | r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded; |
29f97654 | 60 | r->r_brk = (ElfW(Addr)) &_dl_debug_state; |
4d6acc61 RM |
61 | } |
62 | ||
29f97654 | 63 | return r; |
4d6acc61 RM |
64 | } |
65 | ||
66 | ||
67 | /* This function exists solely to have a breakpoint set on it by the | |
68 | debugger. The debugger is supposed to find this function's address by | |
69 | examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks | |
70 | for this particular symbol name in the PT_INTERP file. */ | |
71 | void | |
72 | _dl_debug_state (void) | |
73 | { | |
74 | } | |
7e46ec8c | 75 | rtld_hidden_def (_dl_debug_state) |