include/coff/
authorTristan Gingold <gingold@adacore.com>
Wed, 10 Jul 2013 08:16:34 +0000 (08:16 +0000)
committerTristan Gingold <gingold@adacore.com>
Wed, 10 Jul 2013 08:16:34 +0000 (08:16 +0000)
2013-07-10  Tristan Gingold  <gingold@adacore.com>

* rs6000.h (external_core_dumpx): New structure.
(external_ld_info32): Ditto.

binutils/
2013-07-10  Tristan Gingold  <gingold@adacore.com>

* od-xcoff.c (OPT_LDINFO): Define.
(options): Add ldinfo.
(xcoff_help): Mention ldinfo.
(xcoff_dump): Rename to ...
(xcoff_dump_obj): ... this.  Add a break.
(dump_dumpx_core): New function.
(xcoff_dump_core): Likewise.
(xcoff_dump): Likewise.
* doc/binutils.texi (objdump): Mention ldinfo.

binutils/ChangeLog
binutils/doc/binutils.texi
binutils/od-xcoff.c
include/coff/ChangeLog
include/coff/rs6000.h

index af3b773..fe84d2c 100644 (file)
@@ -1,3 +1,15 @@
+2013-07-10  Tristan Gingold  <gingold@adacore.com>
+
+       * od-xcoff.c (OPT_LDINFO): Define.
+       (options): Add ldinfo.
+       (xcoff_help): Mention ldinfo.
+       (xcoff_dump): Rename to ...
+       (xcoff_dump_obj): ... this.  Add a break.
+       (dump_dumpx_core): New function.
+       (xcoff_dump_core): Likewise.
+       (xcoff_dump): Likewise.
+       * doc/binutils.texi (objdump): Mention ldinfo.
+
 2013-07-09  Tristan Gingold  <gingold@adacore.com>
 
        * configure.com: Add new defines to match changes in configure.
index aaa0bdb..112086f 100644 (file)
@@ -2173,8 +2173,8 @@ format (the lists of options is displayed with the help).
 
 For XCOFF, the available options are: @option{header}, @option{aout},
 @option{sections}, @option{syms}, @option{relocs}, @option{lineno},
-@option{loader}, @option{except}, @option{typchk}, @option{traceback}
-and @option{toc}.
+@option{loader}, @option{except}, @option{typchk}, @option{traceback},
+@option{toc} and @option{ldinfo}.
 
 @item -r
 @itemx --reloc
index d7056a8..168a43a 100644 (file)
@@ -49,6 +49,7 @@
 #define OPT_TYPCHK 8
 #define OPT_TRACEBACK 9
 #define OPT_TOC 10
+#define OPT_LDINFO 11
 
 /* List of actions.  */
 static struct objdump_private_option options[] =
@@ -64,6 +65,7 @@ static struct objdump_private_option options[] =
     { "typchk", 0 },
     { "traceback", 0 },
     { "toc", 0 },
+    { "ldinfo", 0 },
     { NULL, 0 }
   };
 
@@ -85,6 +87,7 @@ For XCOFF files:\n\
   typchk      Display type-check section\n\
   traceback   Display traceback tags\n\
   toc         Display toc symbols\n\
+  ldinfo      Display loader info in core files\n\
 "));
 }
 
@@ -1628,7 +1631,7 @@ dump_xcoff32 (bfd *abfd, struct external_filehdr *fhdr)
 /* Dump ABFD (according to the options[] array).  */
 
 static void
-xcoff_dump (bfd *abfd)
+xcoff_dump_obj (bfd *abfd)
 {
   struct external_filehdr fhdr;
   unsigned short magic;
@@ -1660,6 +1663,7 @@ xcoff_dump (bfd *abfd)
           break;
         default:
           printf (_("unknown magic"));
+         break;
         }
       putchar ('\n');
     }
@@ -1669,6 +1673,164 @@ xcoff_dump (bfd *abfd)
     printf (_("  Unhandled magic\n"));
 }
 
+/* Handle an AIX dumpx core file.  */
+
+static void
+dump_dumpx_core (bfd *abfd, struct external_core_dumpx *hdr)
+{
+  if (options[OPT_FILE_HEADER].selected)
+    {
+      printf ("  signal:     %u\n", bfd_h_get_8 (abfd, hdr->c_signo));
+      printf ("  flags:      0x%02x\n", bfd_h_get_8 (abfd, hdr->c_flag));
+      printf ("  entries:    %u\n",
+             (unsigned) bfd_h_get_16 (abfd, hdr->c_entries));
+#ifdef BFD64
+      printf ("  fdsinfox:   offset: 0x%08" BFD_VMA_FMT "x\n",
+             bfd_h_get_64 (abfd, hdr->c_fdsinfox));
+      printf ("  loader:     offset: 0x%08" BFD_VMA_FMT "x, "
+             "size: 0x%" BFD_VMA_FMT"x\n",
+             bfd_h_get_64 (abfd, hdr->c_loader),
+             bfd_h_get_64 (abfd, hdr->c_lsize));
+      printf ("  thr:        offset: 0x%08" BFD_VMA_FMT "x, nbr: %u\n",
+             bfd_h_get_64 (abfd, hdr->c_thr),
+             (unsigned) bfd_h_get_32 (abfd, hdr->c_n_thr));
+      printf ("  segregions: offset: 0x%08" BFD_VMA_FMT "x, "
+             "nbr: %" BFD_VMA_FMT "u\n",
+             bfd_h_get_64 (abfd, hdr->c_segregion),
+             bfd_h_get_64 (abfd, hdr->c_segs));
+      printf ("  stack:      offset: 0x%08" BFD_VMA_FMT "x, "
+             "org: 0x%" BFD_VMA_FMT"x, "
+             "size: 0x%" BFD_VMA_FMT"x\n",
+             bfd_h_get_64 (abfd, hdr->c_stack),
+             bfd_h_get_64 (abfd, hdr->c_stackorg),
+             bfd_h_get_64 (abfd, hdr->c_size));
+      printf ("  data:       offset: 0x%08" BFD_VMA_FMT "x, "
+             "org: 0x%" BFD_VMA_FMT"x, "
+             "size: 0x%" BFD_VMA_FMT"x\n",
+             bfd_h_get_64 (abfd, hdr->c_data),
+             bfd_h_get_64 (abfd, hdr->c_dataorg),
+             bfd_h_get_64 (abfd, hdr->c_datasize));
+      printf ("  sdata:         org: 0x%" BFD_VMA_FMT"x, "
+             "size: 0x%" BFD_VMA_FMT"x\n",
+             bfd_h_get_64 (abfd, hdr->c_sdorg),
+             bfd_h_get_64 (abfd, hdr->c_sdsize));
+      printf ("  vmmregions: offset: 0x%" BFD_VMA_FMT"x, "
+             "num: 0x%" BFD_VMA_FMT"x\n",
+             bfd_h_get_64 (abfd, hdr->c_vmm),
+             bfd_h_get_64 (abfd, hdr->c_vmmregions));
+      printf ("  impl:       0x%08x\n",
+             (unsigned) bfd_h_get_32 (abfd, hdr->c_impl));
+      printf ("  cprs:       0x%" BFD_VMA_FMT "x\n",
+             bfd_h_get_64 (abfd, hdr->c_cprs));
+#endif
+    }
+  if (options[OPT_LDINFO].selected)
+    {
+#ifdef BFD64
+      file_ptr off = (file_ptr) bfd_h_get_64 (abfd, hdr->c_loader);
+      bfd_size_type len = (bfd_size_type) bfd_h_get_64 (abfd, hdr->c_lsize);
+      char *ldr;
+
+      ldr = xmalloc (len);
+      if (bfd_seek (abfd, off, SEEK_SET) != 0
+         || bfd_bread (ldr, len, abfd) != len)
+       non_fatal (_("cannot read loader info table"));
+      else
+       {
+         char *p;
+
+         printf ("\n"
+                 "ld info:\n");
+         printf ("  next     core off textorg  textsize dataorg  datasize\n");
+         p = ldr;
+         while (1)
+           {
+             struct external_ld_info32 *l = (struct external_ld_info32 *)p;
+             unsigned int next;
+             size_t n1;
+
+             next = bfd_h_get_32 (abfd, l->ldinfo_next);
+             printf ("  %08x %08x %08x %08x %08x %08x\n",
+                     next,
+                     (unsigned) bfd_h_get_32 (abfd, l->core_offset),
+                     (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textorg),
+                     (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textsize),
+                     (unsigned) bfd_h_get_32 (abfd, l->ldinfo_dataorg),
+                     (unsigned) bfd_h_get_32 (abfd, l->ldinfo_datasize));
+             n1 = strlen ((char *) l->ldinfo_filename);
+             printf ("    %s %s\n",
+                     l->ldinfo_filename, l->ldinfo_filename + n1 + 1);
+             if (next == 0)
+               break;
+             p += next;
+           }
+       }
+#else
+      printf (_("\n"
+               "ldinfo dump not supported in 32 bits environments\n"));
+#endif
+    }
+}
+
+/* Dump a core file.  */
+
+static void
+xcoff_dump_core (bfd *abfd)
+{
+  struct external_core_dumpx hdr;
+  unsigned int version;
+
+  /* Read file header.  */
+  if (bfd_seek (abfd, 0, SEEK_SET) != 0
+      || bfd_bread (&hdr, sizeof (hdr), abfd) != sizeof (hdr))
+    {
+      non_fatal (_("cannot core read header"));
+      return;
+    }
+
+  version = bfd_h_get_32 (abfd, hdr.c_version);
+  if (options[OPT_FILE_HEADER].selected)
+    {
+      printf (_("Core header:\n"));
+      printf (_("  version:    0x%08x  "), version);
+      switch (version)
+       {
+       case CORE_DUMPX_VERSION:
+         printf (_("(dumpx format - aix4.3 / 32 bits)"));
+         break;
+       case CORE_DUMPXX_VERSION:
+         printf (_("(dumpxx format - aix5.0 / 64 bits)"));
+         break;
+       default:
+         printf (_("unknown format"));
+         break;
+       }
+      putchar ('\n');
+    }
+  if (version == CORE_DUMPX_VERSION)
+    dump_dumpx_core (abfd, &hdr);
+  else
+    printf (_("  Unhandled magic\n"));
+}
+
+/* Dump an XCOFF file.  */
+
+static void
+xcoff_dump (bfd *abfd)
+{
+  /* We rely on BFD to decide if the file is a core file.  Note that core
+     files are only supported on native environment by BFD.  */
+  switch (bfd_get_format (abfd))
+    {
+    case bfd_core:
+      xcoff_dump_core (abfd);
+      break;
+    default:
+      xcoff_dump_obj (abfd);
+      break;
+    }
+}
+
 /* Vector for xcoff.  */
 
 const struct objdump_private_desc objdump_private_desc_xcoff =
index f10aa34..2a9c0ab 100644 (file)
@@ -1,5 +1,10 @@
+2013-07-10  Tristan Gingold  <gingold@adacore.com>
+
+       * rs6000.h (external_core_dumpx): New structure.
+       (external_ld_info32): Ditto.
+
 2013-07-02  Tristan Gingold  <gingold@adacore.com>
-          
+
        * internal.h (C_STTLS, C_GTLS): Define.
        * xcoff.h (XMC_TL, XMC_TU, XMC_TE): Define.
 
index d5b2af2..7972d33 100644 (file)
@@ -46,7 +46,7 @@ struct external_filehdr {
 /********************** AOUT "OPTIONAL HEADER" **********************/
 
 
-typedef struct 
+typedef struct
 {
   unsigned char        magic[2];       /* type of file                 */
   unsigned char        vstamp[2];      /* version stamp                */
@@ -204,7 +204,7 @@ union external_auxent {
 };
 
 #define        SYMENT  struct external_syment
-#define        SYMESZ  18      
+#define        SYMESZ  18
 #define        AUXENT  union external_auxent
 #define        AUXESZ  18
 #define DBXMASK 0x80           /* for dbx storage mask */
@@ -291,3 +291,63 @@ struct external_exceptab
 };
 
 #define EXCEPTSZ (4 + 2)
+
+/******************** Core files *************************/
+
+struct external_core_dumpx
+{
+  unsigned char c_signo[1];
+  unsigned char c_flag[1];
+  unsigned char c_entries[2];
+
+  unsigned char c_version[4];
+
+  unsigned char c_fdsinfox[8];
+  unsigned char c_loader[8];
+  unsigned char c_lsize[8];
+
+  unsigned char c_n_thr[4];
+  unsigned char c_reserved0[4];
+  unsigned char c_thr[8];
+
+  unsigned char c_segs[8];
+  unsigned char c_segregion[8];
+
+  unsigned char c_stack[8];
+  unsigned char c_stackorg[8];
+  unsigned char c_size[8];
+
+  unsigned char c_data[8];
+  unsigned char c_dataorg[8];
+  unsigned char c_datasize[8];
+  unsigned char c_sdorg[8];
+  unsigned char c_sdsize[8];
+
+  unsigned char c_vmmregions[8];
+  unsigned char c_vmm[8];
+
+  unsigned char c_impl[4];
+  unsigned char c_pad[4];
+  unsigned char c_cprs[8];
+  unsigned char c_reserved[7 * 8];
+
+  /* Followed by:
+     - context of the faulting thread.
+     - user structure.  */
+};
+
+
+/* Core file verion.  */
+#define CORE_DUMPX_VERSION 0x0feeddb1
+#define CORE_DUMPXX_VERSION 0x0feeddb2
+
+struct external_ld_info32
+{
+  unsigned char ldinfo_next[4];
+  unsigned char core_offset[4];
+  unsigned char ldinfo_textorg[4];
+  unsigned char ldinfo_textsize[4];
+  unsigned char ldinfo_dataorg[4];
+  unsigned char ldinfo_datasize[4];
+  unsigned char ldinfo_filename[2];
+};