OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gdb-7.2/] [gdb/] [hppabsd-tdep.c] - Blame information for rev 857

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

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

powered by: WebSVN 2.1.0

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