|
|
@ -4,21 +4,21 @@ |
|
|
Written by Stu Grossman, Cygnus Support. |
|
|
Written by Stu Grossman, Cygnus Support. |
|
|
Converted to back-end form by Ian Lance Taylor, Cygnus Support |
|
|
Converted to back-end form by Ian Lance Taylor, Cygnus Support |
|
|
|
|
|
|
|
|
This file is part of BFD, the Binary File Descriptor library. |
|
|
This file is part of BFD, the Binary File Descriptor library. |
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
|
This program is free software; you can redistribute it and/or modify |
|
|
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 |
|
|
the Free Software Foundation; either version 2 of the License, or |
|
|
the Free Software Foundation; either version 2 of the License, or |
|
|
(at your option) any later version. |
|
|
(at your option) any later version. |
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
|
This program is distributed in the hope that it will be useful, |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
GNU General Public License for more details. |
|
|
GNU General Public License for more details. |
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
|
You should have received a copy of the GNU General Public License |
|
|
along with this program; if not, write to the Free Software |
|
|
along with this program; if not, write to the Free Software |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
|
|
|
|
|
|
|
/* 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
|
|
|
files (namely, Irix 4 and Irix 5, so far). */ |
|
|
files (namely, Irix 4 and Irix 5, so far). */ |
|
|
@ -49,6 +49,110 @@ static int irix_core_core_file_failing_signal PARAMS ((bfd *)); |
|
|
static boolean irix_core_core_file_matches_executable_p |
|
|
static boolean irix_core_core_file_matches_executable_p |
|
|
PARAMS ((bfd *, bfd *)); |
|
|
PARAMS ((bfd *, bfd *)); |
|
|
static void swap_abort PARAMS ((void)); |
|
|
static void swap_abort PARAMS ((void)); |
|
|
|
|
|
#ifdef CORE_MAGIC64 |
|
|
|
|
|
static int do_sections64 PARAMS ((bfd *, struct coreout *)); |
|
|
|
|
|
#endif |
|
|
|
|
|
static int do_sections PARAMS ((bfd *, struct coreout *)); |
|
|
|
|
|
|
|
|
|
|
|
/* Helper function for irix_core_core_file_p:
|
|
|
|
|
|
32-bit and 64-bit versions. */ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef CORE_MAGIC64 |
|
|
|
|
|
static int |
|
|
|
|
|
do_sections64 (abfd, coreout) |
|
|
|
|
|
bfd * abfd; |
|
|
|
|
|
struct coreout * coreout; |
|
|
|
|
|
{ |
|
|
|
|
|
struct vmap64 vmap; |
|
|
|
|
|
char *secname; |
|
|
|
|
|
int i, val; |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < coreout->c_nvmap; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
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)) |
|
|
|
|
|
/* Fail. */ |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* 32-bit version. */ |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
|
do_sections (abfd, coreout) |
|
|
|
|
|
bfd * abfd; |
|
|
|
|
|
struct coreout *coreout; |
|
|
|
|
|
{ |
|
|
|
|
|
struct vmap vmap; |
|
|
|
|
|
char *secname; |
|
|
|
|
|
int i, val; |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < coreout->c_nvmap; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
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)) |
|
|
|
|
|
/* Fail. */ |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static asection * |
|
|
static asection * |
|
|
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) |
|
|
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) |
|
|
@ -79,8 +183,6 @@ irix_core_core_file_p (abfd) |
|
|
bfd *abfd; |
|
|
bfd *abfd; |
|
|
{ |
|
|
{ |
|
|
int val; |
|
|
int val; |
|
|
int i; |
|
|
|
|
|
char *secname; |
|
|
|
|
|
struct coreout coreout; |
|
|
struct coreout coreout; |
|
|
struct idesc *idg, *idf, *ids; |
|
|
struct idesc *idg, *idf, *ids; |
|
|
bfd_size_type amt; |
|
|
bfd_size_type amt; |
|
|
@ -93,13 +195,22 @@ irix_core_core_file_p (abfd) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#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) |
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
/* Have we got a corefile? */ |
|
|
|
|
|
switch (coreout.c_magic) |
|
|
|
|
|
{ |
|
|
|
|
|
case CORE_MAGIC: break; |
|
|
|
|
|
#ifdef CORE_MAGIC64 |
|
|
|
|
|
case CORE_MAGIC64: break; |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifdef CORE_MAGICN32 |
|
|
|
|
|
case CORE_MAGICN32: break; |
|
|
|
|
|
#endif |
|
|
|
|
|
default: return 0; /* Un-identifiable or not corefile. */ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
amt = sizeof (struct sgi_core_struct); |
|
|
amt = sizeof (struct sgi_core_struct); |
|
|
core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt); |
|
|
core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt); |
|
|
if (!core_hdr (abfd)) |
|
|
if (!core_hdr (abfd)) |
|
|
@ -111,45 +222,19 @@ irix_core_core_file_p (abfd) |
|
|
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0) |
|
|
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0) |
|
|
goto fail; |
|
|
goto fail; |
|
|
|
|
|
|
|
|
for (i = 0; i < coreout.c_nvmap; i++) |
|
|
/* Process corefile sections. */ |
|
|
|
|
|
#ifdef CORE_MAGIC64 |
|
|
|
|
|
if (coreout.c_magic == (int) CORE_MAGIC64) |
|
|
{ |
|
|
{ |
|
|
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)) |
|
|
|
|
|
goto fail; |
|
|
goto fail; |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
#endif |
|
|
|
|
|
if (! do_sections (abfd, & coreout)) |
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
/* Make sure that the regs are contiguous within the core file. */ |
|
|
/* Make sure that the regs are contiguous within the core file. */ |
|
|
|
|
|
|
|
|
idg = &coreout.c_idesc[I_GPREGS]; |
|
|
idg = &coreout.c_idesc[I_GPREGS]; |
|
|
idf = &coreout.c_idesc[I_FPREGS]; |
|
|
idf = &coreout.c_idesc[I_FPREGS]; |
|
|
|