From 00e98fc7596ff93e1b30d012cecdf7f3025eaea1 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 31 Mar 2011 07:49:45 +0000 Subject: [PATCH] binutils/ 2011-03-31 Tristan Gingold * 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. include/elf 2011-03-31 Tristan Gingold * 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. --- binutils/ChangeLog | 8 +++ binutils/readelf.c | 159 +++++++++++++++++++++++++++++++++++++++--- include/elf/ChangeLog | 8 +++ include/elf/ia64.h | 24 +++++++ 4 files changed, 188 insertions(+), 11 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 2ffd99bc6c8..de657a456a2 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,11 @@ +2011-03-31 Tristan Gingold + + * 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-30 Catherine Moore * addr2line.c (translate_addresses): Sign extend the pc diff --git a/binutils/readelf.c b/binutils/readelf.c index 9b4f237f9f4..c3e5ffde94f 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -12048,6 +12048,117 @@ get_netbsd_elfcore_note_type (unsigned e_type) 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. @@ -12079,13 +12190,21 @@ process_note (Elf_Internal_Note * pnote) 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); + nt = get_note_type (pnote->type); - printf (" %s\t\t0x%08lx\t%s\n", name, pnote->descsz, nt); - return 1; + 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; } @@ -12116,14 +12235,32 @@ process_corefile_note_segment (FILE * file, bfd_vma offset, bfd_vma length) 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 (!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)) diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 182a59b33f8..e3685d85482 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,11 @@ +2011-03-31 Tristan Gingold + + * 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. + 2011-03-14 Richard Sandiford * arm.h (R_ARM_IRELATIVE): New relocation. diff --git a/include/elf/ia64.h b/include/elf/ia64.h index fb3d99f4008..5b621739426 100644 --- a/include/elf/ia64.h +++ b/include/elf/ia64.h @@ -232,6 +232,30 @@ typedef struct 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 -- 2.30.2