Commit | Line | Data |
---|---|---|
0e56aeaf MK |
1 | /* Target-dependent code for HP PA-RISC BSD's. |
2 | ||
0fb0cc75 JB |
3 | Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 |
4 | Free Software Foundation, Inc. | |
0e56aeaf MK |
5 | |
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
0e56aeaf MK |
11 | (at your option) any later version. |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0e56aeaf MK |
20 | |
21 | #include "defs.h" | |
dc28f363 | 22 | #include "objfiles.h" |
dc28f363 MK |
23 | #include "target.h" |
24 | #include "value.h" | |
0e56aeaf | 25 | |
dc28f363 MK |
26 | #include "elf/common.h" |
27 | ||
0e56aeaf MK |
28 | #include "hppa-tdep.h" |
29 | #include "solib-svr4.h" | |
30 | ||
dc28f363 | 31 | CORE_ADDR |
e38c262f | 32 | hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function) |
dc28f363 MK |
33 | { |
34 | CORE_ADDR faddr = value_as_address (function); | |
35 | struct obj_section *faddr_sec; | |
36 | gdb_byte buf[4]; | |
37 | ||
38 | /* Is this a plabel? If so, dereference it to get the Global Pointer | |
39 | value. */ | |
40 | if (faddr & 2) | |
41 | { | |
42 | if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0) | |
43 | return extract_unsigned_integer (buf, sizeof buf); | |
44 | } | |
45 | ||
46 | /* If the address is in the .plt section, then the real function | |
47 | hasn't yet been fixed up by the linker so we cannot determine the | |
48 | Global Pointer for that function. */ | |
49 | if (in_plt_section (faddr, NULL)) | |
50 | return 0; | |
51 | ||
52 | faddr_sec = find_pc_section (faddr); | |
53 | if (faddr_sec != NULL) | |
54 | { | |
55 | struct obj_section *sec; | |
56 | ||
57 | ALL_OBJFILE_OSECTIONS (faddr_sec->objfile, sec) | |
58 | { | |
59 | if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0) | |
60 | break; | |
61 | } | |
62 | ||
63 | if (sec < faddr_sec->objfile->sections_end) | |
64 | { | |
aded6f54 PA |
65 | CORE_ADDR addr = obj_section_addr (sec); |
66 | CORE_ADDR endaddr = obj_section_endaddr (sec); | |
dc28f363 | 67 | |
aded6f54 | 68 | while (addr < endaddr) |
dc28f363 MK |
69 | { |
70 | gdb_byte buf[4]; | |
71 | LONGEST tag; | |
72 | ||
73 | if (target_read_memory (addr, buf, sizeof buf) != 0) | |
74 | break; | |
75 | ||
76 | tag = extract_signed_integer (buf, sizeof buf); | |
77 | if (tag == DT_PLTGOT) | |
78 | { | |
79 | CORE_ADDR pltgot; | |
80 | ||
81 | if (target_read_memory (addr + 4, buf, sizeof buf) != 0) | |
82 | break; | |
83 | ||
af5ca30d | 84 | /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so |
dc28f363 MK |
85 | we have to do it ourselves. */ |
86 | pltgot = extract_unsigned_integer (buf, sizeof buf); | |
87 | pltgot += ANOFFSET (sec->objfile->section_offsets, | |
88 | SECT_OFF_TEXT (sec->objfile)); | |
af5ca30d | 89 | |
dc28f363 MK |
90 | return pltgot; |
91 | } | |
92 | ||
93 | if (tag == DT_NULL) | |
94 | break; | |
95 | ||
96 | addr += 8; | |
97 | } | |
98 | } | |
99 | } | |
100 | ||
101 | return 0; | |
102 | } | |
103 | \f | |
104 | ||
af5ca30d | 105 | void |
0e56aeaf MK |
106 | hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
107 | { | |
108 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
109 | ||
ed944ce7 MK |
110 | /* OpenBSD and NetBSD have a 64-bit 'long double'. */ |
111 | set_gdbarch_long_double_bit (gdbarch, 64); | |
8da61cc4 | 112 | set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double); |
ed944ce7 | 113 | |
0e56aeaf MK |
114 | /* OpenBSD and NetBSD use ELF. */ |
115 | tdep->is_elf = 1; | |
34f55018 MK |
116 | tdep->find_global_pointer = hppabsd_find_global_pointer; |
117 | tdep->in_solib_call_trampoline = hppa_in_solib_call_trampoline; | |
118 | set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code); | |
0e56aeaf | 119 | |
ed944ce7 | 120 | /* OpenBSD and NetBSD use SVR4-style shared libraries. */ |
0e56aeaf MK |
121 | set_solib_svr4_fetch_link_map_offsets |
122 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
123 | } |