]>
Commit | Line | Data |
---|---|---|
0e56aeaf MK |
1 | /* Target-dependent code for HP PA-RISC BSD's. |
2 | ||
213516ef | 3 | Copyright (C) 2004-2023 Free Software Foundation, Inc. |
0e56aeaf MK |
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 | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
0e56aeaf MK |
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 | |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0e56aeaf MK |
19 | |
20 | #include "defs.h" | |
dc28f363 | 21 | #include "objfiles.h" |
dc28f363 MK |
22 | #include "target.h" |
23 | #include "value.h" | |
0e56aeaf | 24 | |
dc28f363 MK |
25 | #include "elf/common.h" |
26 | ||
0e56aeaf | 27 | #include "hppa-tdep.h" |
03b62bbb | 28 | #include "hppa-bsd-tdep.h" |
82ca8957 | 29 | #include "dwarf2/frame.h" |
0e56aeaf MK |
30 | #include "solib-svr4.h" |
31 | ||
63807e1d | 32 | static CORE_ADDR |
e38c262f | 33 | hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function) |
dc28f363 | 34 | { |
e17a4113 | 35 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
dc28f363 MK |
36 | CORE_ADDR faddr = value_as_address (function); |
37 | struct obj_section *faddr_sec; | |
dc28f363 MK |
38 | |
39 | /* Is this a plabel? If so, dereference it to get the Global Pointer | |
40 | value. */ | |
41 | if (faddr & 2) | |
42 | { | |
b926417a | 43 | gdb_byte buf[4]; |
dc28f363 | 44 | if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0) |
e17a4113 | 45 | return extract_unsigned_integer (buf, sizeof buf, byte_order); |
dc28f363 MK |
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. */ | |
3e5d3a5a | 51 | if (in_plt_section (faddr)) |
dc28f363 MK |
52 | return 0; |
53 | ||
54 | faddr_sec = find_pc_section (faddr); | |
55 | if (faddr_sec != NULL) | |
56 | { | |
5250cbc8 | 57 | for (struct obj_section *sec : faddr_sec->objfile->sections ()) |
dc28f363 MK |
58 | { |
59 | if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0) | |
dc28f363 | 60 | { |
5250cbc8 TT |
61 | CORE_ADDR addr = sec->addr (); |
62 | CORE_ADDR endaddr = sec->endaddr (); | |
dc28f363 | 63 | |
5250cbc8 | 64 | while (addr < endaddr) |
dc28f363 | 65 | { |
5250cbc8 TT |
66 | gdb_byte buf[4]; |
67 | LONGEST tag; | |
dc28f363 | 68 | |
5250cbc8 | 69 | if (target_read_memory (addr, buf, sizeof buf) != 0) |
dc28f363 MK |
70 | break; |
71 | ||
5250cbc8 TT |
72 | tag = extract_signed_integer (buf, byte_order); |
73 | if (tag == DT_PLTGOT) | |
74 | { | |
75 | CORE_ADDR pltgot; | |
af5ca30d | 76 | |
5250cbc8 TT |
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 | } | |
dc28f363 | 88 | |
5250cbc8 TT |
89 | if (tag == DT_NULL) |
90 | break; | |
91 | ||
92 | addr += 8; | |
93 | } | |
dc28f363 | 94 | |
5250cbc8 | 95 | break; |
dc28f363 MK |
96 | } |
97 | } | |
98 | } | |
99 | ||
100 | return 0; | |
101 | } | |
102 | \f | |
103 | ||
17767988 MK |
104 | static void |
105 | hppabsd_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, | |
106 | struct dwarf2_frame_state_reg *reg, | |
bd2b40ac | 107 | frame_info_ptr this_frame) |
17767988 MK |
108 | { |
109 | if (regnum == HPPA_PCOQ_HEAD_REGNUM) | |
110 | reg->how = DWARF2_FRAME_REG_RA; | |
111 | else if (regnum == HPPA_SP_REGNUM) | |
112 | reg->how = DWARF2_FRAME_REG_CFA; | |
113 | } | |
114 | ||
af5ca30d | 115 | void |
0e56aeaf MK |
116 | hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
117 | { | |
08106042 | 118 | hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch); |
0e56aeaf | 119 | |
ed944ce7 MK |
120 | /* OpenBSD and NetBSD have a 64-bit 'long double'. */ |
121 | set_gdbarch_long_double_bit (gdbarch, 64); | |
8da61cc4 | 122 | set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double); |
ed944ce7 | 123 | |
0e56aeaf MK |
124 | /* OpenBSD and NetBSD use ELF. */ |
125 | tdep->is_elf = 1; | |
34f55018 MK |
126 | tdep->find_global_pointer = hppabsd_find_global_pointer; |
127 | tdep->in_solib_call_trampoline = hppa_in_solib_call_trampoline; | |
128 | set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code); | |
0e56aeaf | 129 | |
ed944ce7 | 130 | /* OpenBSD and NetBSD use SVR4-style shared libraries. */ |
0e56aeaf MK |
131 | set_solib_svr4_fetch_link_map_offsets |
132 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
17767988 MK |
133 | |
134 | /* Hook in the DWARF CFI frame unwinder. */ | |
135 | dwarf2_frame_set_init_reg (gdbarch, hppabsd_dwarf2_frame_init_reg); | |
136 | dwarf2_append_unwinders (gdbarch); | |
0e56aeaf | 137 | } |