Fix host_name and target_name generation by common/create-version.sh.
[deliverable/binutils-gdb.git] / gdb / hppabsd-tdep.c
CommitLineData
0e56aeaf
MK
1/* Target-dependent code for HP PA-RISC BSD's.
2
28e7fd62 3 Copyright (C) 2004-2013 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"
63807e1d 28#include "hppabsd-tdep.h"
0e56aeaf
MK
29#include "solib-svr4.h"
30
63807e1d 31static CORE_ADDR
e38c262f 32hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
dc28f363 33{
e17a4113 34 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
dc28f363
MK
35 CORE_ADDR faddr = value_as_address (function);
36 struct obj_section *faddr_sec;
37 gdb_byte buf[4];
38
39 /* Is this a plabel? If so, dereference it to get the Global Pointer
40 value. */
41 if (faddr & 2)
42 {
43 if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0)
e17a4113 44 return extract_unsigned_integer (buf, sizeof buf, byte_order);
dc28f363
MK
45 }
46
47 /* If the address is in the .plt section, then the real function
48 hasn't yet been fixed up by the linker so we cannot determine the
49 Global Pointer for that function. */
50 if (in_plt_section (faddr, NULL))
51 return 0;
52
53 faddr_sec = find_pc_section (faddr);
54 if (faddr_sec != NULL)
55 {
56 struct obj_section *sec;
57
58 ALL_OBJFILE_OSECTIONS (faddr_sec->objfile, sec)
59 {
60 if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
61 break;
62 }
63
64 if (sec < faddr_sec->objfile->sections_end)
65 {
aded6f54
PA
66 CORE_ADDR addr = obj_section_addr (sec);
67 CORE_ADDR endaddr = obj_section_endaddr (sec);
dc28f363 68
aded6f54 69 while (addr < endaddr)
dc28f363
MK
70 {
71 gdb_byte buf[4];
72 LONGEST tag;
73
74 if (target_read_memory (addr, buf, sizeof buf) != 0)
75 break;
76
e17a4113 77 tag = extract_signed_integer (buf, sizeof buf, byte_order);
dc28f363
MK
78 if (tag == DT_PLTGOT)
79 {
80 CORE_ADDR pltgot;
81
82 if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
83 break;
84
af5ca30d 85 /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
dc28f363 86 we have to do it ourselves. */
e17a4113
UW
87 pltgot = extract_unsigned_integer (buf, sizeof buf,
88 byte_order);
dc28f363
MK
89 pltgot += ANOFFSET (sec->objfile->section_offsets,
90 SECT_OFF_TEXT (sec->objfile));
af5ca30d 91
dc28f363
MK
92 return pltgot;
93 }
94
95 if (tag == DT_NULL)
96 break;
97
98 addr += 8;
99 }
100 }
101 }
102
103 return 0;
104}
105\f
106
af5ca30d 107void
0e56aeaf
MK
108hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
109{
110 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
111
ed944ce7
MK
112 /* OpenBSD and NetBSD have a 64-bit 'long double'. */
113 set_gdbarch_long_double_bit (gdbarch, 64);
8da61cc4 114 set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
ed944ce7 115
0e56aeaf
MK
116 /* OpenBSD and NetBSD use ELF. */
117 tdep->is_elf = 1;
34f55018
MK
118 tdep->find_global_pointer = hppabsd_find_global_pointer;
119 tdep->in_solib_call_trampoline = hppa_in_solib_call_trampoline;
120 set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code);
0e56aeaf 121
ed944ce7 122 /* OpenBSD and NetBSD use SVR4-style shared libraries. */
0e56aeaf
MK
123 set_solib_svr4_fetch_link_map_offsets
124 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
125}
This page took 0.888032 seconds and 4 git commands to generate.