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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [gdb-5.0/] [bfd/] [irix-core.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* BFD back-end for Irix core files.
2
   Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
3
   Written by Stu Grossman, Cygnus Support.
4
   Converted to back-end form by Ian Lance Taylor, Cygnus Support
5
 
6
This file is part of BFD, the Binary File Descriptor library.
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 2 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, write to the Free Software
20
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21
 
22
/* This file can only be compiled on systems which use Irix style core
23
   files (namely, Irix 4 and Irix 5, so far).  */
24
 
25
#include "bfd.h"
26
#include "sysdep.h"
27
#include "libbfd.h"
28
 
29
#ifdef IRIX_CORE
30
 
31
#include <core.out.h>
32
 
33
struct sgi_core_struct
34
{
35
  int sig;
36
  char cmd[CORE_NAMESIZE];
37
};
38
 
39
#define core_hdr(bfd) ((bfd)->tdata.sgi_core_data)
40
#define core_signal(bfd) (core_hdr(bfd)->sig)
41
#define core_command(bfd) (core_hdr(bfd)->cmd)
42
 
43
static asection *make_bfd_asection
44
  PARAMS ((bfd *, CONST char *, flagword, bfd_size_type, bfd_vma, file_ptr));
45
static const bfd_target *irix_core_core_file_p PARAMS ((bfd *));
46
static char *irix_core_core_file_failing_command PARAMS ((bfd *));
47
static int irix_core_core_file_failing_signal PARAMS ((bfd *));
48
static boolean irix_core_core_file_matches_executable_p
49
  PARAMS ((bfd *, bfd *));
50
static asymbol *irix_core_make_empty_symbol PARAMS ((bfd *));
51
static void swap_abort PARAMS ((void));
52
 
53
static asection *
54
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
55
     bfd *abfd;
56
     CONST char *name;
57
     flagword flags;
58
     bfd_size_type _raw_size;
59
     bfd_vma vma;
60
     file_ptr filepos;
61
{
62
  asection *asect;
63
 
64
  asect = bfd_make_section_anyway (abfd, name);
65
  if (!asect)
66
    return NULL;
67
 
68
  asect->flags = flags;
69
  asect->_raw_size = _raw_size;
70
  asect->vma = vma;
71
  asect->filepos = filepos;
72
  asect->alignment_power = 4;
73
 
74
  return asect;
75
}
76
 
77
static const bfd_target *
78
irix_core_core_file_p (abfd)
79
     bfd *abfd;
80
{
81
  int val;
82
  int i;
83
  char *secname;
84
  struct coreout coreout;
85
  struct idesc *idg, *idf, *ids;
86
 
87
  val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd);
88
  if (val != sizeof coreout)
89
    {
90
      if (bfd_get_error () != bfd_error_system_call)
91
        bfd_set_error (bfd_error_wrong_format);
92
      return 0;
93
    }
94
 
95
#ifndef CORE_MAGICN32
96
#define CORE_MAGICN32 CORE_MAGIC
97
#endif
98
  if ((coreout.c_magic != CORE_MAGIC && coreout.c_magic != CORE_MAGICN32)
99
      || coreout.c_version != CORE_VERSION1)
100
    return 0;
101
 
102
  core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, sizeof (struct sgi_core_struct));
103
  if (!core_hdr (abfd))
104
    return NULL;
105
 
106
  strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE);
107
  core_signal (abfd) = coreout.c_sigcause;
108
 
109
  if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
110
    return NULL;
111
 
112
  for (i = 0; i < coreout.c_nvmap; i++)
113
    {
114
      struct vmap vmap;
115
 
116
      val = bfd_read ((PTR)&vmap, 1, sizeof vmap, abfd);
117
      if (val != sizeof vmap)
118
        break;
119
 
120
      switch (vmap.v_type)
121
        {
122
        case VDATA:
123
          secname = ".data";
124
          break;
125
        case VSTACK:
126
          secname = ".stack";
127
          break;
128
#ifdef VMAPFILE
129
        case VMAPFILE:
130
          secname = ".mapfile";
131
          break;
132
#endif
133
        default:
134
          continue;
135
        }
136
 
137
      /* A file offset of zero means that the section is not contained
138
         in the corefile.  */
139
      if (vmap.v_offset == 0)
140
        continue;
141
 
142
      if (!make_bfd_asection (abfd, secname,
143
                              SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
144
                              vmap.v_len,
145
                              vmap.v_vaddr,
146
                              vmap.v_offset))
147
        return NULL;
148
    }
149
 
150
  /* Make sure that the regs are contiguous within the core file. */
151
 
152
  idg = &coreout.c_idesc[I_GPREGS];
153
  idf = &coreout.c_idesc[I_FPREGS];
154
  ids = &coreout.c_idesc[I_SPECREGS];
155
 
156
  if (idg->i_offset + idg->i_len != idf->i_offset
157
      || idf->i_offset + idf->i_len != ids->i_offset)
158
    return 0;                    /* Can't deal with non-contig regs */
159
 
160
  if (bfd_seek (abfd, idg->i_offset, SEEK_SET) != 0)
161
    return NULL;
162
 
163
  make_bfd_asection (abfd, ".reg",
164
                     SEC_HAS_CONTENTS,
165
                     idg->i_len + idf->i_len + ids->i_len,
166
                     0,
167
                     idg->i_offset);
168
 
169
  /* OK, we believe you.  You're a core file (sure, sure).  */
170
 
171
  return abfd->xvec;
172
}
173
 
174
static char *
175
irix_core_core_file_failing_command (abfd)
176
     bfd *abfd;
177
{
178
  return core_command (abfd);
179
}
180
 
181
static int
182
irix_core_core_file_failing_signal (abfd)
183
     bfd *abfd;
184
{
185
  return core_signal (abfd);
186
}
187
 
188
static boolean
189
irix_core_core_file_matches_executable_p (core_bfd, exec_bfd)
190
     bfd *core_bfd, *exec_bfd;
191
{
192
  return true;                  /* XXX - FIXME */
193
}
194
 
195
static asymbol *
196
irix_core_make_empty_symbol (abfd)
197
     bfd *abfd;
198
{
199
  asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
200
  if (new)
201
    new->the_bfd = abfd;
202
  return new;
203
}
204
 
205
#define irix_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
206
#define irix_core_get_symtab _bfd_nosymbols_get_symtab
207
#define irix_core_print_symbol _bfd_nosymbols_print_symbol
208
#define irix_core_get_symbol_info _bfd_nosymbols_get_symbol_info
209
#define irix_core_bfd_is_local_label_name \
210
  _bfd_nosymbols_bfd_is_local_label_name
211
#define irix_core_get_lineno _bfd_nosymbols_get_lineno
212
#define irix_core_find_nearest_line _bfd_nosymbols_find_nearest_line
213
#define irix_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
214
#define irix_core_read_minisymbols _bfd_nosymbols_read_minisymbols
215
#define irix_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
216
 
217
/* If somebody calls any byte-swapping routines, shoot them.  */
218
static void
219
swap_abort()
220
{
221
  abort(); /* This way doesn't require any declaration for ANSI to fuck up */
222
}
223
#define NO_GET  ((bfd_vma (*) PARAMS ((   const bfd_byte *))) swap_abort )
224
#define NO_PUT  ((void    (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
225
#define NO_SIGNED_GET \
226
  ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
227
 
228
const bfd_target irix_core_vec =
229
  {
230
    "irix-core",
231
    bfd_target_unknown_flavour,
232
    BFD_ENDIAN_BIG,             /* target byte order */
233
    BFD_ENDIAN_BIG,             /* target headers byte order */
234
    (HAS_RELOC | EXEC_P |       /* object flags */
235
     HAS_LINENO | HAS_DEBUG |
236
     HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
237
    (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
238
    0,                                                      /* symbol prefix */
239
    ' ',                                                   /* ar_pad_char */
240
    16,                                                    /* ar_max_namelen */
241
    NO_GET, NO_SIGNED_GET, NO_PUT,      /* 64 bit data */
242
    NO_GET, NO_SIGNED_GET, NO_PUT,      /* 32 bit data */
243
    NO_GET, NO_SIGNED_GET, NO_PUT,      /* 16 bit data */
244
    NO_GET, NO_SIGNED_GET, NO_PUT,      /* 64 bit hdrs */
245
    NO_GET, NO_SIGNED_GET, NO_PUT,      /* 32 bit hdrs */
246
    NO_GET, NO_SIGNED_GET, NO_PUT,      /* 16 bit hdrs */
247
 
248
    {                           /* bfd_check_format */
249
     _bfd_dummy_target,         /* unknown format */
250
     _bfd_dummy_target,         /* object file */
251
     _bfd_dummy_target,         /* archive */
252
     irix_core_core_file_p      /* a core file */
253
    },
254
    {                           /* bfd_set_format */
255
     bfd_false, bfd_false,
256
     bfd_false, bfd_false
257
    },
258
    {                           /* bfd_write_contents */
259
     bfd_false, bfd_false,
260
     bfd_false, bfd_false
261
    },
262
 
263
       BFD_JUMP_TABLE_GENERIC (_bfd_generic),
264
       BFD_JUMP_TABLE_COPY (_bfd_generic),
265
       BFD_JUMP_TABLE_CORE (irix_core),
266
       BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
267
       BFD_JUMP_TABLE_SYMBOLS (irix_core),
268
       BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
269
       BFD_JUMP_TABLE_WRITE (_bfd_generic),
270
       BFD_JUMP_TABLE_LINK (_bfd_nolink),
271
       BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
272
 
273
    NULL,
274
 
275
    (PTR) 0                      /* backend_data */
276
};
277
 
278
#endif /* IRIX_CORE */

powered by: WebSVN 2.1.0

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