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

[PATCH] Support prelink sections and dynamic tags in readelf


Hi!

The following tag adds printing of SHT_GNU_LIBLIST sections
and handles prelink dynamic tags.
Ok to commit?

2002-07-02  Jakub Jelinek  <jakub@redhat.com>

	* readelf.c (get_dynamic_type): Handle DT_GNU_PRELINKED,
	DT_GNU_CONFLICT* and DT_GNU_LIBLISZ*.
	(get_section_type_name): Handle SHT_GNU_LIBLIST.
	(process_dynamic_segment): Handle DT_GNU_CONFLICTSZ,
	DT_GNU_LIBLISTSZ and DT_GNU_PRELINKED.
	(process_gnu_liblist): New.
	(process_file): Call it.

	* elf/common.h (SHT_GNU_LIBLIST, DT_GNU_PRELINKED,
	DT_GNU_CONFLICT*, DT_GNU_LIBLIST*): Define.

--- binutils/readelf.c.jj	Mon Jul  1 14:28:15 2002
+++ binutils/readelf.c	Tue Jul  2 13:25:14 2002
@@ -263,6 +263,7 @@ static int		  process_corefile_note_segm
 static int		  process_corefile_note_segments PARAMS ((FILE *));
 static int		  process_corefile_contents	 PARAMS ((FILE *));
 static int		  process_arch_specific		 PARAMS ((FILE *));
+static int		  process_gnu_liblist		 PARAMS ((FILE *));
 
 typedef int Elf32_Word;
 
@@ -524,7 +525,7 @@ print_vma (vma, mode)
 
 /* Display a symbol on stdout.  If do_wide is not true then
    format the symbol to be at most WIDTH characters,
-   truhncating as necessary.  If WIDTH is negative then
+   truncating as necessary.  If WIDTH is negative then
    format the string to be exactly - WIDTH characters,
    truncating or padding as necessary.  */
 
@@ -1383,6 +1384,12 @@ get_dynamic_type (type)
     case DT_USED:	return "USED";
     case DT_FILTER:	return "FILTER";
 
+    case DT_GNU_PRELINKED: return "GNU_PRELINKED";
+    case DT_GNU_CONFLICT: return "GNU_CONFLICT";
+    case DT_GNU_CONFLICTSZ: return "GNU_CONFLICTSZ";
+    case DT_GNU_LIBLIST: return "GNU_LIBLIST";
+    case DT_GNU_LIBLISTSZ: return "GNU_LIBLISTSZ";
+
     default:
       if ((type >= DT_LOPROC) && (type <= DT_HIPROC))
 	{
@@ -2180,6 +2187,7 @@ get_section_type_name (sh_type)
     case 0x6ffffffc:	        return "VERDEF";
     case 0x7ffffffd:		return "AUXILIARY";
     case 0x7fffffff:		return "FILTER";
+    case SHT_GNU_LIBLIST:	return "GNU_LIBLIST";
 
     default:
       if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC))
@@ -4741,6 +4749,8 @@ process_dynamic_segment (file)
 	case DT_MOVESZ	:
 	case DT_INIT_ARRAYSZ:
 	case DT_FINI_ARRAYSZ:
+	case DT_GNU_CONFLICTSZ:
+	case DT_GNU_LIBLISTSZ:
 	  if (do_dynamic)
 	    {
 	      print_vma (entry->d_un.d_val, UNSIGNED);
@@ -4789,6 +4799,20 @@ process_dynamic_segment (file)
 	  /* The value of this entry is ignored.  */
 	  break;
 
+	case DT_GNU_PRELINKED:
+	  if (do_dynamic)
+	    {
+	      struct tm * tmp;
+	      time_t time = entry->d_un.d_val;
+
+	      tmp = gmtime (&time);
+	      printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
+		      tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
+		      tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+
+	    }
+	  break;
+
 	default:
 	  if ((entry->d_tag >= DT_VERSYM) && (entry->d_tag <= DT_VERNEEDNUM))
 	    version_info [DT_VERSIONTAGIDX (entry->d_tag)] =
@@ -9355,6 +9379,86 @@ process_mips_specific (file)
   return 1;
 }
 
+static int
+process_gnu_liblist (file)
+     FILE * file;
+{
+  Elf_Internal_Shdr * section, * string_sec;
+  Elf32_External_Lib * elib;
+  char * strtab;
+  size_t cnt;
+  unsigned i;
+
+  if (! do_arch)
+    return 0;
+
+  for (i = 0, section = section_headers;
+       i < elf_header.e_shnum;
+       i++, section ++)
+    {
+      switch (section->sh_type)
+	{
+	case SHT_GNU_LIBLIST:
+	  elib = ((Elf32_External_Lib *)
+		 get_data (NULL, file, section->sh_offset, section->sh_size,
+			   _("liblist")));
+
+	  if (elib == NULL)
+	    break;
+	  string_sec = SECTION_HEADER (section->sh_link);
+
+	  strtab = (char *) get_data (NULL, file, string_sec->sh_offset,
+				      string_sec->sh_size,
+				      _("liblist string table"));
+
+	  if (strtab == NULL
+	      || section->sh_entsize != sizeof (Elf32_External_Lib))
+	    {
+	      free (elib);
+	      break;
+	    }
+
+	  printf (_("\nLibrary list section '%s' contains %lu entries:\n"),
+		  SECTION_NAME (section),
+		  (long) (section->sh_size / sizeof (Elf32_External_Lib)));
+
+	  puts ("     Library              Time Stamp          Checksum   Version Flags");
+
+	  for (cnt = 0; cnt < section->sh_size / sizeof (Elf32_External_Lib);
+	       ++cnt)
+	    {
+	      Elf32_Lib liblist;
+	      time_t time;
+	      char timebuf[20];
+	      struct tm * tmp;
+
+	      liblist.l_name = BYTE_GET (elib[cnt].l_name);
+	      time = BYTE_GET (elib[cnt].l_time_stamp);
+	      liblist.l_checksum = BYTE_GET (elib[cnt].l_checksum);
+	      liblist.l_version = BYTE_GET (elib[cnt].l_version);
+	      liblist.l_flags = BYTE_GET (elib[cnt].l_flags);
+
+	      tmp = gmtime (&time);
+	      sprintf (timebuf, "%04u-%02u-%02uT%02u:%02u:%02u",
+		       tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
+		       tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+
+	      printf ("%3lu: ", (unsigned long) cnt);
+	      if (do_wide)
+		printf ("%-20s", strtab + liblist.l_name);
+	      else
+		printf ("%-20.20s", strtab + liblist.l_name);
+	      printf (" %s %#010lx %-7ld %-7ld\n", timebuf, liblist.l_checksum,
+		      liblist.l_version, liblist.l_flags);
+	    }
+
+	  free (elib);
+	}
+    }
+
+  return 1;
+}
+
 static const char *
 get_note_type (e_type)
      unsigned e_type;
@@ -9802,6 +9906,8 @@ process_file (file_name)
 
   process_corefile_contents (file);
 
+  process_gnu_liblist (file);
+
   process_arch_specific (file);
 
   fclose (file);
--- include/elf/common.h.jj	Mon Jul  1 14:28:20 2002
+++ include/elf/common.h	Tue Jul  2 12:02:50 2002
@@ -303,6 +303,8 @@ Foundation, Inc., 59 Temple Place - Suit
 #define SHT_LOOS        0x60000000      /* First of OS specific semantics */
 #define SHT_HIOS        0x6fffffff      /* Last of OS specific semantics */
 
+#define SHT_GNU_LIBLIST	0x6ffffff7	/* List of prelink dependencies */
+
 /* The next three section types are defined by Solaris, and are named
    SHT_SUNW*.  We use them in GNU code, so we also define SHT_GNU*
    versions.  */
@@ -520,6 +522,9 @@ Foundation, Inc., 59 Temple Place - Suit
    OS specific values.  This is a deliberate special case and we
    maintain it for backwards compatability.  */
 #define DT_VALRNGLO	0x6ffffd00
+#define DT_GNU_PRELINKED 0x6ffffdf5
+#define DT_GNU_CONFLICTSZ 0x6ffffdf6
+#define DT_GNU_LIBLISTSZ 0x6ffffdf7
 #define DT_CHECKSUM	0x6ffffdf8
 #define DT_PLTPADSZ	0x6ffffdf9
 #define DT_MOVEENT	0x6ffffdfa
@@ -531,6 +536,8 @@ Foundation, Inc., 59 Temple Place - Suit
 #define DT_VALRNGHI	0x6ffffdff
 
 #define DT_ADDRRNGLO	0x6ffffe00
+#define DT_GNU_CONFLICT	0x6ffffef8
+#define DT_GNU_LIBLIST	0x6ffffef9
 #define DT_CONFIG	0x6ffffefa
 #define DT_DEPAUDIT	0x6ffffefb
 #define DT_AUDIT	0x6ffffefc

	Jakub


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