1 /* Target-dependent code for HP PA-RISC BSD's.
3 Copyright (C) 2004-2020 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/>. */
25 #include "elf/common.h"
27 #include "hppa-tdep.h"
28 #include "hppa-bsd-tdep.h"
29 #include "dwarf2-frame.h"
30 #include "solib-svr4.h"
33 hppabsd_find_global_pointer (struct gdbarch
*gdbarch
, struct value
*function
)
35 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
36 CORE_ADDR faddr
= value_as_address (function
);
37 struct obj_section
*faddr_sec
;
39 /* Is this a plabel? If so, dereference it to get the Global Pointer
44 if (target_read_memory ((faddr
& ~3) + 4, buf
, sizeof buf
) == 0)
45 return extract_unsigned_integer (buf
, sizeof buf
, byte_order
);
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
))
54 faddr_sec
= find_pc_section (faddr
);
55 if (faddr_sec
!= NULL
)
57 struct obj_section
*sec
;
59 ALL_OBJFILE_OSECTIONS (faddr_sec
->objfile
, sec
)
61 if (strcmp (sec
->the_bfd_section
->name
, ".dynamic") == 0)
65 if (sec
< faddr_sec
->objfile
->sections_end
)
67 CORE_ADDR addr
= obj_section_addr (sec
);
68 CORE_ADDR endaddr
= obj_section_endaddr (sec
);
70 while (addr
< endaddr
)
75 if (target_read_memory (addr
, buf
, sizeof buf
) != 0)
78 tag
= extract_signed_integer (buf
, sizeof buf
, byte_order
);
83 if (target_read_memory (addr
+ 4, buf
, sizeof buf
) != 0)
86 /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
87 we have to do it ourselves. */
88 pltgot
= extract_unsigned_integer (buf
, sizeof buf
,
90 pltgot
+= sec
->objfile
->text_section_offset ();
108 hppabsd_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
109 struct dwarf2_frame_state_reg
*reg
,
110 struct frame_info
*this_frame
)
112 if (regnum
== HPPA_PCOQ_HEAD_REGNUM
)
113 reg
->how
= DWARF2_FRAME_REG_RA
;
114 else if (regnum
== HPPA_SP_REGNUM
)
115 reg
->how
= DWARF2_FRAME_REG_CFA
;
119 hppabsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
121 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
123 /* OpenBSD and NetBSD have a 64-bit 'long double'. */
124 set_gdbarch_long_double_bit (gdbarch
, 64);
125 set_gdbarch_long_double_format (gdbarch
, floatformats_ieee_double
);
127 /* OpenBSD and NetBSD use ELF. */
129 tdep
->find_global_pointer
= hppabsd_find_global_pointer
;
130 tdep
->in_solib_call_trampoline
= hppa_in_solib_call_trampoline
;
131 set_gdbarch_skip_trampoline_code (gdbarch
, hppa_skip_trampoline_code
);
133 /* OpenBSD and NetBSD use SVR4-style shared libraries. */
134 set_solib_svr4_fetch_link_map_offsets
135 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
137 /* Hook in the DWARF CFI frame unwinder. */
138 dwarf2_frame_set_init_reg (gdbarch
, hppabsd_dwarf2_frame_init_reg
);
139 dwarf2_append_unwinders (gdbarch
);