Automatic date update in version.in
[binutils-gdb.git] / gdb / glibc-tdep.c
blob48e080ae9bf330440df914e7c4ba8ca687891272
1 /* Target-dependent code for the GNU C Library (glibc).
3 Copyright (C) 2002-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "frame.h"
21 #include "symtab.h"
22 #include "symfile.h"
23 #include "objfiles.h"
25 #include "glibc-tdep.h"
27 /* Calling functions in shared libraries. */
29 /* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c.
30 This function:
31 1) decides whether a PLT has sent us into the linker to resolve
32 a function reference, and
33 2) if so, tells us where to set a temporary breakpoint that will
34 trigger when the dynamic linker is done. */
36 CORE_ADDR
37 glibc_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
39 /* The GNU dynamic linker is part of the GNU C library, and is used
40 by all GNU systems (GNU/Hurd, GNU/Linux). An unresolved PLT
41 entry points to "_dl_runtime_resolve", which calls "fixup" to
42 patch the PLT, and then passes control to the function.
44 We look for the symbol `_dl_runtime_resolve', and find `fixup' in
45 the same objfile. If we are at the entry point of `fixup', then
46 we set a breakpoint at the return address (at the top of the
47 stack), and continue.
49 It's kind of gross to do all these checks every time we're
50 called, since they don't change once the executable has gotten
51 started. But this is only a temporary hack --- upcoming versions
52 of GNU/Linux will provide a portable, efficient interface for
53 debugging programs that use shared libraries. */
55 struct bound_minimal_symbol resolver
56 = lookup_bound_minimal_symbol ("_dl_runtime_resolve");
58 if (resolver.minsym)
60 /* The dynamic linker began using this name in early 2005. */
61 struct bound_minimal_symbol fixup
62 = lookup_minimal_symbol ("_dl_fixup", NULL, resolver.objfile);
64 /* This is the name used in older versions. */
65 if (! fixup.minsym)
66 fixup = lookup_minimal_symbol ("fixup", NULL, resolver.objfile);
68 if (fixup.minsym && fixup.value_address () == pc)
69 return frame_unwind_caller_pc (get_current_frame ());
72 return 0;