This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

[Patch] readelf: display VMS notes


Hi,

with this patch, readelf will recognize VMS/IPF notes.  Things are slightly more complex than on other OS
because the note format is differents (fields are 64 bit instead of 32).  Furthermore, VMS notes are fully
decoded.

No regression on a cross i386-linux.

OK for trunk ?

Tristan.

binutils/
2011-03-25  Tristan Gingold  <gingold@adacore.com>

	* readelf.c (get_ia64_vms_note_type): New function.
	(print_ia64_vms_note): Ditto.
	(process_note): Recognize VMS/ia64 specific notes.
	Display them.
	(process_corefile_note_segment): Decode VMS notes.

2011-03-25  Tristan Gingold  <gingold@adacore.com>

	* ia64.h (Elf64_External_VMS_Note): New struct.
	(NT_VMS_MHD, NT_VMS_LNM, NT_VMS_SRC, NT_VMS_TITLE, NT_VMS_EIDC,
	NT_VMS_FPMODE, NT_VMS_LINKTIME, NT_VMS_IMGNAM, NT_VMS_IMGID
	NT_VMS_LINKID, NT_VMS_IMGBID, NT_VMS_GSTNAM, NT_VMS_ORIG_DYN)
	NT_VMS_PATCHTIME) New macros.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.536
diff -c -p -r1.536 readelf.c
*** binutils/readelf.c	14 Mar 2011 17:48:31 -0000	1.536
--- binutils/readelf.c	25 Mar 2011 16:09:26 -0000
*************** get_netbsd_elfcore_note_type (unsigned e
*** 12046,12051 ****
--- 12046,12162 ----
    return buff;
  }
  
+ static const char *
+ get_ia64_vms_note_type (unsigned e_type)
+ {
+   static char buff[64];
+ 
+   switch (e_type)
+     {
+     case NT_VMS_MHD:
+       return _("NT_VMS_MHD (module header)");
+     case NT_VMS_LNM:
+       return _("NT_VMS_LNM (language name)");
+     case NT_VMS_SRC:
+       return _("NT_VMS_SRC (source files)");
+     case NT_VMS_TITLE:
+       return _("NT_VMS_TITLE");
+     case NT_VMS_EIDC:
+       return _("NT_VMS_EIDC (consistency check)");
+     case NT_VMS_FPMODE:
+       return _("NT_VMS_FPMODE (FP mode)");
+     case NT_VMS_LINKTIME:
+       return _("NT_VMS_LINKTIME");
+     case NT_VMS_IMGNAM:
+       return _("NT_VMS_IMGNAM (image name)");
+     case NT_VMS_IMGID:
+       return _("NT_VMS_IMGID (image id)");
+     case NT_VMS_LINKID:
+       return _("NT_VMS_LINKID (link id)");
+     case NT_VMS_IMGBID:
+       return _("NT_VMS_IMGBID (build id)");
+     case NT_VMS_GSTNAM:
+       return _("NT_VMS_GSTNAM (sym table name)");
+     case NT_VMS_ORIG_DYN:
+       return _("NT_VMS_ORIG_DYN");
+     case NT_VMS_PATCHTIME:
+       return _("NT_VMS_PATCHTIME");
+     default:
+       snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), e_type);
+       return buff;
+     }
+ }
+ 
+ static int
+ print_ia64_vms_note (Elf_Internal_Note * pnote)
+ {
+   switch (pnote->type)
+     {
+     case NT_VMS_MHD:
+       if (pnote->descsz > 36)
+         {
+           size_t l = strlen (pnote->descdata + 34);
+           printf (_("    Creation date  : %.17s\n"), pnote->descdata);
+           printf (_("    Last patch date: %.17s\n"), pnote->descdata + 17);
+           printf (_("    Module name    : %s\n"), pnote->descdata + 34);
+           printf (_("    Module version : %s\n"), pnote->descdata + 34 + l + 1);
+         }
+       else
+         printf (_("    Invalid size\n"));
+       break;
+     case NT_VMS_LNM:
+       printf (_("   Language: %s\n"), pnote->descdata);
+       break;
+ #ifdef BFD64
+     case NT_VMS_FPMODE:
+       printf (_("   FP mode: 0x%016" BFD_VMA_FMT "x\n"),
+               (bfd_vma)byte_get ((unsigned char *)pnote->descdata, 8));
+       break;
+     case NT_VMS_LINKTIME:
+       printf (_("   Link time: "));
+       print_vms_time
+         ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8));
+       printf ("\n");
+       break;
+     case NT_VMS_PATCHTIME:
+       printf (_("   Patch time: "));
+       print_vms_time
+         ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8));
+       printf ("\n");
+       break;
+     case NT_VMS_ORIG_DYN:
+       printf (_("   Major id: %u,  minor id: %u\n"),
+               (unsigned) byte_get ((unsigned char *)pnote->descdata, 4),
+               (unsigned) byte_get ((unsigned char *)pnote->descdata + 4, 4));
+       printf (_("   Manip date  : "));
+       print_vms_time
+         ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata + 8, 8));
+       printf (_("\n"
+                 "   Link flags  : 0x%016" BFD_VMA_FMT "x\n"),
+               (bfd_vma)byte_get ((unsigned char *)pnote->descdata + 16, 8));
+       printf (_("   Header flags: 0x%08x\n"),
+               (unsigned)byte_get ((unsigned char *)pnote->descdata + 24, 4));
+       printf (_("   Image id    : %s\n"), pnote->descdata + 32);
+       break;
+ #endif
+     case NT_VMS_IMGNAM:
+       printf (_("    Image name: %s\n"), pnote->descdata);
+       break;
+     case NT_VMS_GSTNAM:
+       printf (_("    Global symbol table name: %s\n"), pnote->descdata);
+       break;
+     case NT_VMS_IMGID:
+       printf (_("    Image id: %s\n"), pnote->descdata);
+       break;
+     case NT_VMS_LINKID:
+       printf (_("    Linker id: %s\n"), pnote->descdata);
+       break;
+     default:
+       break;
+     }
+   return 1;
+ }
+ 
  /* Note that by the ELF standard, the name field is already null byte
     terminated, and namesz includes the terminating null byte.
     I.E. the value of namesz for the name "FSF" is 4.
*************** process_note (Elf_Internal_Note * pnote)
*** 12077,12089 ****
        name = "SPU";
      }
  
    else
      /* Don't recognize this note name; just use the default set of
         note type strings.  */
!       nt = get_note_type (pnote->type);
  
!   printf ("  %s\t\t0x%08lx\t%s\n", name, pnote->descsz, nt);
!   return 1;
  }
  
  
--- 12188,12208 ----
        name = "SPU";
      }
  
+   else if (const_strneq (pnote->namedata, "IPF/VMS"))
+     /* VMS/ia64-specific file notes.  */
+     nt = get_ia64_vms_note_type (pnote->type);
+ 
    else
      /* Don't recognize this note name; just use the default set of
         note type strings.  */
!     nt = get_note_type (pnote->type);
  
!   printf ("  %-10s\t0x%08lx\t%s\n", name, pnote->descsz, nt);
! 
!   if (const_strneq (pnote->namedata, "IPF/VMS"))
!     return print_ia64_vms_note (pnote);
!   else
!     return 1;
  }
  
  
*************** process_corefile_note_segment (FILE * fi
*** 12114,12127 ****
        Elf_Internal_Note inote;
        char * temp = NULL;
  
!       inote.type     = BYTE_GET (external->type);
!       inote.namesz   = BYTE_GET (external->namesz);
!       inote.namedata = external->name;
!       inote.descsz   = BYTE_GET (external->descsz);
!       inote.descdata = inote.namedata + align_power (inote.namesz, 2);
!       inote.descpos  = offset + (inote.descdata - (char *) pnotes);
  
!       next = (Elf_External_Note *) (inote.descdata + align_power (inote.descsz, 2));
  
        if (   ((char *) next > ((char *) pnotes) + length)
  	  || ((char *) next <  (char *) pnotes))
--- 12233,12265 ----
        Elf_Internal_Note inote;
        char * temp = NULL;
  
!       if (!is_ia64_vms ())
!         {
!           inote.type     = BYTE_GET (external->type);
!           inote.namesz   = BYTE_GET (external->namesz);
!           inote.namedata = external->name;
!           inote.descsz   = BYTE_GET (external->descsz);
!           inote.descdata = inote.namedata + align_power (inote.namesz, 2);
!           inote.descpos  = offset + (inote.descdata - (char *) pnotes);
! 
!           next = (Elf_External_Note *)
!             (inote.descdata + align_power (inote.descsz, 2));
!         }
!       else
!         {
!           Elf64_External_VMS_Note *vms_external;
  
!           vms_external = (Elf64_External_VMS_Note *)external;
!           inote.type     = BYTE_GET (vms_external->type);
!           inote.namesz   = BYTE_GET (vms_external->namesz);
!           inote.namedata = vms_external->name;
!           inote.descsz   = BYTE_GET (vms_external->descsz);
!           inote.descdata = inote.namedata + align_power (inote.namesz, 3);
!           inote.descpos  = offset + (inote.descdata - (char *) pnotes);
! 
!           next = (Elf_External_Note *)
!             (inote.descdata + align_power (inote.descsz, 3));
!         }
  
        if (   ((char *) next > ((char *) pnotes) + length)
  	  || ((char *) next <  (char *) pnotes))
Index: include/elf/ChangeLog

Index: include/elf/ia64.h
===================================================================
RCS file: /cvs/src/src/include/elf/ia64.h,v
retrieving revision 1.18
diff -c -p -r1.18 ia64.h
*** include/elf/ia64.h	11 Jun 2010 15:57:46 -0000	1.18
--- include/elf/ia64.h	25 Mar 2011 16:09:27 -0000
*************** typedef struct
*** 232,237 ****
--- 232,261 ----
    unsigned char fill_1[4];
  } Elf64_External_VMS_IMAGE_RELA;
  
+ /* Note segments.  VMS is special as it uses 64-bit entries.  */
+ 
+ typedef struct {
+   unsigned char	namesz[8];		/* Size of entry's owner string */
+   unsigned char	descsz[8];		/* Size of the note descriptor */
+   unsigned char	type[8];		/* Interpretation of the descriptor */
+   char		name[1];		/* Start of the name+desc data */
+ } Elf64_External_VMS_Note;
+ 
+ #define NT_VMS_MHD         1 /* Object module name, version, and date/time.  */
+ #define NT_VMS_LNM         2 /* Language processor name.  */
+ #define NT_VMS_SRC         3 /* Source files.  */
+ #define NT_VMS_TITLE       4 /* Title text.  */
+ #define NT_VMS_EIDC        5 /* Entity ident consistency check.  */
+ #define NT_VMS_FPMODE      6 /* Whole program floating-point mode.  */
+ #define NT_VMS_LINKTIME  101 /* Date/time image was linked.  */
+ #define NT_VMS_IMGNAM    102 /* Image name string.  */
+ #define NT_VMS_IMGID     103 /* Image ident string.  */
+ #define NT_VMS_LINKID    104 /* Linker ident string.  */
+ #define NT_VMS_IMGBID    105 /* Image build ident string.  */
+ #define NT_VMS_GSTNAM    106 /* Global Symbol Table Name.  */
+ #define NT_VMS_ORIG_DYN  107 /* Original setting of dynamic data.  */
+ #define NT_VMS_PATCHTIME 108 /* Date/time of last patch.  */
+ 
  /* IA64-specific relocation types: */
  
  /* Relocs apply to specific instructions within a bundle.  The least


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