Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / hppabsd-tdep.c
blobd95d6c5ae45562a58687a70840f8a977ab8e1fa8
1 /* Target-dependent code for HP PA-RISC BSD's.
3 Copyright (C) 2004, 2005, 2006 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 2 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, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 #include "defs.h"
23 #include "arch-utils.h"
24 #include "symtab.h"
25 #include "objfiles.h"
26 #include "osabi.h"
27 #include "regcache.h"
28 #include "regset.h"
29 #include "target.h"
30 #include "value.h"
32 #include "gdb_assert.h"
33 #include "gdb_string.h"
35 #include "elf/common.h"
37 #include "hppa-tdep.h"
38 #include "solib-svr4.h"
41 CORE_ADDR
42 hppabsd_find_global_pointer (struct value *function)
44 CORE_ADDR faddr = value_as_address (function);
45 struct obj_section *faddr_sec;
46 gdb_byte buf[4];
48 /* Is this a plabel? If so, dereference it to get the Global Pointer
49 value. */
50 if (faddr & 2)
52 if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0)
53 return extract_unsigned_integer (buf, sizeof buf);
56 /* If the address is in the .plt section, then the real function
57 hasn't yet been fixed up by the linker so we cannot determine the
58 Global Pointer for that function. */
59 if (in_plt_section (faddr, NULL))
60 return 0;
62 faddr_sec = find_pc_section (faddr);
63 if (faddr_sec != NULL)
65 struct obj_section *sec;
67 ALL_OBJFILE_OSECTIONS (faddr_sec->objfile, sec)
69 if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
70 break;
73 if (sec < faddr_sec->objfile->sections_end)
75 CORE_ADDR addr = sec->addr;
77 while (addr < sec->endaddr)
79 gdb_byte buf[4];
80 LONGEST tag;
82 if (target_read_memory (addr, buf, sizeof buf) != 0)
83 break;
85 tag = extract_signed_integer (buf, sizeof buf);
86 if (tag == DT_PLTGOT)
88 CORE_ADDR pltgot;
90 if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
91 break;
93 /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
94 we have to do it ourselves. */
95 pltgot = extract_unsigned_integer (buf, sizeof buf);
96 pltgot += ANOFFSET (sec->objfile->section_offsets,
97 SECT_OFF_TEXT (sec->objfile));
99 return pltgot;
102 if (tag == DT_NULL)
103 break;
105 addr += 8;
110 return 0;
114 void
115 hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
117 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
119 /* OpenBSD and NetBSD have a 64-bit 'long double'. */
120 set_gdbarch_long_double_bit (gdbarch, 64);
121 set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
123 /* OpenBSD and NetBSD use ELF. */
124 tdep->is_elf = 1;
125 tdep->find_global_pointer = hppabsd_find_global_pointer;
126 tdep->in_solib_call_trampoline = hppa_in_solib_call_trampoline;
127 set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code);
129 /* OpenBSD and NetBSD use SVR4-style shared libraries. */
130 set_solib_svr4_fetch_link_map_offsets
131 (gdbarch, svr4_ilp32_fetch_link_map_offsets);