This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[mea@nada.kth.se: AIX 4.3.2 new library and coredump format]


Here is a set of BFD patches that are a start on supporting AIX 4.3 in
GDB.  Could someone please evaluate these and install if they're OK?
The theory seems plausible, although upon reading these I realize that
my BFD-remembering neurons must be dying off...

								Stan

------- Start of forwarded message -------
To: gdb-patches@cygnus.com
Subject: AIX 4.3.2 new library and coredump format
From: Johanna Svenningsson <mea@nada.kth.se>
Date: 27 Mar 1999 06:14:58 +0200
Lines: 1781
X-Mailer: Gnus v5.6.43/Emacs 19.34
Sender: owner-gdb-patches@cygnus.com
Precedence: bulk
Reply-To: gdb-patches@cygnus.com
Content-Type: text
Content-Length: 48580


In AIX 4.3 the format of libraries and coredumps has been changed.
I've tried to adapt gdb to both the new and old style. It might not be
very beautiful, but it seems to be working for me at least. I've
tested it on AIX 4.3.2 and 4.2.1.

In order to compile this with xlc I needed the previous patches and a
couple of workarounds that I have reported today to gdb-bugs.

Regards,
/Johanna

1999-03-27	Johanna Svenningsson	<mea@pdc.kth.se>

	Attempted to make gdb understand the new format of AIX
	coredumps and libraries.
	* rs6000-core.c:	added code for new coredumpformat
	* coff-rs6000.c:	handles new library format
	* configure.in:		checks for core_dumpx-struct


*** gdb-4.17.87/bfd/rs6000-core.c	Mon Oct  5 05:37:54 1998
- --- gdb-4.17.86-AIX/bfd/rs6000-core.c	Sat Mar 27 03:54:47 1999
***************
*** 78,84 ****
  
  #define	NUM_OF_SPEC_REGS  7
  
! #define	core_hdr(bfd)		(((Rs6kCorData*)(bfd->tdata.any))->hdr)
  
  /* AIX 4.1 Changed the names and locations of a few items in the core file,
     this seems to be the quickest easiet way to deal with it. 
- --- 78,87 ----
  
  #define	NUM_OF_SPEC_REGS  7
  
! #define	core_hdrs(bfd)		(((Rs6kCorData*)(bfd->tdata.any))->U_hdr.hdr)
! #ifdef HAVE_CORE_DUMPX
! #define	core_hdrx(bfd)		(((Rs6kCorData*)(bfd->tdata.any))->U_hdr.hdrx)
! #endif
  
  /* AIX 4.1 Changed the names and locations of a few items in the core file,
     this seems to be the quickest easiet way to deal with it. 
***************
*** 85,95 ****
  
     Note however that encoding magic addresses (STACK_END_ADDR) is going
     to be _very_ fragile.  But I don't see any easy way to get that info
!    right now.  */
  #ifdef CORE_VERSION_1
  #define CORE_DATA_SIZE_FIELD c_u.U_dsize
  #define CORE_COMM_FIELD c_u.U_comm
  #define SAVE_FIELD c_mst
  #define	STACK_END_ADDR 0x2ff23000
  #else
  #define CORE_DATA_SIZE_FIELD c_u.u_dsize
- --- 88,105 ----
  
     Note however that encoding magic addresses (STACK_END_ADDR) is going
     to be _very_ fragile.  But I don't see any easy way to get that info
!    right now.  
! 
!    STACK_END_ADDR is no longer needed in the 64 bit coredump format.
! */
  #ifdef CORE_VERSION_1
  #define CORE_DATA_SIZE_FIELD c_u.U_dsize
  #define CORE_COMM_FIELD c_u.U_comm
  #define SAVE_FIELD c_mst
+ #ifdef HAVE_CORE_DUMPX
+ #define CORE_COMM64_FIELD c_u.U_proc.pi_comm
+ #define SAVE_FIELDX c_flt.hctx.r32
+ #endif
  #define	STACK_END_ADDR 0x2ff23000
  #else
  #define CORE_DATA_SIZE_FIELD c_u.u_dsize
***************
*** 100,106 ****
  
  /* These are stored in the bfd's tdata */
  typedef struct {
!   struct core_dump hdr;		/* core file header */
  } Rs6kCorData;
  
  static asection *make_bfd_asection PARAMS ((bfd *, CONST char *, flagword,
- --- 110,121 ----
  
  /* These are stored in the bfd's tdata */
  typedef struct {
!      union {
! 	  struct core_dump hdr;		/* core file header */
! #ifdef HAVE_CORE_DUMPX	 
! 	  struct core_dumpx hdrx;
! #endif
!      } U_hdr;
  } Rs6kCorData;
  
  static asection *make_bfd_asection PARAMS ((bfd *, CONST char *, flagword,
***************
*** 138,146 ****
- --- 153,165 ----
       bfd *abfd;
  {
    struct core_dump coredata;
+ #ifdef HAVE_CORE_DUMPX
+   struct core_dumpx coredata64;
+ #endif
    struct stat statbuf;
    bfd_size_type nread;
    char *tmpptr;
+   boolean is_big=false;
  
    if (bfd_seek (abfd, 0, SEEK_SET) != 0)
      return NULL;
***************
*** 147,158 ****
  
    nread = bfd_read (&coredata, 1, sizeof (struct core_dump), abfd);
    if (nread != sizeof (struct core_dump))
!     {
!       if (bfd_get_error () != bfd_error_system_call)
! 	bfd_set_error (bfd_error_wrong_format);
!       return NULL;
      }
  
    if (bfd_stat (abfd, &statbuf) < 0)
      {
        bfd_set_error (bfd_error_system_call);
- --- 166,197 ----
  
    nread = bfd_read (&coredata, 1, sizeof (struct core_dump), abfd);
    if (nread != sizeof (struct core_dump))
!   {
! #ifdef HAVE_CORE_DUMPX
!        if(coredata.c_entries == 0)
!        {
! 	    is_big=true;
! 	    if (bfd_seek (abfd, 0, SEEK_SET) != 0)
! 		 return NULL;
! 	    
! 	    nread = bfd_read (&coredata64, 1, 
! 			      sizeof (struct core_dumpx), abfd);
! 	    if (nread != sizeof (struct core_dumpx))
! 	    {
! 		 if (bfd_get_error () != bfd_error_system_call)
! 		      bfd_set_error (bfd_error_wrong_format);
! 	    }  
! 	      
!        }else
! #endif
!        {
! 	    if (bfd_get_error () != bfd_error_system_call)
! 		 bfd_set_error (bfd_error_wrong_format);
! 	    return NULL;
!        }
      }
  
+ 
    if (bfd_stat (abfd, &statbuf) < 0)
      {
        bfd_set_error (bfd_error_system_call);
***************
*** 174,215 ****
       file.  The usefulness of a core dump without a stack segment is pretty
       limited anyway.  */
       
!   if (!(coredata.c_flag & UBLOCK_VALID)
!       || !(coredata.c_flag & LE_VALID))
!     {
!       bfd_set_error (bfd_error_wrong_format);
!       return NULL;
!     }
! 
!   if (!(coredata.c_flag & USTACK_VALID))
!     {
!       bfd_set_error (bfd_error_file_truncated);
!       return NULL;
!     }
! 
    /* Don't check the core file size for a full core, AIX 4.1 includes
       additional shared library sections in a full core.  */
!   if (!(coredata.c_flag & (FULL_CORE | CORE_TRUNC))
!       && ((bfd_vma)coredata.c_stack + coredata.c_size) != statbuf.st_size)
!     {
!       /* If the size is wrong, it means we're misinterpreting something.  */
!       bfd_set_error (bfd_error_wrong_format);
!       return NULL;
!     }
  
    /* Sanity check on the c_tab field.  */
!   if ((u_long) coredata.c_tab < sizeof coredata ||
!       (u_long) coredata.c_tab >= statbuf.st_size ||
!       (long) coredata.c_tab >= (long)coredata.c_stack)
!     {
!       bfd_set_error (bfd_error_wrong_format);
!       return NULL;
!     }
  
    /* Issue warning if the core file was truncated during writing.  */
!   if (coredata.c_flag & CORE_TRUNC)
!     (*_bfd_error_handler) (_("%s: warning core file truncated"),
! 			   bfd_get_filename (abfd));
  
    /* Allocate core file header.  */
    tmpptr = (char*) bfd_zalloc (abfd, sizeof (Rs6kCorData));
- --- 213,320 ----
       file.  The usefulness of a core dump without a stack segment is pretty
       limited anyway.  */
       
!   if(!is_big)
!   {
!        if (!(coredata.c_flag & UBLOCK_VALID)
! 	   || !(coredata.c_flag & LE_VALID))
!        {
! 	    bfd_set_error (bfd_error_wrong_format);
! 	    return NULL;
!        }
!        
!        if (!(coredata.c_flag & USTACK_VALID))
!        {
! 	    bfd_set_error (bfd_error_file_truncated);
! 	    return NULL;
!        }
!   }
! #ifdef HAVE_CORE_DUMPX
!   else
!   {
!        if (!(coredata64.c_flag & UBLOCK_VALID)
! 	   || !(coredata64.c_flag & LE_VALID))
!        {
! 	    bfd_set_error (bfd_error_wrong_format);
! 	    return NULL;
!        }
!        
!        if (!(coredata64.c_flag & USTACK_VALID))
!        {
! 	    bfd_set_error (bfd_error_file_truncated);
! 	    return NULL;
!        }
!   }
! #endif
    /* Don't check the core file size for a full core, AIX 4.1 includes
       additional shared library sections in a full core.  */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if (!(coredata64.c_flag & (FULL_CORE | CORE_TRUNC))
! 	   && ((bfd_vma)coredata64.c_stack + coredata64.c_size) 
! 	   != statbuf.st_size)
!        {
! 	    /* If the size is wrong, 
! 	       it means we're misinterpreting something.  */
! 	    bfd_set_error (bfd_error_wrong_format);
! 	    return NULL;
!        }
!   }
!   else
! #endif
!   {
!        if (!(coredata.c_flag & (FULL_CORE | CORE_TRUNC))
! 	   && ((bfd_vma)coredata.c_stack + coredata.c_size) 
! 	   != statbuf.st_size)
!        {
! 	    /* If the size is wrong, 
! 	       it means we're misinterpreting something.  */
! 	    bfd_set_error (bfd_error_wrong_format);
! 	    return NULL;
!        }
!   }
  
+ 
+ 
    /* Sanity check on the c_tab field.  */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if ((u_long) coredata64.c_loader < sizeof coredata64 ||
! 	   (u_long) coredata64.c_loader >= statbuf.st_size ||
! 	   (long) coredata64.c_loader >= (long)coredata64.c_stack)
!        {
! 	    bfd_set_error (bfd_error_wrong_format);
! 	    return NULL;
!        }
  
+   }
+   else
+ #endif
+   {
+        if ((u_long) coredata.c_tab < sizeof coredata ||
+ 	   (u_long) coredata.c_tab >= statbuf.st_size ||
+ 	   (long) coredata.c_tab >= (long)coredata.c_stack)
+        {
+ 	    bfd_set_error (bfd_error_wrong_format);
+ 	    return NULL;
+        }
+   }
    /* Issue warning if the core file was truncated during writing.  */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if (coredata64.c_flag & CORE_TRUNC)
! 	    (*_bfd_error_handler) (_("%s: warning core file truncated"),
! 				   bfd_get_filename (abfd));
!   }
!   else
! #endif
!   {
!        if (coredata.c_flag & CORE_TRUNC)
! 	    (*_bfd_error_handler) (_("%s: warning core file truncated"),
! 				   bfd_get_filename (abfd));
!   }
  
    /* Allocate core file header.  */
    tmpptr = (char*) bfd_zalloc (abfd, sizeof (Rs6kCorData));
***************
*** 219,263 ****
    set_tdata (abfd, tmpptr);
  
    /* Copy core file header.  */
!   core_hdr (abfd) = coredata;
  
    /* .stack section. */
!   if (!make_bfd_asection (abfd, ".stack",
!   			  SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 			  (bfd_size_type) coredata.c_size,
! 			  (bfd_vma) (STACK_END_ADDR - coredata.c_size),
! 			  (file_ptr) coredata.c_stack))
!     return NULL;
  
    /* .reg section for GPRs and special registers. */
!   if (!make_bfd_asection (abfd, ".reg",
!   			  SEC_HAS_CONTENTS,
! 			  (bfd_size_type) ((32 + NUM_OF_SPEC_REGS) * 4),
! 			  (bfd_vma) 0,
! 			  (file_ptr) ((char *) &coredata.SAVE_FIELD
! 				      - (char *) &coredata)))
!     return NULL;
  
    /* .reg2 section for FPRs (floating point registers). */
!   if (!make_bfd_asection (abfd, ".reg2",
!   			  SEC_HAS_CONTENTS,
! 			  (bfd_size_type) 8 * 32,	/* 32 FPRs. */
! 			  (bfd_vma) 0,
! 			  (file_ptr) ((char *) &coredata.SAVE_FIELD.fpr[0]
! 				      - (char *) &coredata)))
!     return NULL;
  
    /* .ldinfo section.
       To actually find out how long this section is in this particular
       core dump would require going down the whole list of struct ld_info's.
       See if we can just fake it.  */
!   if (!make_bfd_asection (abfd, ".ldinfo",
!   			  SEC_HAS_CONTENTS,
! 			  (bfd_size_type) 0x7fffffff,
! 			  (bfd_vma) 0,
! 			  (file_ptr) coredata.c_tab))
!     return NULL;
! 
  #ifndef CORE_VERSION_1
    /* .data section if present.
       AIX 3 dumps the complete data section and sets FULL_CORE if the
- --- 324,434 ----
    set_tdata (abfd, tmpptr);
  
    /* Copy core file header.  */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!        core_hdrx (abfd) = coredata64;
!   else
! #endif
!        core_hdrs (abfd) = coredata;
  
+ 
    /* .stack section. */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if (!make_bfd_asection (abfd, ".stack",
! 			       SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 			       (bfd_size_type) coredata64.c_size,
! 			       (bfd_vma) (coredata64.c_stackorg),
! 			       (file_ptr) coredata64.c_stack))
! 	    return NULL;
!   }
!   else
! #endif
!   {
!        if (!make_bfd_asection (abfd, ".stack",
! 			       SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 			       (bfd_size_type) coredata.c_size,
! 			       (bfd_vma) (STACK_END_ADDR - coredata.c_size),
! 			       (file_ptr) coredata.c_stack))
! 	    return NULL;
!   }
  
+ 
    /* .reg section for GPRs and special registers. */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if (!make_bfd_asection (abfd, ".reg",
! 			       SEC_HAS_CONTENTS,
! 			       (bfd_size_type) ((32 + NUM_OF_SPEC_REGS) * 4),
! 			       (bfd_vma) 0,
! 			       (file_ptr) ((char *) &coredata64.SAVE_FIELDX
! 					   - (char *) &coredata64)))
! 	    return NULL;
!   }
!   else
! #endif
!   {
!        if (!make_bfd_asection (abfd, ".reg",
! 			       SEC_HAS_CONTENTS,
! 			       (bfd_size_type) ((32 + NUM_OF_SPEC_REGS) * 4),
! 			       (bfd_vma) 0,
! 			       (file_ptr) ((char *) &coredata.SAVE_FIELD
! 					   - (char *) &coredata)))
! 	    return NULL;
!   }
  
    /* .reg2 section for FPRs (floating point registers). */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if (!make_bfd_asection (abfd, ".reg2",
! 			       SEC_HAS_CONTENTS,
! 			       (bfd_size_type) 8 * 32,	/* 32 FPRs. */
! 			       (bfd_vma) 0,
! 			       (file_ptr) ((char *) &coredata64.SAVE_FIELDX.fpr[0]
! 					   - (char *) &coredata64)))
! 	    return NULL;
!   }else
! #endif    
!   {
  
+        if (!make_bfd_asection (abfd, ".reg2",
+ 			       SEC_HAS_CONTENTS,
+ 			       (bfd_size_type) 8 * 32,	/* 32 FPRs. */
+ 			       (bfd_vma) 0,
+ 			       (file_ptr) ((char *) &coredata.SAVE_FIELD.fpr[0]
+ 					   - (char *) &coredata)))
+ 	    return NULL;
+   }
+ 
+ 
    /* .ldinfo section.
       To actually find out how long this section is in this particular
       core dump would require going down the whole list of struct ld_info's.
       See if we can just fake it.  */
! #ifdef HAVE_CORE_DUMPX
!   if(is_big)
!   {
!        if (!make_bfd_asection (abfd, ".ldinfo",
! 			       SEC_HAS_CONTENTS,
! 			       coredata64.c_lsize,
! 			       (bfd_vma) 0,
! 			       (file_ptr) coredata64.c_loader))
! 	    return NULL;
!   }
!   else
! #endif
!   {
!        if (!make_bfd_asection (abfd, ".ldinfo",
! 			       SEC_HAS_CONTENTS,
! 			       (bfd_size_type) 0x7fffffff,
! 			       (bfd_vma) 0,
! 			       (file_ptr) coredata.c_tab))
! 	    return NULL;
!   }
!   
  #ifndef CORE_VERSION_1
    /* .data section if present.
       AIX 3 dumps the complete data section and sets FULL_CORE if the
***************
*** 281,351 ****
    /* AIX 4 adds data sections from loaded objects to the core file,
       which can be found by examining ldinfo, and anonymously mmapped
       regions.  */
    {
      struct ld_info ldinfo;
      bfd_size_type ldinfo_size;
!     file_ptr ldinfo_offset = (file_ptr) coredata.c_tab;
  
      /* .data section from executable.  */
!     if (coredata.c_datasize)
!       {
! 	if (!make_bfd_asection (abfd, ".data",
! 				SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 				(bfd_size_type) coredata.c_datasize,
! 				(bfd_vma)
! 				  CDATA_ADDR (coredata.CORE_DATA_SIZE_FIELD),
! 				(file_ptr) coredata.c_data))
! 	  return NULL;
!       }
  
      /* .data sections from loaded objects.  */
      ldinfo_size = (char *) &ldinfo.ldinfo_filename[0]
! 		  - (char *) &ldinfo.ldinfo_next;
      while (1)
!       {
! 	if (bfd_seek (abfd, ldinfo_offset, SEEK_SET) != 0)
! 	  return NULL;
! 	if (bfd_read (&ldinfo, ldinfo_size, 1, abfd) != ldinfo_size)
! 	  return NULL;
! 	if (ldinfo.ldinfo_core)
! 	  {
! 	    if (!make_bfd_asection (abfd, ".data",
! 				    SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 				    (bfd_size_type) ldinfo.ldinfo_datasize,
! 				    (bfd_vma) ldinfo.ldinfo_dataorg,
! 				    (file_ptr) ldinfo.ldinfo_core))
  	      return NULL;
! 	  }
! 	if (ldinfo.ldinfo_next == 0)
! 	  break;
! 	ldinfo_offset += ldinfo.ldinfo_next;
!       }
  
!     /* .vmdata sections from anonymously mmapped regions.  */
!     if (coredata.c_vmregions)
!       {
! 	int i;
  
! 	if (bfd_seek (abfd, (file_ptr) coredata.c_vmm, SEEK_SET) != 0)
! 	  return NULL;
  
! 	for (i = 0; i < coredata.c_vmregions; i++)
! 	  {
! 	    struct vm_info vminfo;
  
! 	    if (bfd_read (&vminfo, sizeof (vminfo), 1, abfd) != sizeof (vminfo))
! 	      return NULL;
! 	    if (vminfo.vminfo_offset)
  	      {
! 		if (!make_bfd_asection (abfd, ".vmdata",
! 					SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 					(bfd_size_type) vminfo.vminfo_size,
! 					(bfd_vma) vminfo.vminfo_addr,
! 					(file_ptr) vminfo.vminfo_offset))
! 		  return NULL;
  	      }
! 	  }
!       }
    }
  #endif
  
- --- 452,598 ----
    /* AIX 4 adds data sections from loaded objects to the core file,
       which can be found by examining ldinfo, and anonymously mmapped
       regions.  */
+ 
    {
      struct ld_info ldinfo;
      bfd_size_type ldinfo_size;
!     file_ptr ldinfo_offset;
  
+ #ifdef HAVE_CORE_DUMPX
+     if(is_big)
+ 	 ldinfo_offset=(file_ptr) coredata64.c_loader;
+     else
+ #endif
+ 	 ldinfo_offset=(file_ptr) coredata.c_tab;
+ 
      /* .data section from executable.  */
! #ifdef HAVE_CORE_DUMPX
!     if(is_big)
!     {
! 	 if (coredata64.c_datasize)
! 	 {
! 	      if (!make_bfd_asection (abfd, ".data",
! 				      SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 				      (bfd_size_type) coredata64.c_datasize,
! 				      (bfd_vma)
! 				      CDATA_ADDR (coredata64.CORE_DATA_SIZE_FIELD),
! 				      (file_ptr) coredata64.c_data))
! 	      {
! 		   return NULL;
! 	      }
! 	 }
!     }
!     else
! #endif
!     {
! 	 if (coredata.c_datasize)
! 	 {
! 	      if (!make_bfd_asection (abfd, ".data",
! 				      SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 				      (bfd_size_type) coredata.c_datasize,
! 				      (bfd_vma)
! 				      CDATA_ADDR (coredata.CORE_DATA_SIZE_FIELD),
! 				      (file_ptr) coredata.c_data))
! 	      {
  
+ 		   return NULL;
+ 	      }
+ 	 }
+     }
      /* .data sections from loaded objects.  */
      ldinfo_size = (char *) &ldinfo.ldinfo_filename[0]
! 	 - (char *) &ldinfo.ldinfo_next;
      while (1)
!     {
! 	 if (bfd_seek (abfd, ldinfo_offset, SEEK_SET) != 0)
! 	 {
! 	      
  	      return NULL;
! 	 }
! 	 if (bfd_read (&ldinfo, ldinfo_size, 1, abfd) != ldinfo_size)
! 	 {
  
! 	      return NULL;
! 	 }
  
! 	 if (ldinfo.ldinfo_core)
! 	 {
! 	      if (!make_bfd_asection (abfd, ".data",
! 				      SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 				      (bfd_size_type) ldinfo.ldinfo_datasize,
! 				      (bfd_vma) ldinfo.ldinfo_dataorg,
! 				      (file_ptr) ldinfo.ldinfo_core))
! 	      {
! 		 
! 		   return NULL;
! 	      }
  
! 	 }
! 	 if (ldinfo.ldinfo_next == 0)
! 	      break;
! 	 ldinfo_offset += ldinfo.ldinfo_next;
!     }
  
!     /* .vmdata sections from anonymously mmapped regions.  */
! #ifdef HAVE_CORE_DUMPX
!     if(is_big)
!     {
! 	 if (coredata64.c_vmregions)
! 	 {
! 	      int i;
! 	 
! 	      if (bfd_seek (abfd, (file_ptr) coredata64.c_vmm, SEEK_SET) != 0)
  	      {
! 		   return NULL;
  	      }
! 	      for (i = 0; i < coredata64.c_vmregions; i++)
! 	      {
! 		   struct vm_info vminfo;
! 	      
! 		   if (bfd_read (&vminfo, sizeof (vminfo), 1, abfd) != sizeof (vminfo))
! 			return NULL;
! 		   if (vminfo.vminfo_offset)
! 		   {
! 			if (!make_bfd_asection (abfd, ".vmdata",
! 						SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 						(bfd_size_type) vminfo.vminfo_size,
! 						(bfd_vma) vminfo.vminfo_addr,
! 						(file_ptr) vminfo.vminfo_offset))
! 			{
! 			     return NULL;
! 			}
! 		   }
! 	      }
! 	 }
!     }
!     else
! #endif
!     {
! 	 if (coredata.c_vmregions)
! 	 {
! 	      int i;
! 	      
! 	      if (bfd_seek (abfd, (file_ptr) coredata.c_vmm, SEEK_SET) != 0)
! 		   return NULL;
! 	 
! 	      for (i = 0; i < coredata.c_vmregions; i++)
! 	      {
! 		   struct vm_info vminfo;
! 	      
! 		   if (bfd_read (&vminfo, sizeof (vminfo), 1, abfd) != sizeof (vminfo))
! 			return NULL;
! 		   if (vminfo.vminfo_offset)
! 		   {
! 			if (!make_bfd_asection (abfd, ".vmdata",
! 						SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
! 						(bfd_size_type) vminfo.vminfo_size,
! 						(bfd_vma) vminfo.vminfo_addr,
! 						(file_ptr) vminfo.vminfo_offset))
! 			     return NULL;
! 		   }
! 	      }
! 	 }
!     }
    }
  #endif
  
***************
*** 353,359 ****
- --- 600,620 ----
  }
  
  
+ /* c_entries is always 0 in the new, 64 bit, coredump
+ format, see "man core_43"... */
  
+ static boolean
+ is_big_core(abfd)
+      bfd *abfd;
+ {
+      if((core_hdrs (abfd).c_entries) ==0)
+ 	  return true;
+      else
+ 	  return false;
+ }
+ 
+ 
+ 
  /* return `true' if given core is from the given executable.. */
  boolean
  rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd)
***************
*** 360,366 ****
       bfd *core_bfd;
       bfd *exec_bfd;
  {
!   struct core_dump coredata;
    struct ld_info ldinfo;
    bfd_size_type size;
    char *path, *s;
- --- 621,630 ----
       bfd *core_bfd;
       bfd *exec_bfd;
  {
!   struct core_dump coredata32;
! #ifdef HAVE_CORE_DUMPX
!   struct core_dumpx coredata64;
! #endif
    struct ld_info ldinfo;
    bfd_size_type size;
    char *path, *s;
***************
*** 367,380 ****
    size_t alloc;
    const char *str1, *str2;
    boolean ret;
  
!   if (bfd_seek (core_bfd, 0, SEEK_SET) != 0
!       || bfd_read (&coredata, sizeof coredata, 1, core_bfd) != sizeof coredata)
!     return false;
  
!   if (bfd_seek (core_bfd, (long) coredata.c_tab, SEEK_SET) != 0)
!     return false;
  
    size = (char *) &ldinfo.ldinfo_filename[0] - (char *) &ldinfo.ldinfo_next;
    if (bfd_read (&ldinfo, size, 1, core_bfd) != size)
      return false;
- --- 631,662 ----
    size_t alloc;
    const char *str1, *str2;
    boolean ret;
+   boolean is_big=false;
  
! #ifdef HAVE_CORE_DUMPX 
!   is_big=is_big_core(core_bfd);
  
!   if(is_big)
!   {
!        if (bfd_seek (core_bfd, 0, SEEK_SET) != 0
! 	   || bfd_read (&coredata64, sizeof coredata64, 1, core_bfd) != sizeof coredata64)
! 	    return false;
!        if (bfd_seek (core_bfd, (long) coredata64.c_loader, SEEK_SET) != 0)
! 	    return false;
  
+   }
+   else
+ #endif
+   {
+        if (bfd_seek (core_bfd, 0, SEEK_SET) != 0
+ 	   || bfd_read (&coredata32, sizeof coredata32, 1, core_bfd) != sizeof coredata32)
+ 	    return false;
+        if (bfd_seek (core_bfd, (long) coredata32.c_tab, SEEK_SET) != 0)
+ 	    return false;
+ 
+ 
+   }
+ 
    size = (char *) &ldinfo.ldinfo_filename[0] - (char *) &ldinfo.ldinfo_next;
    if (bfd_read (&ldinfo, size, 1, core_bfd) != size)
      return false;
***************
*** 432,438 ****
  rs6000coff_core_file_failing_command (abfd)
       bfd *abfd;
  {
!   char *com = core_hdr (abfd).CORE_COMM_FIELD;
    if (*com)
      return com;
    else
- --- 714,728 ----
  rs6000coff_core_file_failing_command (abfd)
       bfd *abfd;
  {
!      char *com;
! 
! #ifdef HAVE_CORE_DUMPX
!      if(is_big_core(abfd))
! 	  com = core_hdrx (abfd).CORE_COMM64_FIELD;
!      else
! #endif
! 	  com = core_hdrs (abfd).CORE_COMM_FIELD;
! 
    if (*com)
      return com;
    else
***************
*** 443,449 ****
  rs6000coff_core_file_failing_signal (abfd)
       bfd *abfd;
  {
!   return core_hdr (abfd).c_signo;
  }
  
  
- --- 733,744 ----
  rs6000coff_core_file_failing_signal (abfd)
       bfd *abfd;
  {
! #ifdef HAVE_CORE_DUMPX
!      if(is_big_core(abfd))
! 	  return core_hdrx (abfd).c_signo;
!      else
! #endif
! 	  return core_hdrs (abfd).c_signo;
  }
  
  
***************
*** 505,507 ****
- --- 800,807 ----
  }
  
  #endif /* AIX_CORE */
+ 
+ 
+ 
+ 
+ 
*** gdb-4.17.87/bfd/coff-rs6000.c	Tue Jun 30 12:02:19 1998
- --- gdb-4.17.86-AIX/bfd/coff-rs6000.c	Sat Mar 27 03:45:02 1999
***************
*** 594,600 ****
  
  /* XCOFF archives use this as a magic string.  */
  
! #define XCOFFARMAG "<aiaff>\012"
  #define SXCOFFARMAG 8
  
  /* This terminates an XCOFF archive member name.  */
- --- 594,601 ----
  
  /* XCOFF archives use this as a magic string.  */
  
! #define XCOFFBIGARMAG "<bigaf>\012"
! #define XCOFFSMALLARMAG "<aiaff>\012"
  #define SXCOFFARMAG 8
  
  /* This terminates an XCOFF archive member name.  */
***************
*** 604,610 ****
  
  /* XCOFF archives start with this (printable) structure.  */
  
! struct xcoff_ar_file_hdr
  {
    /* Magic string.  */
    char magic[SXCOFFARMAG];
- --- 605,611 ----
  
  /* XCOFF archives start with this (printable) structure.  */
  
! struct xcoff_ar_small_file_hdr
  {
    /* Magic string.  */
    char magic[SXCOFFARMAG];
***************
*** 626,636 ****
    char freeoff[12];
  };
  
! #define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG)
  
  /* Each XCOFF archive member starts with this (printable) structure.  */
  
! struct xcoff_ar_hdr
  {
    /* File size not including the header (decimal ASCII string).  */
    char size[12];
- --- 627,664 ----
    char freeoff[12];
  };
  
! #define SIZEOF_AR_SMALL_FILE_HDR (5 * 12 + SXCOFFARMAG)
  
+ struct xcoff_ar_big_file_hdr
+ {
+   /* Magic string.  */
+   char magic[SXCOFFARMAG];
+ 
+   /* Offset of the member table (decimal ASCII string).  */
+   char memoff[20];
+ 
+   /* Offset of the global symbol table (decimal ASCII string).  */
+   char symoff[20];
+ 
+   /* Offset of the 64 global symbol table (decimal ASCII string).  */
+   char sym64off[20];
+ 
+   /* Offset of the first member in the archive (decimal ASCII string).  */
+   char firstmemoff[20];
+ 
+   /* Offset of the last member in the archive (decimal ASCII string).  */
+   char lastmemoff[20];
+ 
+   /* Offset of the first member on the free list (decimal ASCII
+      string).  */
+   char freeoff[20];
+ };
+ 
+ #define SIZEOF_AR_BIG_FILE_HDR (6 * 20 + SXCOFFARMAG)
+ 
  /* Each XCOFF archive member starts with this (printable) structure.  */
  
! struct xcoff_ar_small_hdr
  {
    /* File size not including the header (decimal ASCII string).  */
    char size[12];
***************
*** 664,681 ****
       bytes is given in the size field.  */
  };
  
! #define SIZEOF_AR_HDR (7 * 12 + 4)
  
  /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
     artdata structure.  */
! #define xcoff_ardata(abfd) \
!   ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
  
  /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
     archive element.  */
  #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
  #define arch_xhdr(bfd) \
!   ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
  
  /* XCOFF archives do not have anything which corresponds to an
     extended name table.  */
- --- 692,750 ----
       bytes is given in the size field.  */
  };
  
! #define SIZEOF_AR_SMALL_HDR (7 * 12 + 4)
  
+ /* Each XCOFF archive member starts with this (printable) structure.  */
+ 
+ struct xcoff_ar_big_hdr
+ {
+   /* File size not including the header (decimal ASCII string).  */
+   char size[20];
+ 
+   /* File offset of next archive member (decimal ASCII string).  */
+   char nextoff[20];
+ 
+   /* File offset of previous archive member (decimal ASCII string).  */
+   char prevoff[20];
+ 
+   /* File mtime (decimal ASCII string).  */
+   char date[12];
+ 
+   /* File UID (decimal ASCII string).  */
+   char uid[12];
+ 
+   /* File GID (decimal ASCII string).  */
+   char gid[12];
+ 
+   /* File mode (octal ASCII string).  */
+   char mode[12];
+ 
+   /* Length of file name (decimal ASCII string).  */
+   char namlen[4];
+ 
+   /* This structure is followed by the file name.  The length of the
+      name is given in the namlen field.  If the length of the name is
+      odd, the name is followed by a null byte.  The name and optional
+      null byte are followed by XCOFFARFMAG, which is not included in
+      namlen.  The contents of the archive member follow; the number of
+      bytes is given in the size field.  */
+ };
+ 
+ #define SIZEOF_AR_BIG_HDR (3*20 + 4 * 12 + 4)
+ 
  /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
     artdata structure.  */
! #define xcoff_big_ardata(abfd) \
!   ((struct xcoff_ar_big_file_hdr *) bfd_ardata (abfd)->tdata)
  
+ #define xcoff_small_ardata(abfd) \
+   ((struct xcoff_ar_small_file_hdr *) bfd_ardata (abfd)->tdata)
+ 
  /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
     archive element.  */
  #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
  #define arch_xhdr(bfd) \
!   ((struct xcoff_ar_big_hdr *) arch_eltdata (bfd)->arch_header)
  
  /* XCOFF archives do not have anything which corresponds to an
     extended name table.  */
***************
*** 694,699 ****
- --- 763,824 ----
  
  #define xcoff_update_armap_timestamp bfd_true
  
+ struct xcoff_ar_big_file_hdr *
+ xcoff_ardata(abfd)
+           bfd *abfd;
+ {
+      return (struct xcoff_ar_big_file_hdr *)bfd_ardata (abfd)->tdata;
+ }
+ 
+ static boolean
+ is_big_ar(abfd)
+       bfd *abfd;
+ {
+      if(strncmp(xcoff_ardata (abfd)->magic,XCOFFBIGARMAG,SXCOFFARMAG) == 0)
+ 	  return true;
+      else
+ 	  return false;
+ }
+ 
+ boolean
+ bfd_read_ar(abfd,hdr)
+          bfd *abfd;
+ 	 struct xcoff_ar_big_hdr *hdr;
+ {
+      struct xcoff_ar_small_hdr shdr;
+ 
+      
+ 
+      if(is_big_ar(abfd))
+      {
+ 	  if (bfd_read ((PTR) hdr, SIZEOF_AR_BIG_HDR, 1, abfd) 
+ 	      != SIZEOF_AR_BIG_HDR)
+ 	  {
+ 	       return false;
+ 	  }
+ 	  else
+ 	  {
+ 
+ 	       return true;
+ 	  }
+      }
+ 
+      if (bfd_read ((PTR) &shdr, SIZEOF_AR_SMALL_HDR, 1, abfd) 
+ 	 != SIZEOF_AR_SMALL_HDR)
+      {
+ 	  return false;
+      }
+      strncpy(hdr->size,shdr.size,sizeof(shdr.size));
+      strncpy(hdr->nextoff,shdr.nextoff,sizeof(shdr.nextoff));
+      strncpy(hdr->prevoff,shdr.prevoff,sizeof(shdr.prevoff));
+      strncpy(hdr->date,shdr.date,sizeof(shdr.date));
+      strncpy(hdr->uid,shdr.uid,sizeof(shdr.uid));
+      strncpy(hdr->gid,shdr.gid,sizeof(shdr.gid));
+      strncpy(hdr->mode,shdr.mode,sizeof(shdr.mode));
+      strncpy(hdr->namlen,shdr.namlen,sizeof(shdr.namlen));
+ 
+      return true;
+ }
  /* Read in the armap of an XCOFF archive.  */
  
  static boolean
***************
*** 701,707 ****
       bfd *abfd;
  {
    file_ptr off;
!   struct xcoff_ar_hdr hdr;
    size_t namlen;
    bfd_size_type sz;
    bfd_byte *contents, *cend;
- --- 826,832 ----
       bfd *abfd;
  {
    file_ptr off;
!   struct xcoff_ar_big_hdr hdr;
    size_t namlen;
    bfd_size_type sz;
    bfd_byte *contents, *cend;
***************
*** 709,714 ****
- --- 834,840 ----
    carsym *arsym;
    bfd_byte *p;
  
+ 
    if (xcoff_ardata (abfd) == NULL)
      {
        bfd_has_map (abfd) = false;
***************
*** 726,734 ****
      return false;
  
    /* The symbol table starts with a normal archive header.  */
- -   if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
- -     return false;
  
    /* Skip the name (normally empty).  */
    namlen = strtol (hdr.namlen, (char **) NULL, 10);
    if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
- --- 852,861 ----
      return false;
  
    /* The symbol table starts with a normal archive header.  */
  
+   if(!bfd_read_ar(abfd,&hdr))
+        return false;
+ 
    /* Skip the name (normally empty).  */
    namlen = strtol (hdr.namlen, (char **) NULL, 10);
    if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
***************
*** 782,841 ****
    return true;
  }
  
- - /* See if this is an XCOFF archive.  */
- - 
  static const bfd_target *
! xcoff_archive_p (abfd)
       bfd *abfd;
  {
!   struct xcoff_ar_file_hdr hdr;
  
!   if (bfd_read ((PTR) &hdr, SIZEOF_AR_FILE_HDR, 1, abfd)
!       != SIZEOF_AR_FILE_HDR)
!     {
!       if (bfd_get_error () != bfd_error_system_call)
! 	bfd_set_error (bfd_error_wrong_format);
!       return NULL;
!     }
  
!   if (strncmp (hdr.magic, XCOFFARMAG, SXCOFFARMAG) != 0)
!     {
!       bfd_set_error (bfd_error_wrong_format);
!       return NULL;
!     }
  
!   /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
!      involves a cast, we can't do it as the left operand of
!      assignment.  */
!   abfd->tdata.aout_ar_data =
!     (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
  
!   if (bfd_ardata (abfd) == (struct artdata *) NULL)
!     return NULL;
  
!   bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
! 						  (char **) NULL, 10);
!   bfd_ardata (abfd)->cache = NULL;
!   bfd_ardata (abfd)->archive_head = NULL;
!   bfd_ardata (abfd)->symdefs = NULL;
!   bfd_ardata (abfd)->extended_names = NULL;
  
!   bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
!   if (bfd_ardata (abfd)->tdata == NULL)
!     return NULL;
  
!   memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
  
!   if (! xcoff_slurp_armap (abfd))
      {
!       bfd_release (abfd, bfd_ardata (abfd));
!       abfd->tdata.aout_ar_data = (struct artdata *) NULL;
!       return NULL;
      }
  
!   return abfd->xvec;
  }
  
  /* Read the archive header in an XCOFF archive.  */
  
  static PTR
- --- 909,1052 ----
    return true;
  }
  
  static const bfd_target *
! handle_small_archive(abfd)
       bfd *abfd;
  {
!      struct xcoff_ar_small_file_hdr shdr;
!      struct xcoff_ar_big_file_hdr hdr;
  
!      strncpy(hdr.magic,XCOFFSMALLARMAG,SXCOFFARMAG);
!      
!      if (bfd_read ((PTR) &shdr.memoff, 
! 		   SIZEOF_AR_SMALL_FILE_HDR - SXCOFFARMAG, 1, abfd)
! 	 != SIZEOF_AR_SMALL_FILE_HDR-SXCOFFARMAG)
!      {
! 	  if (bfd_get_error () != bfd_error_system_call)
! 	       bfd_set_error (bfd_error_wrong_format);
! 	  return NULL;
!      }
  
!      strncpy(hdr.memoff,shdr.memoff,sizeof(shdr.memoff));
!      strncpy(hdr.symoff,shdr.symoff,sizeof(shdr.symoff));
!      strncpy(hdr.firstmemoff,shdr.firstmemoff,sizeof(shdr.firstmemoff));
!      strncpy(hdr.lastmemoff,shdr.lastmemoff,sizeof(shdr.lastmemoff));
!      strncpy(hdr.freeoff,shdr.freeoff,sizeof(shdr.freeoff));
  
!      
  
!      /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
! 	involves a cast, we can't do it as the left operand of
! 	assignment.  */
!      abfd->tdata.aout_ar_data =
! 	  (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
  
!      if (bfd_ardata (abfd) == (struct artdata *) NULL)
! 	  return NULL;
  
!      bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
! 						     (char **) NULL, 10);
!      bfd_ardata (abfd)->cache = NULL;
!      bfd_ardata (abfd)->archive_head = NULL;
!      bfd_ardata (abfd)->symdefs = NULL;
!      bfd_ardata (abfd)->extended_names = NULL;
  
!      bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_BIG_FILE_HDR);
!      if (bfd_ardata (abfd)->tdata == NULL)
! 	  return NULL;
!      
!      memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_BIG_FILE_HDR);
  
!      if (! xcoff_slurp_armap (abfd))
      {
! 	 bfd_release (abfd, bfd_ardata (abfd));
! 	 abfd->tdata.aout_ar_data = (struct artdata *) NULL;
! 	 return NULL;
      }
  
!      return abfd->xvec;
  }
  
+ static const bfd_target *
+ handle_big_archive(abfd)
+      bfd *abfd;
+ {
+      struct xcoff_ar_big_file_hdr hdr;
+      
+      strncpy(hdr.magic,XCOFFBIGARMAG,SXCOFFARMAG);
+      if (bfd_read ((PTR) &hdr.memoff, 
+ 		   SIZEOF_AR_BIG_FILE_HDR-SXCOFFARMAG, 1, abfd)
+ 	 != SIZEOF_AR_BIG_FILE_HDR -SXCOFFARMAG)
+      {
+ 	  if (bfd_get_error () != bfd_error_system_call)
+ 	       bfd_set_error (bfd_error_wrong_format);
+ 	  return NULL;
+      }
+      /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
+ 	involves a cast, we can't do it as the left operand of
+ 	assignment.  */
+      abfd->tdata.aout_ar_data =
+ 	  (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
+ 
+      if (bfd_ardata (abfd) == (struct artdata *) NULL)
+ 	  return NULL;
+ 
+      bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
+ 						     (char **) NULL, 10);
+      bfd_ardata (abfd)->cache = NULL;
+      bfd_ardata (abfd)->archive_head = NULL;
+      bfd_ardata (abfd)->symdefs = NULL;
+      bfd_ardata (abfd)->extended_names = NULL;
+ 
+      bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_BIG_FILE_HDR);
+      if (bfd_ardata (abfd)->tdata == NULL)
+ 	  return NULL;
+      
+      memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_BIG_FILE_HDR);
+ 
+      if (! xcoff_slurp_armap (abfd))
+      {
+ 	  bfd_release (abfd, bfd_ardata (abfd));
+ 	  abfd->tdata.aout_ar_data = (struct artdata *) NULL;
+ 	  return NULL;
+      }
+ 
+      return abfd->xvec;
+ }
+ 
+ /* See if this is an XCOFF archive.  */
+ 
+ static const bfd_target *
+ xcoff_archive_p (abfd)
+      bfd *abfd;
+ {
+      char hdrmagic[SXCOFFARMAG];
+ 
+      if (bfd_read ((PTR) &hdrmagic, SXCOFFARMAG, 1, abfd)
+ 	 != SXCOFFARMAG)
+      {
+ 	  if (bfd_get_error () != bfd_error_system_call)
+ 	       bfd_set_error (bfd_error_wrong_format);
+ 	  return NULL;
+      }
+ 
+   /*check if it's a small or big archive.... */
+ 
+   if (strncmp (hdrmagic, XCOFFBIGARMAG, SXCOFFARMAG) == 0)
+        return handle_big_archive(abfd);
+   else
+        if (strncmp (hdrmagic, XCOFFSMALLARMAG, SXCOFFARMAG) == 0)
+ 	    return handle_small_archive(abfd);
+        else
+        {
+ 	    bfd_set_error (bfd_error_wrong_format);
+ 	    return NULL;
+        }
+   
+ 
+ }
+ 
+ 
  /* Read the archive header in an XCOFF archive.  */
  
  static PTR
***************
*** 842,870 ****
  xcoff_read_ar_hdr (abfd)
       bfd *abfd;
  {
!   struct xcoff_ar_hdr hdr;
    size_t namlen;
!   struct xcoff_ar_hdr *hdrp;
    struct areltdata *ret;
  
!   if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
      return NULL;
  
    namlen = strtol (hdr.namlen, (char **) NULL, 10);
!   hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
    if (hdrp == NULL)
      return NULL;
!   memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
!   if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
      return NULL;
- -   ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
  
    ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
    if (ret == NULL)
      return NULL;
    ret->arch_header = (char *) hdrp;
    ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
!   ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
  
    /* Skip over the XCOFFARFMAG at the end of the file name.  */
    if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
- --- 1053,1088 ----
  xcoff_read_ar_hdr (abfd)
       bfd *abfd;
  {
!   struct xcoff_ar_big_hdr hdr;
    size_t namlen;
!   struct xcoff_ar_big_hdr *hdrp;
    struct areltdata *ret;
  
!   if (!bfd_read_ar(abfd,&hdr))
      return NULL;
  
    namlen = strtol (hdr.namlen, (char **) NULL, 10);
!   hdrp = (struct xcoff_ar_big_hdr *) bfd_alloc 
!        (abfd, SIZEOF_AR_BIG_HDR + namlen + 1);
! 
    if (hdrp == NULL)
      return NULL;
! 
!   memcpy (hdrp, &hdr, SIZEOF_AR_BIG_HDR);
! 
!   if (bfd_read ((char *) hdrp + SIZEOF_AR_BIG_HDR, 1, namlen, abfd) != namlen)
      return NULL;
  
+   ((char *) hdrp)[SIZEOF_AR_BIG_HDR + namlen] = '\0';
+ 
    ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
+ 
    if (ret == NULL)
      return NULL;
+ 
    ret->arch_header = (char *) hdrp;
    ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
!   ret->filename = (char *) hdrp + SIZEOF_AR_BIG_HDR;
  
    /* Skip over the XCOFFARFMAG at the end of the file name.  */
    if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
***************
*** 880,909 ****
       bfd *archive;
       bfd *last_file;
  {
!   file_ptr filestart;
  
!   if (xcoff_ardata (archive) == NULL)
!     {
!       bfd_set_error (bfd_error_invalid_operation);
!       return NULL;
!     }
  
!   if (last_file == NULL)
!     filestart = bfd_ardata (archive)->first_file_filepos;
!   else
!     filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL, 10);
  
!   if (filestart == 0
!       || filestart == strtol (xcoff_ardata (archive)->memoff,
! 			      (char **) NULL, 10)
!       || filestart == strtol (xcoff_ardata (archive)->symoff,
! 			      (char **) NULL, 10))
!     {
!       bfd_set_error (bfd_error_no_more_archived_files);
!       return NULL;
!     }
  
!   return _bfd_get_elt_at_filepos (archive, filestart);
  }
  
  /* Stat an element in an XCOFF archive.  */
- --- 1098,1130 ----
       bfd *archive;
       bfd *last_file;
  {
!      file_ptr filestart;
  
!      if (xcoff_ardata (archive) == NULL)
!      {
  
! 	  bfd_set_error (bfd_error_invalid_operation);
! 	  return NULL;
!      }
  
!      if (last_file == NULL)
! 	  filestart = bfd_ardata (archive)->first_file_filepos;
!      else
! 	  filestart = strtol (arch_xhdr (last_file)->nextoff, 
! 			      (char **) NULL, 10);
!      
!      if (filestart == 0
! 	 || filestart == strtol (xcoff_ardata (archive)->memoff,
! 				 (char **) NULL, 10)
! 	 || filestart == strtol (xcoff_ardata (archive)->symoff,
! 				 (char **) NULL, 10))
!      {
! 	  bfd_set_error (bfd_error_no_more_archived_files);
! 	  return NULL;
! 	  
!      }
  
!      return _bfd_get_elt_at_filepos (archive, filestart);
  }
  
  /* Stat an element in an XCOFF archive.  */
***************
*** 913,919 ****
       bfd *abfd;
       struct stat *s;
  {
!   struct xcoff_ar_hdr *hdrp;
  
    if (abfd->arelt_data == NULL)
      {
- --- 1134,1140 ----
       bfd *abfd;
       struct stat *s;
  {
!   struct xcoff_ar_big_hdr *hdrp;
  
    if (abfd->arelt_data == NULL)
      {
***************
*** 961,967 ****
       unsigned int orl_count;
       int stridx;
  {
!   struct xcoff_ar_hdr hdr;
    char *p;
    unsigned char buf[4];
    bfd *sub;
- --- 1182,1188 ----
       unsigned int orl_count;
       int stridx;
  {
!   struct xcoff_ar_small_hdr hdr; /*XXX*/
    char *p;
    unsigned char buf[4];
    bfd *sub;
***************
*** 979,989 ****
    sprintf (hdr.namlen, "%d", 0);
  
    /* We need spaces, not null bytes, in the header.  */
!   for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++)
      if (*p == '\0')
        *p = ' ';
  
!   if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
        || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
      return false;
    
- --- 1200,1210 ----
    sprintf (hdr.namlen, "%d", 0);
  
    /* We need spaces, not null bytes, in the header.  */
!   for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_SMALL_HDR; p++)
      if (*p == '\0')
        *p = ' ';
  
!   if (bfd_write ((PTR) &hdr, SIZEOF_AR_SMALL_HDR, 1, abfd) != SIZEOF_AR_SMALL_HDR
        || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
      return false;
    
***************
*** 992,998 ****
      return false;
  
    sub = abfd->archive_head;
!   fileoff = SIZEOF_AR_FILE_HDR;
    i = 0;
    while (sub != NULL && i < orl_count)
      {
- --- 1213,1219 ----
      return false;
  
    sub = abfd->archive_head;
!   fileoff = SIZEOF_AR_SMALL_FILE_HDR;
    i = 0;
    while (sub != NULL && i < orl_count)
      {
***************
*** 1007,1013 ****
  	}
        namlen = strlen (normalize_filename (sub));
        namlen = (namlen + 1) &~ 1;
!       fileoff += (SIZEOF_AR_HDR
  		  + namlen
  		  + SXCOFFARFMAG
  		  + arelt_size (sub));
- --- 1228,1234 ----
  	}
        namlen = strlen (normalize_filename (sub));
        namlen = (namlen + 1) &~ 1;
!       fileoff += (SIZEOF_AR_SMALL_HDR
  		  + namlen
  		  + SXCOFFARFMAG
  		  + arelt_size (sub));
***************
*** 1045,1051 ****
  xcoff_write_archive_contents (abfd)
       bfd *abfd;
  {
!   struct xcoff_ar_file_hdr fhdr;
    size_t count;
    size_t total_namlen;
    file_ptr *offsets;
- --- 1266,1272 ----
  xcoff_write_archive_contents (abfd)
       bfd *abfd;
  {
!   struct xcoff_ar_small_file_hdr fhdr;
    size_t count;
    size_t total_namlen;
    file_ptr *offsets;
***************
*** 1054,1067 ****
    file_ptr prevoff, nextoff;
    bfd *sub;
    unsigned int i;
!   struct xcoff_ar_hdr ahdr;
    bfd_size_type size;
    char *p;
    char decbuf[13];
  
    memset (&fhdr, 0, sizeof fhdr);
!   strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);
!   sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR);
    sprintf (fhdr.freeoff, "%d", 0);
  
    count = 0;
- --- 1275,1288 ----
    file_ptr prevoff, nextoff;
    bfd *sub;
    unsigned int i;
!   struct xcoff_ar_big_hdr ahdr; /*XXX*/
    bfd_size_type size;
    char *p;
    char decbuf[13];
  
    memset (&fhdr, 0, sizeof fhdr);
!   strncpy (fhdr.magic, XCOFFBIGARMAG, SXCOFFARMAG);
!   sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_BIG_FILE_HDR);
    sprintf (fhdr.freeoff, "%d", 0);
  
    count = 0;
***************
*** 1075,1092 ****
    if (offsets == NULL)
      return false;
  
!   if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
      return false;
  
    makemap = bfd_has_map (abfd);
    hasobjects = false;
    prevoff = 0;
!   nextoff = SIZEOF_AR_FILE_HDR;
    for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
      {
        const char *name;
        size_t namlen;
!       struct xcoff_ar_hdr *ahdrp;
        bfd_size_type remaining;
  
        if (makemap && ! hasobjects)
- --- 1296,1313 ----
    if (offsets == NULL)
      return false;
  
!   if (bfd_seek (abfd, SIZEOF_AR_BIG_FILE_HDR, SEEK_SET) != 0)
      return false;
  
    makemap = bfd_has_map (abfd);
    hasobjects = false;
    prevoff = 0;
!   nextoff = SIZEOF_AR_BIG_FILE_HDR;
    for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
      {
        const char *name;
        size_t namlen;
!       struct xcoff_ar_big_hdr *ahdrp;
        bfd_size_type remaining;
  
        if (makemap && ! hasobjects)
***************
*** 1139,1145 ****
        namlen = (namlen + 1) &~ 1;
  
        remaining = arelt_size (sub);
!       size = (SIZEOF_AR_HDR
  	      + namlen
  	      + SXCOFFARFMAG
  	      + remaining);
- --- 1360,1366 ----
        namlen = (namlen + 1) &~ 1;
  
        remaining = arelt_size (sub);
!       size = (SIZEOF_AR_BIG_HDR
  	      + namlen
  	      + SXCOFFARFMAG
  	      + remaining);
***************
*** 1154,1164 ****
        sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
  
        /* We need spaces, not null bytes, in the header.  */
!       for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++)
  	if (*p == '\0')
  	  *p = ' ';
  
!       if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
  	  || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
  	  || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
  	      != SXCOFFARFMAG))
- --- 1375,1385 ----
        sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
  
        /* We need spaces, not null bytes, in the header.  */
!       for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_BIG_HDR; p++)
  	if (*p == '\0')
  	  *p = ' ';
  
!       if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_BIG_HDR, abfd) != SIZEOF_AR_BIG_HDR
  	  || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
  	  || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
  	      != SXCOFFARFMAG))
***************
*** 1206,1212 ****
    sprintf (ahdr.mode, "%d", 0);
    sprintf (ahdr.namlen, "%d", 0);
  
!   size = (SIZEOF_AR_HDR
  	  + 12
  	  + count * 12
  	  + total_namlen
- --- 1427,1433 ----
    sprintf (ahdr.mode, "%d", 0);
    sprintf (ahdr.namlen, "%d", 0);
  
!   size = (SIZEOF_AR_BIG_HDR
  	  + 12
  	  + count * 12
  	  + total_namlen
***************
*** 1221,1231 ****
      sprintf (ahdr.nextoff, "%d", 0);
  
    /* We need spaces, not null bytes, in the header.  */
!   for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++)
      if (*p == '\0')
        *p = ' ';
  
!   if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
        || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
  	  != SXCOFFARFMAG))
      return false;
- --- 1442,1452 ----
      sprintf (ahdr.nextoff, "%d", 0);
  
    /* We need spaces, not null bytes, in the header.  */
!   for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_BIG_HDR; p++)
      if (*p == '\0')
        *p = ' ';
  
!   if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_BIG_HDR, abfd) != SIZEOF_AR_BIG_HDR
        || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
  	  != SXCOFFARFMAG))
      return false;
***************
*** 1274,1286 ****
    /* Write out the archive file header.  */
  
    /* We need spaces, not null bytes, in the header.  */
!   for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++)
      if (*p == '\0')
        *p = ' ';
  
    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
!       || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
! 	  SIZEOF_AR_FILE_HDR))
      return false;
  
    return true;
- --- 1495,1507 ----
    /* Write out the archive file header.  */
  
    /* We need spaces, not null bytes, in the header.  */
!   for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_BIG_FILE_HDR; p++)
      if (*p == '\0')
        *p = ' ';
  
    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
!       || (bfd_write ((PTR) &fhdr, SIZEOF_AR_BIG_FILE_HDR, 1, abfd) !=
! 	  SIZEOF_AR_BIG_FILE_HDR))
      return false;
  
    return true;
***************
*** 1416,1418 ****
- --- 1637,1641 ----
  
    COFF_SWAP_TABLE,
  };
+ 
+ 
*** gdb-4.17.87/bfd/configure.in~	Thu Mar 25 04:19:20 1999
- --- gdb-4.17.87/bfd/configure.in	Sat Mar 27 04:12:42 1999
***************
*** 99,104 ****
- --- 99,105 ----
  AC_HEADER_TIME
  AC_HEADER_DIRENT
  AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen)
+ AC_EGREP_HEADER(core_dumpx,sys/core.h,AC_DEFINE(HAVE_CORE_DUMPX, 1, [Define if you have a struct core_dumpx]))
  
  BFD_BINARY_FOPEN
  
------- End of forwarded message -------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]