GDB (xrefs)
Loading...
Searching...
No Matches
hppa-bsd-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for HP PA-RISC BSD's.
2
3 Copyright (C) 2004-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21#include "objfiles.h"
22#include "target.h"
23#include "value.h"
24
25#include "elf/common.h"
26
27#include "hppa-tdep.h"
28#include "hppa-bsd-tdep.h"
29#include "dwarf2/frame.h"
30#include "solib-svr4.h"
31
32static CORE_ADDR
34{
35 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
36 CORE_ADDR faddr = value_as_address (function);
37 struct obj_section *faddr_sec;
38
39 /* Is this a plabel? If so, dereference it to get the Global Pointer
40 value. */
41 if (faddr & 2)
42 {
43 gdb_byte buf[4];
44 if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0)
45 return extract_unsigned_integer (buf, sizeof buf, byte_order);
46 }
47
48 /* If the address is in the .plt section, then the real function
49 hasn't yet been fixed up by the linker so we cannot determine the
50 Global Pointer for that function. */
51 if (in_plt_section (faddr))
52 return 0;
53
54 faddr_sec = find_pc_section (faddr);
55 if (faddr_sec != NULL)
56 {
57 for (struct obj_section *sec : faddr_sec->objfile->sections ())
58 {
59 if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
60 {
61 CORE_ADDR addr = sec->addr ();
62 CORE_ADDR endaddr = sec->endaddr ();
63
64 while (addr < endaddr)
65 {
66 gdb_byte buf[4];
67 LONGEST tag;
68
69 if (target_read_memory (addr, buf, sizeof buf) != 0)
70 break;
71
72 tag = extract_signed_integer (buf, byte_order);
73 if (tag == DT_PLTGOT)
74 {
75 CORE_ADDR pltgot;
76
77 if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
78 break;
79
80 /* The NetBSD/OpenBSD ld.so doesn't relocate
81 DT_PLTGOT, so we have to do it ourselves. */
82 pltgot = extract_unsigned_integer (buf, sizeof buf,
83 byte_order);
84 pltgot += sec->objfile->text_section_offset ();
85
86 return pltgot;
87 }
88
89 if (tag == DT_NULL)
90 break;
91
92 addr += 8;
93 }
94
95 break;
96 }
97 }
98 }
99
100 return 0;
101}
102
103
104static void
106 struct dwarf2_frame_state_reg *reg,
107 frame_info_ptr this_frame)
108{
111 else if (regnum == HPPA_SP_REGNUM)
113}
114
115void
117{
118 hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
119
120 /* OpenBSD and NetBSD have a 64-bit 'long double'. */
123
124 /* OpenBSD and NetBSD use ELF. */
125 tdep->is_elf = 1;
129
130 /* OpenBSD and NetBSD use SVR4-style shared libraries. */
133
134 /* Hook in the DWARF CFI frame unwinder. */
137}
int regnum
static LONGEST extract_signed_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:465
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:480
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
Definition frame.c:1369
void dwarf2_frame_set_init_reg(struct gdbarch *gdbarch, void(*init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, frame_info_ptr))
Definition frame.c:666
@ DWARF2_FRAME_REG_RA
Definition frame.h:61
@ DWARF2_FRAME_REG_CFA
Definition frame.h:63
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code)
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
Definition gdbarch.c:1663
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
Definition gdbarch.c:1646
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:89
void hppabsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static CORE_ADDR hppabsd_find_global_pointer(struct gdbarch *gdbarch, struct value *function)
static void hppabsd_dwarf2_frame_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, frame_info_ptr this_frame)
CORE_ADDR hppa_skip_trampoline_code(frame_info_ptr frame, CORE_ADDR pc)
Definition hppa-tdep.c:2887
int hppa_in_solib_call_trampoline(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition hppa-tdep.c:2859
@ HPPA_SP_REGNUM
Definition hppa-tdep.h:42
@ HPPA_PCOQ_HEAD_REGNUM
Definition hppa-tdep.h:46
struct obj_section * find_pc_section(CORE_ADDR pc)
Definition objfiles.c:1128
static int in_plt_section(CORE_ADDR pc)
Definition objfiles.h:972
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
enum dwarf2_frame_reg_rule how
Definition frame.h:86
CORE_ADDR(* find_global_pointer)(struct gdbarch *, struct value *)
Definition hppa-tdep.h:99
int(* in_solib_call_trampoline)(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition hppa-tdep.h:104
CORE_ADDR addr() const
Definition objfiles.h:385
CORE_ADDR endaddr() const
Definition objfiles.h:392
struct objfile * objfile
Definition objfiles.h:401
iterator_range< section_iterator > sections()
Definition objfiles.h:685
Definition value.h:130
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1785
CORE_ADDR value_as_address(struct value *val)
Definition value.c:2636