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]

[PATCH] bfd/rs6000-core.c


[Note:  I originally sent this to the gdb list where I am a maintainer
for the PPC architecture.  I've since been informed that I should have
sent this patch to the binutils list instead.  I now suspect that may
have inadvertently treaded on someone's territory.  So, whoever's
responsible for rs6000-core.c (if anyone), please look over my changes
and let me know if you have any objections.  I'll be happy to
accomodate you.  :-) ]

I've just committed the following changes for the new AIX 4.3 core dump
structure.

Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.330
diff -u -p -r1.330 ChangeLog
--- ChangeLog	2000/02/17 00:33:34	1.330
+++ ChangeLog	2000/02/17 08:59:39
@@ -1,3 +1,14 @@
+2000-02-17  Kevin Buettner  <kevinb@redhat.com>
+
+	* rs6000-core.c (CORE_DATA_SIZE_FIELD, CORE_COMM_FIELD, SAVE_FIELD,
+	STACK_END_ADDR): Define for new core file format.
+	(LOADER_OFFSET_FIELD, LOADER_REGION_SIZE, CORE_DUMP): New defines
+	for handling the vagaries of the various core file structures used
+	by AIX over the years.
+	(rs6000coff_core_p, rs6000coff_core_file_matches_executable,
+	Rs6kCorData): Use above defines to adapt code to use AIX 4.3's
+	core_dumpx structure.
+
 Thu Feb 17 00:04:48 2000  J"orn Rennecke <amylaar@cygnus.co.uk>
 
 	* archures.c (bfd_mach_sh2, bfd_mach_sh_dsp): New macros.
Index: rs6000-core.c
===================================================================
RCS file: /cvs/src/src/bfd/rs6000-core.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 rs6000-core.c
--- rs6000-core.c	1999/05/03 07:28:58	1.1.1.1
+++ rs6000-core.c	2000/02/17 08:59:40
@@ -1,5 +1,5 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998, 2000
    Free Software Foundation, Inc.
    FIXME: Can someone provide a transliteration of this name into ASCII?
    Using the following chars caused a compiler warning on HIUX (so I replaced
@@ -81,26 +81,47 @@ Foundation, Inc., 59 Temple Place - Suit
 #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. 
+   this seems to be the quickest/easiest way to deal with it. 
 
    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.  */
+   right now.
+   
+   AIX 4.3 defines an entirely new structure (core_dumpx).  Yet the
+   basic logic stays the same and we can still use our macro
+   redefinition mechanism to effect the necessary changes.  */
+
+#ifdef AIX_CORE_DUMPX_CORE
+#define CORE_DATA_SIZE_FIELD c_dataorg
+#define CORE_COMM_FIELD c_u.U_proc.pi_comm
+#define SAVE_FIELD c_flt.hctx.r32
+#define STACK_END_ADDR coredata.c_stackorg + coredata.c_size
+#define LOADER_OFFSET_FIELD c_loader
+#define LOADER_REGION_SIZE coredata.c_lsize
+#define CORE_DUMP core_dumpx
+#else
 #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
+#define LOADER_OFFSET_FIELD c_tab
+#define LOADER_REGION_SIZE 0x7ffffff
+#define CORE_DUMP core_dump
 #else
 #define CORE_DATA_SIZE_FIELD c_u.u_dsize
 #define CORE_COMM_FIELD c_u.u_comm
 #define SAVE_FIELD c_u.u_save
 #define	STACK_END_ADDR 0x2ff80000
+#define LOADER_OFFSET_FIELD c_tab
+#define LOADER_REGION_SIZE 0x7ffffff
+#define CORE_DUMP core_dump
+#endif
 #endif
 
 /* These are stored in the bfd's tdata */
 typedef struct {
-  struct core_dump hdr;		/* core file header */
+  struct CORE_DUMP hdr;		/* core file header */
 } Rs6kCorData;
 
 static asection *make_bfd_asection PARAMS ((bfd *, CONST char *, flagword,
@@ -137,7 +158,7 @@ const bfd_target *
 rs6000coff_core_p (abfd)
      bfd *abfd;
 {
-  struct core_dump coredata;
+  struct CORE_DUMP coredata;
   struct stat statbuf;
   bfd_size_type nread;
   char *tmpptr;
@@ -145,8 +166,8 @@ rs6000coff_core_p (abfd)
   if (bfd_seek (abfd, 0, SEEK_SET) != 0)
     return NULL;
 
-  nread = bfd_read (&coredata, 1, sizeof (struct core_dump), abfd);
-  if (nread != sizeof (struct core_dump))
+  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);
@@ -197,6 +218,15 @@ rs6000coff_core_p (abfd)
       return NULL;
     }
 
+#ifdef AIX_CORE_DUMPX_CORE
+  /* For the core_dumpx format, make sure c_entries == 0  If it does
+     not, the core file uses the old format */
+  if (coredata.c_entries != 0)
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return NULL;
+    }
+#else
   /* Sanity check on the c_tab field.  */
   if ((u_long) coredata.c_tab < sizeof coredata ||
       (u_long) coredata.c_tab >= statbuf.st_size ||
@@ -205,6 +235,7 @@ rs6000coff_core_p (abfd)
       bfd_set_error (bfd_error_wrong_format);
       return NULL;
     }
+#endif
 
   /* Issue warning if the core file was truncated during writing.  */
   if (coredata.c_flag & CORE_TRUNC)
@@ -253,9 +284,9 @@ rs6000coff_core_p (abfd)
      See if we can just fake it.  */
   if (!make_bfd_asection (abfd, ".ldinfo",
   			  SEC_HAS_CONTENTS,
-			  (bfd_size_type) 0x7fffffff,
+			  (bfd_size_type) LOADER_REGION_SIZE,
 			  (bfd_vma) 0,
-			  (file_ptr) coredata.c_tab))
+			  (file_ptr) coredata.LOADER_OFFSET_FIELD))
     return NULL;
 
 #ifndef CORE_VERSION_1
@@ -284,7 +315,7 @@ rs6000coff_core_p (abfd)
   {
     struct ld_info ldinfo;
     bfd_size_type ldinfo_size;
-    file_ptr ldinfo_offset = (file_ptr) coredata.c_tab;
+    file_ptr ldinfo_offset = (file_ptr) coredata.LOADER_OFFSET_FIELD;
 
     /* .data section from executable.  */
     if (coredata.c_datasize)
@@ -360,7 +391,7 @@ rs6000coff_core_file_matches_executable_
      bfd *core_bfd;
      bfd *exec_bfd;
 {
-  struct core_dump coredata;
+  struct CORE_DUMP coredata;
   struct ld_info ldinfo;
   bfd_size_type size;
   char *path, *s;
@@ -372,7 +403,7 @@ rs6000coff_core_file_matches_executable_
       || bfd_read (&coredata, sizeof coredata, 1, core_bfd) != sizeof coredata)
     return false;
 
-  if (bfd_seek (core_bfd, (long) coredata.c_tab, SEEK_SET) != 0)
+  if (bfd_seek (core_bfd, (long) coredata.LOADER_OFFSET_FIELD, SEEK_SET) != 0)
     return false;
 
   size = (char *) &ldinfo.ldinfo_filename[0] - (char *) &ldinfo.ldinfo_next;



-- 
Kevin Buettner
kev@primenet.com, kevinb@redhat.com

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