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]

Re: [patch] print additional mips elf 64 reloc type info in readelf


--- Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de> wrote:
> Timothy Daly wrote:
> [snip]
> > @@ -1071,8 +1094,14 @@ dump_relocations (file, rel_offset, rel_
> >  #else
> >   printf (_("unrecognised: %-7lx"), type);

[sniply]

> Is better to print also the "unrecognised" string for rtype[23] ==
> NULL.

Good point.  Modified patch below (and attached).  

A couple of thoughts:  

"Unrecognised" is actually spelled with a 'z'.  I didn't want to
change the spelling, for fear that translations might disappear.  

It seems as though the _bfd_int64_low stuff shouldn't be necessary -
rtype[23] only have 8 meaningful bits.  But I don't think it's
hurting anything. :)

-Tim


Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.151
diff -u -p -r1.151 readelf.c
--- readelf.c 2002/02/13 18:14:42 1.151
+++ readelf.c 2002/02/18 00:26:15
@@ -851,6 +851,15 @@ dump_relocations (file, rel_offset, rel_
  printf
    (_(" Offset     Info    Type            Symbol's Value  Symbol's
Name\n"));
     }
+  else if (elf_header.e_machine == EM_MIPS) 
+    {
+      if (is_rela)
+ printf
+   (_("    Offset             Info            Type              
Type2              Type3              Symbol's Value   Symbol's Name 
         Addend\n"));
+      else
+ printf
+   (_("    Offset             Info            Type              
Type2              Type3              Symbol's Value   Symbol's
Name\n"));
+    }
   else
     {
       if (is_rela)
@@ -864,10 +873,14 @@ dump_relocations (file, rel_offset, rel_
   for (i = 0; i < rel_size; i++)
     {
       const char * rtype;
+      const char * rtype2 = NULL;
+      const char * rtype3 = NULL;
       bfd_vma      offset;
       bfd_vma      info;
       bfd_vma      symtab_index;
       bfd_vma      type;
+      bfd_vma      type2 = NULL;
+      bfd_vma      type3 = NULL;
 
       if (is_rela)
  {
@@ -889,6 +902,12 @@ dump_relocations (file, rel_offset, rel_
  {
    if (elf_header.e_machine == EM_SPARCV9)
      type       = ELF64_R_TYPE_ID (info);
+   else if (elf_header.e_machine == EM_MIPS) 
+     {
+       type = ELF64_MIPS_R_TYPE (info);
+       type2 = ELF64_MIPS_R_TYPE2 (info);
+       type3 = ELF64_MIPS_R_TYPE3 (info);
+     }
    else
      type       = ELF64_R_TYPE (info);
    /* The #ifdef BFD64 below is to prevent a compile time warning.
@@ -1006,6 +1025,10 @@ dump_relocations (file, rel_offset, rel_
  case EM_MIPS:
  case EM_MIPS_RS3_LE:
    rtype = elf_mips_reloc_type (type);
+   if (!is_32bit_elf) {
+     rtype2 = elf_mips_reloc_type (type2);
+     rtype3 = elf_mips_reloc_type (type3);
+   }
    break;
 
  case EM_ALPHA:
@@ -1073,6 +1096,27 @@ dump_relocations (file, rel_offset, rel_
 #endif
       else
  printf ("%-21.21s", rtype);
+
+      if (!is_32bit_elf && elf_header.e_machine == EM_MIPS) 
+ {
+   if (rtype2 == NULL)
+#ifdef _bfd_int64_low
+     printf (_("unrecognised: %-7lx"), _bfd_int64_low (type2));
+#else
+     printf (_("unrecognised: %-7lx"), type2);
+#endif
+   else
+     printf ("%-21.21s", rtype2);
+
+   if (rtype3 == NULL)
+#ifdef _bfd_int64_low
+     printf (_("unrecognised: %-7lx"), _bfd_int64_low (type3));
+#else
+     printf (_("unrecognised: %-7lx"), type3);
+#endif
+   else
+     printf ("%-21.21s", rtype3);
+ }
 
       if (symtab_index)
  {






__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.151
diff -u -p -r1.151 readelf.c
--- readelf.c	2002/02/13 18:14:42	1.151
+++ readelf.c	2002/02/18 00:26:15
@@ -851,6 +851,15 @@ dump_relocations (file, rel_offset, rel_
 	printf
 	  (_(" Offset     Info    Type            Symbol's Value  Symbol's Name\n"));
     }
+  else if (elf_header.e_machine == EM_MIPS) 
+    {
+      if (is_rela)
+	printf
+	  (_("    Offset             Info            Type               Type2              Type3              Symbol's Value   Symbol's Name           Addend\n"));
+      else
+	printf
+	  (_("    Offset             Info            Type               Type2              Type3              Symbol's Value   Symbol's Name\n"));
+    }
   else
     {
       if (is_rela)
@@ -864,10 +873,14 @@ dump_relocations (file, rel_offset, rel_
   for (i = 0; i < rel_size; i++)
     {
       const char * rtype;
+      const char * rtype2 = NULL;
+      const char * rtype3 = NULL;
       bfd_vma      offset;
       bfd_vma      info;
       bfd_vma      symtab_index;
       bfd_vma      type;
+      bfd_vma      type2 = NULL;
+      bfd_vma      type3 = NULL;
 
       if (is_rela)
 	{
@@ -889,6 +902,12 @@ dump_relocations (file, rel_offset, rel_
 	{
 	  if (elf_header.e_machine == EM_SPARCV9)
 	    type       = ELF64_R_TYPE_ID (info);
+	  else if (elf_header.e_machine == EM_MIPS) 
+	    {
+	      type = ELF64_MIPS_R_TYPE (info);
+	      type2 = ELF64_MIPS_R_TYPE2 (info);
+	      type3 = ELF64_MIPS_R_TYPE3 (info);
+	    }
 	  else
 	    type       = ELF64_R_TYPE (info);
 	  /* The #ifdef BFD64 below is to prevent a compile time warning.
@@ -1006,6 +1025,10 @@ dump_relocations (file, rel_offset, rel_
 	case EM_MIPS:
 	case EM_MIPS_RS3_LE:
 	  rtype = elf_mips_reloc_type (type);
+	  if (!is_32bit_elf) {
+	    rtype2 = elf_mips_reloc_type (type2);
+	    rtype3 = elf_mips_reloc_type (type3);
+	  }
 	  break;
 
 	case EM_ALPHA:
@@ -1073,6 +1096,27 @@ dump_relocations (file, rel_offset, rel_
 #endif
       else
 	printf ("%-21.21s", rtype);
+
+      if (!is_32bit_elf && elf_header.e_machine == EM_MIPS) 
+	{
+	  if (rtype2 == NULL)
+#ifdef _bfd_int64_low
+	    printf (_("unrecognised: %-7lx"), _bfd_int64_low (type2));
+#else
+	    printf (_("unrecognised: %-7lx"), type2);
+#endif
+	  else
+	    printf ("%-21.21s", rtype2);
+
+	  if (rtype3 == NULL)
+#ifdef _bfd_int64_low
+	    printf (_("unrecognised: %-7lx"), _bfd_int64_low (type3));
+#else
+	    printf (_("unrecognised: %-7lx"), type3);
+#endif
+	  else
+	    printf ("%-21.21s", rtype3);
+	}
 
       if (symtab_index)
 	{

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