From 14c1e154d62b5c900d725af70e034f24a0a577dd Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 10 Sep 2002 10:39:03 +0000 Subject: [PATCH] Call new functions do_sections, do_sections64, depending on corefile (32-bit or 64-bit). --- bfd/ChangeLog | 6 ++ bfd/irix-core.c | 193 ++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 145 insertions(+), 54 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 66cce3515..73bc6904d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2002-09-10 Michael Snyder + + * 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 * elfxx-ia64.c (elfNN_ia64_relax_section): Handle PCREL21M diff --git a/bfd/irix-core.c b/bfd/irix-core.c index 0e48a9aa6..b1a575b03 100644 --- a/bfd/irix-core.c +++ b/bfd/irix-core.c @@ -4,21 +4,21 @@ Written by Stu Grossman, 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 -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + 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 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 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,45 +222,19 @@ 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. */ + /* Make sure that the regs are contiguous within the core file. */ idg = &coreout.c_idesc[I_GPREGS]; idf = &coreout.c_idesc[I_FPREGS]; -- 2.11.4.GIT