OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [hppabsd-tdep.c] - Blame information for rev 173

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Target-dependent code for HP PA-RISC BSD's.
2
 
3
   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
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
9
   the Free Software Foundation; either version 3 of the License, or
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
18
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
 
20
#include "defs.h"
21
#include "objfiles.h"
22
#include "target.h"
23
#include "value.h"
24
 
25
#include "elf/common.h"
26
 
27
#include "hppa-tdep.h"
28
#include "solib-svr4.h"
29
 
30
CORE_ADDR
31
hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
32
{
33
  CORE_ADDR faddr = value_as_address (function);
34
  struct obj_section *faddr_sec;
35
  gdb_byte buf[4];
36
 
37
  /* Is this a plabel? If so, dereference it to get the Global Pointer
38
     value.  */
39
  if (faddr & 2)
40
    {
41
      if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0)
42
        return extract_unsigned_integer (buf, sizeof buf);
43
    }
44
 
45
  /* If the address is in the .plt section, then the real function
46
     hasn't yet been fixed up by the linker so we cannot determine the
47
     Global Pointer for that function.  */
48
  if (in_plt_section (faddr, NULL))
49
    return 0;
50
 
51
  faddr_sec = find_pc_section (faddr);
52
  if (faddr_sec != NULL)
53
    {
54
      struct obj_section *sec;
55
 
56
      ALL_OBJFILE_OSECTIONS (faddr_sec->objfile, sec)
57
        {
58
          if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
59
            break;
60
        }
61
 
62
      if (sec < faddr_sec->objfile->sections_end)
63
        {
64
          CORE_ADDR addr = sec->addr;
65
 
66
          while (addr < sec->endaddr)
67
            {
68
              gdb_byte buf[4];
69
              LONGEST tag;
70
 
71
              if (target_read_memory (addr, buf, sizeof buf) != 0)
72
                break;
73
 
74
              tag = extract_signed_integer (buf, sizeof buf);
75
              if (tag == DT_PLTGOT)
76
                {
77
                  CORE_ADDR pltgot;
78
 
79
                  if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
80
                    break;
81
 
82
                  /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
83
                     we have to do it ourselves.  */
84
                  pltgot = extract_unsigned_integer (buf, sizeof buf);
85
                  pltgot += ANOFFSET (sec->objfile->section_offsets,
86
                                      SECT_OFF_TEXT (sec->objfile));
87
 
88
                  return pltgot;
89
                }
90
 
91
              if (tag == DT_NULL)
92
                break;
93
 
94
              addr += 8;
95
            }
96
        }
97
    }
98
 
99
  return 0;
100
}
101
 
102
 
103
void
104
hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
105
{
106
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
107
 
108
  /* OpenBSD and NetBSD have a 64-bit 'long double'.  */
109
  set_gdbarch_long_double_bit (gdbarch, 64);
110
  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
111
 
112
  /* OpenBSD and NetBSD use ELF.  */
113
  tdep->is_elf = 1;
114
  tdep->find_global_pointer = hppabsd_find_global_pointer;
115
  tdep->in_solib_call_trampoline = hppa_in_solib_call_trampoline;
116
  set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code);
117
 
118
  /* OpenBSD and NetBSD use SVR4-style shared libraries.  */
119
  set_solib_svr4_fetch_link_map_offsets
120
    (gdbarch, svr4_ilp32_fetch_link_map_offsets);
121
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.