Call new functions do_sections, do_sections64, depending on corefile (32-bit

or 64-bit).
This commit is contained in:
Nick Clifton
2002-09-10 10:39:03 +00:00
parent 873e05886e
commit b3018b5f70
2 changed files with 145 additions and 54 deletions

View File

@ -1,3 +1,9 @@
2002-09-10 Michael Snyder <msnyder@redhat.com>
* irix-core.c (do_sections, do_sections64): New functions.
(irix_core_core_file_p): Call new functions do_sections,
do_sections64, depending on corefile (32-bit or 64-bit).
2002-09-09 Richard Henderson <rth@redhat.com>
* elfxx-ia64.c (elfNN_ia64_relax_section): Handle PCREL21M

View File

@ -49,6 +49,110 @@ static int irix_core_core_file_failing_signal PARAMS ((bfd *));
static boolean irix_core_core_file_matches_executable_p
PARAMS ((bfd *, bfd *));
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 *
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
@ -79,8 +183,6 @@ irix_core_core_file_p (abfd)
bfd *abfd;
{
int val;
int i;
char *secname;
struct coreout coreout;
struct idesc *idg, *idf, *ids;
bfd_size_type amt;
@ -93,13 +195,22 @@ irix_core_core_file_p (abfd)
return 0;
}
#ifndef CORE_MAGICN32
#define CORE_MAGICN32 CORE_MAGIC
#endif
if ((coreout.c_magic != CORE_MAGIC && coreout.c_magic != CORE_MAGICN32)
|| coreout.c_version != CORE_VERSION1)
if (coreout.c_version != CORE_VERSION1)
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);
core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt);
if (!core_hdr (abfd))
@ -111,43 +222,17 @@ irix_core_core_file_p (abfd)
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
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;
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))
if (! do_sections64 (abfd, & coreout))
goto fail;
}
else
#endif
if (! do_sections (abfd, & coreout))
goto fail;
/* Make sure that the regs are contiguous within the core file. */