1 |
/* BFD back-end for Irix core files. |
/* BFD back-end for Irix core files. |
2 |
Copyright 1993, 1994, 1996, 1999, 2001, 2002 |
Copyright 1993, 1994, 1996, 1999, 2001, 2002, 2004 |
3 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
4 |
Written by Stu Grossman, Cygnus Support. |
Written by Stu Grossman, Cygnus Support. |
5 |
Converted to back-end form by Ian Lance Taylor, Cygnus Support |
Converted to back-end form by Ian Lance Taylor, Cygnus Support |
6 |
|
|
7 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
10 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
11 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
12 |
(at your option) any later version. |
(at your option) any later version. |
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
GNU General Public License for more details. |
GNU General Public License for more details. |
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
20 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
21 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
22 |
|
|
23 |
/* This file can only be compiled on systems which use Irix style core |
/* This file can only be compiled on systems which use Irix style core |
24 |
files (namely, Irix 4 and Irix 5, so far). */ |
files (namely, Irix 4 and Irix 5, so far). */ |
43 |
|
|
44 |
static asection *make_bfd_asection |
static asection *make_bfd_asection |
45 |
PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr)); |
PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr)); |
46 |
static const bfd_target *irix_core_core_file_p PARAMS ((bfd *)); |
static const bfd_target *irix_core_core_file_p |
47 |
static char *irix_core_core_file_failing_command PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
48 |
static int irix_core_core_file_failing_signal PARAMS ((bfd *)); |
static char *irix_core_core_file_failing_command |
49 |
static boolean irix_core_core_file_matches_executable_p |
PARAMS ((bfd *)); |
50 |
|
static int irix_core_core_file_failing_signal |
51 |
|
PARAMS ((bfd *)); |
52 |
|
static bfd_boolean irix_core_core_file_matches_executable_p |
53 |
PARAMS ((bfd *, bfd *)); |
PARAMS ((bfd *, bfd *)); |
54 |
static void swap_abort PARAMS ((void)); |
static void swap_abort |
55 |
|
PARAMS ((void)); |
56 |
|
#ifdef CORE_MAGIC64 |
57 |
|
static int do_sections64 |
58 |
|
PARAMS ((bfd *, struct coreout *)); |
59 |
|
#endif |
60 |
|
static int do_sections |
61 |
|
PARAMS ((bfd *, struct coreout *)); |
62 |
|
|
63 |
|
/* Helper function for irix_core_core_file_p: |
64 |
|
32-bit and 64-bit versions. */ |
65 |
|
|
66 |
|
#ifdef CORE_MAGIC64 |
67 |
|
static int |
68 |
|
do_sections64 (abfd, coreout) |
69 |
|
bfd * abfd; |
70 |
|
struct coreout * coreout; |
71 |
|
{ |
72 |
|
struct vmap64 vmap; |
73 |
|
char *secname; |
74 |
|
int i, val; |
75 |
|
|
76 |
|
for (i = 0; i < coreout->c_nvmap; i++) |
77 |
|
{ |
78 |
|
val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd); |
79 |
|
if (val != sizeof vmap) |
80 |
|
break; |
81 |
|
|
82 |
|
switch (vmap.v_type) |
83 |
|
{ |
84 |
|
case VDATA: |
85 |
|
secname = ".data"; |
86 |
|
break; |
87 |
|
case VSTACK: |
88 |
|
secname = ".stack"; |
89 |
|
break; |
90 |
|
#ifdef VMAPFILE |
91 |
|
case VMAPFILE: |
92 |
|
secname = ".mapfile"; |
93 |
|
break; |
94 |
|
#endif |
95 |
|
default: |
96 |
|
continue; |
97 |
|
} |
98 |
|
|
99 |
|
/* A file offset of zero means that the |
100 |
|
section is not contained in the corefile. */ |
101 |
|
if (vmap.v_offset == 0) |
102 |
|
continue; |
103 |
|
|
104 |
|
if (!make_bfd_asection (abfd, secname, |
105 |
|
SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS, |
106 |
|
vmap.v_len, vmap.v_vaddr, vmap.v_offset)) |
107 |
|
/* Fail. */ |
108 |
|
return 0; |
109 |
|
} |
110 |
|
|
111 |
|
return 1; |
112 |
|
} |
113 |
|
#endif |
114 |
|
|
115 |
|
/* 32-bit version. */ |
116 |
|
|
117 |
|
static int |
118 |
|
do_sections (abfd, coreout) |
119 |
|
bfd * abfd; |
120 |
|
struct coreout *coreout; |
121 |
|
{ |
122 |
|
struct vmap vmap; |
123 |
|
char *secname; |
124 |
|
int i, val; |
125 |
|
|
126 |
|
for (i = 0; i < coreout->c_nvmap; i++) |
127 |
|
{ |
128 |
|
val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd); |
129 |
|
if (val != sizeof vmap) |
130 |
|
break; |
131 |
|
|
132 |
|
switch (vmap.v_type) |
133 |
|
{ |
134 |
|
case VDATA: |
135 |
|
secname = ".data"; |
136 |
|
break; |
137 |
|
case VSTACK: |
138 |
|
secname = ".stack"; |
139 |
|
break; |
140 |
|
#ifdef VMAPFILE |
141 |
|
case VMAPFILE: |
142 |
|
secname = ".mapfile"; |
143 |
|
break; |
144 |
|
#endif |
145 |
|
default: |
146 |
|
continue; |
147 |
|
} |
148 |
|
|
149 |
|
/* A file offset of zero means that the |
150 |
|
section is not contained in the corefile. */ |
151 |
|
if (vmap.v_offset == 0) |
152 |
|
continue; |
153 |
|
|
154 |
|
if (!make_bfd_asection (abfd, secname, |
155 |
|
SEC_ALLOC | SEC_LOAD+SEC_HAS_CONTENTS, |
156 |
|
vmap.v_len, vmap.v_vaddr, vmap.v_offset)) |
157 |
|
/* Fail. */ |
158 |
|
return 0; |
159 |
|
} |
160 |
|
return 1; |
161 |
|
} |
162 |
|
|
163 |
static asection * |
static asection * |
164 |
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) |
make_bfd_asection (abfd, name, flags, size, vma, filepos) |
165 |
bfd *abfd; |
bfd *abfd; |
166 |
const char *name; |
const char *name; |
167 |
flagword flags; |
flagword flags; |
168 |
bfd_size_type _raw_size; |
bfd_size_type size; |
169 |
bfd_vma vma; |
bfd_vma vma; |
170 |
file_ptr filepos; |
file_ptr filepos; |
171 |
{ |
{ |
176 |
return NULL; |
return NULL; |
177 |
|
|
178 |
asect->flags = flags; |
asect->flags = flags; |
179 |
asect->_raw_size = _raw_size; |
asect->size = size; |
180 |
asect->vma = vma; |
asect->vma = vma; |
181 |
asect->filepos = filepos; |
asect->filepos = filepos; |
182 |
asect->alignment_power = 4; |
asect->alignment_power = 4; |
189 |
bfd *abfd; |
bfd *abfd; |
190 |
{ |
{ |
191 |
int val; |
int val; |
|
int i; |
|
|
char *secname; |
|
192 |
struct coreout coreout; |
struct coreout coreout; |
193 |
struct idesc *idg, *idf, *ids; |
struct idesc *idg, *idf, *ids; |
194 |
bfd_size_type amt; |
bfd_size_type amt; |
201 |
return 0; |
return 0; |
202 |
} |
} |
203 |
|
|
204 |
#ifndef CORE_MAGICN32 |
if (coreout.c_version != CORE_VERSION1) |
|
#define CORE_MAGICN32 CORE_MAGIC |
|
|
#endif |
|
|
if ((coreout.c_magic != CORE_MAGIC && coreout.c_magic != CORE_MAGICN32) |
|
|
|| coreout.c_version != CORE_VERSION1) |
|
205 |
return 0; |
return 0; |
206 |
|
|
207 |
|
/* Have we got a corefile? */ |
208 |
|
switch (coreout.c_magic) |
209 |
|
{ |
210 |
|
case CORE_MAGIC: break; |
211 |
|
#ifdef CORE_MAGIC64 |
212 |
|
case CORE_MAGIC64: break; |
213 |
|
#endif |
214 |
|
#ifdef CORE_MAGICN32 |
215 |
|
case CORE_MAGICN32: break; |
216 |
|
#endif |
217 |
|
default: return 0; /* Un-identifiable or not corefile. */ |
218 |
|
} |
219 |
|
|
220 |
amt = sizeof (struct sgi_core_struct); |
amt = sizeof (struct sgi_core_struct); |
221 |
core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt); |
core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt); |
222 |
if (!core_hdr (abfd)) |
if (!core_hdr (abfd)) |
228 |
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0) |
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0) |
229 |
goto fail; |
goto fail; |
230 |
|
|
231 |
for (i = 0; i < coreout.c_nvmap; i++) |
/* Process corefile sections. */ |
232 |
|
#ifdef CORE_MAGIC64 |
233 |
|
if (coreout.c_magic == (int) CORE_MAGIC64) |
234 |
{ |
{ |
235 |
struct vmap vmap; |
if (! do_sections64 (abfd, & coreout)) |
|
|
|
|
val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd); |
|
|
if (val != sizeof vmap) |
|
|
break; |
|
|
|
|
|
switch (vmap.v_type) |
|
|
{ |
|
|
case VDATA: |
|
|
secname = ".data"; |
|
|
break; |
|
|
case VSTACK: |
|
|
secname = ".stack"; |
|
|
break; |
|
|
#ifdef VMAPFILE |
|
|
case VMAPFILE: |
|
|
secname = ".mapfile"; |
|
|
break; |
|
|
#endif |
|
|
default: |
|
|
continue; |
|
|
} |
|
|
|
|
|
/* A file offset of zero means that the section is not contained |
|
|
in the corefile. */ |
|
|
if (vmap.v_offset == 0) |
|
|
continue; |
|
|
|
|
|
if (!make_bfd_asection (abfd, secname, |
|
|
SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS, |
|
|
vmap.v_len, |
|
|
vmap.v_vaddr, |
|
|
vmap.v_offset)) |
|
236 |
goto fail; |
goto fail; |
237 |
} |
} |
238 |
|
else |
239 |
|
#endif |
240 |
|
if (! do_sections (abfd, & coreout)) |
241 |
|
goto fail; |
242 |
|
|
243 |
/* Make sure that the regs are contiguous within the core file. */ |
/* Make sure that the regs are contiguous within the core file. */ |
244 |
|
|
245 |
idg = &coreout.c_idesc[I_GPREGS]; |
idg = &coreout.c_idesc[I_GPREGS]; |
246 |
idf = &coreout.c_idesc[I_FPREGS]; |
idf = &coreout.c_idesc[I_FPREGS]; |
286 |
return core_signal (abfd); |
return core_signal (abfd); |
287 |
} |
} |
288 |
|
|
289 |
static boolean |
static bfd_boolean |
290 |
irix_core_core_file_matches_executable_p (core_bfd, exec_bfd) |
irix_core_core_file_matches_executable_p (core_bfd, exec_bfd) |
291 |
bfd *core_bfd, *exec_bfd; |
bfd *core_bfd, *exec_bfd; |
292 |
{ |
{ |
293 |
return true; /* XXX - FIXME */ |
return TRUE; /* XXX - FIXME */ |
294 |
} |
} |
295 |
|
|
296 |
/* If somebody calls any byte-swapping routines, shoot them. */ |
/* If somebody calls any byte-swapping routines, shoot them. */ |
299 |
{ |
{ |
300 |
abort(); /* This way doesn't require any declaration for ANSI to fuck up */ |
abort(); /* This way doesn't require any declaration for ANSI to fuck up */ |
301 |
} |
} |
302 |
#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort ) |
|
303 |
#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort ) |
#define NO_GET ((bfd_vma (*) (const void *)) swap_abort) |
304 |
#define NO_SIGNED_GET \ |
#define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) |
305 |
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort ) |
#define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) |
306 |
|
#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) |
307 |
|
#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) |
308 |
|
#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) |
309 |
|
|
310 |
const bfd_target irix_core_vec = |
const bfd_target irix_core_vec = |
311 |
{ |
{ |
320 |
0, /* symbol prefix */ |
0, /* symbol prefix */ |
321 |
' ', /* ar_pad_char */ |
' ', /* ar_pad_char */ |
322 |
16, /* ar_max_namelen */ |
16, /* ar_max_namelen */ |
323 |
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */ |
NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit data */ |
324 |
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */ |
NO_GET, NO_GETS, NO_PUT, /* 32 bit data */ |
325 |
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */ |
NO_GET, NO_GETS, NO_PUT, /* 16 bit data */ |
326 |
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */ |
NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit hdrs */ |
327 |
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */ |
NO_GET, NO_GETS, NO_PUT, /* 32 bit hdrs */ |
328 |
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */ |
NO_GET, NO_GETS, NO_PUT, /* 16 bit hdrs */ |
329 |
|
|
330 |
{ /* bfd_check_format */ |
{ /* bfd_check_format */ |
331 |
_bfd_dummy_target, /* unknown format */ |
_bfd_dummy_target, /* unknown format */ |
332 |
_bfd_dummy_target, /* object file */ |
_bfd_dummy_target, /* object file */ |
333 |
_bfd_dummy_target, /* archive */ |
_bfd_dummy_target, /* archive */ |
334 |
irix_core_core_file_p /* a core file */ |
irix_core_core_file_p /* a core file */ |
335 |
}, |
}, |
336 |
{ /* bfd_set_format */ |
{ /* bfd_set_format */ |
337 |
bfd_false, bfd_false, |
bfd_false, bfd_false, |
338 |
bfd_false, bfd_false |
bfd_false, bfd_false |
339 |
}, |
}, |
340 |
{ /* bfd_write_contents */ |
{ /* bfd_write_contents */ |
341 |
bfd_false, bfd_false, |
bfd_false, bfd_false, |
342 |
bfd_false, bfd_false |
bfd_false, bfd_false |
343 |
}, |
}, |
344 |
|
|
345 |
BFD_JUMP_TABLE_GENERIC (_bfd_generic), |
BFD_JUMP_TABLE_GENERIC (_bfd_generic), |
355 |
NULL, |
NULL, |
356 |
|
|
357 |
(PTR) 0 /* backend_data */ |
(PTR) 0 /* backend_data */ |
358 |
}; |
}; |
359 |
|
|
360 |
#endif /* IRIX_CORE */ |
#endif /* IRIX_CORE */ |