Add support for the MIPS32
[deliverable/binutils-gdb.git] / binutils / readelf.c
index 152ce1e937f81a44c0a083888436e80808810806..d9686731fda9d630e793e2bb1a1e88db9e5fbe97 100644 (file)
@@ -70,6 +70,9 @@
 #include "elf/i960.h"
 #include "elf/pj.h"
 #include "elf/avr.h"
+#include "elf/ia64.h"
+#include "elf/cris.h"
+#include "elf/i860.h"
 
 #include "bucomm.h"
 #include "getopt.h"
@@ -562,6 +565,10 @@ guess_is_rela (e_machine)
     case EM_SH:
     case EM_ALPHA:
     case EM_MCORE:
+    case EM_IA_64:
+    case EM_AVR:
+    case EM_CRIS:
+    case EM_860:
       return TRUE;
 
     case EM_MMA:
@@ -873,6 +880,17 @@ dump_relocations (file, rel_offset, rel_size, symtab, nsyms, strtab, is_rela)
        case EM_PJ:
          rtype = elf_pj_reloc_type (type);
          break;
+       case EM_IA_64:
+         rtype = elf_ia64_reloc_type (type);
+         break;
+
+       case EM_CRIS:
+         rtype = elf_cris_reloc_type (type);
+         break;
+
+       case EM_860:
+         rtype = elf_i860_reloc_type (type);
+         break;
        }
 
       if (rtype == NULL)
@@ -1064,15 +1082,21 @@ get_dynamic_type (type)
     case DT_PREINIT_ARRAY: return "PREINIT_ARRAY";
     case DT_PREINIT_ARRAYSZ: return "PREINIT_ARRAYSZ";
 
+    case DT_CHECKSUM:  return "CHECKSUM";
     case DT_PLTPADSZ:  return "PLTPADSZ";
     case DT_MOVEENT:   return "MOVEENT";
     case DT_MOVESZ:    return "MOVESZ";
-    case DT_FEATURE_1: return "FEATURE_1";
+    case DT_FEATURE:   return "FEATURE";
     case DT_POSFLAG_1: return "POSFLAG_1";
     case DT_SYMINSZ:   return "SYMINSZ";
     case DT_SYMINENT:  return "SYMINENT"; /* aka VALRNGHI */
 
     case DT_ADDRRNGLO:  return "ADDRRNGLO";
+    case DT_CONFIG:    return "CONFIG";
+    case DT_DEPAUDIT:  return "DEPAUDIT";
+    case DT_AUDIT:     return "AUDIT";
+    case DT_PLTPAD:    return "PLTPAD";
+    case DT_MOVETAB:   return "MOVETAB";
     case DT_SYMINFO:   return "SYMINFO"; /* aka ADDRRNGHI */
 
     case DT_VERSYM:    return "VERSYM";
@@ -1085,7 +1109,7 @@ get_dynamic_type (type)
     case DT_VERNEED:   return "VERNEED";
     case DT_VERNEEDNUM:        return "VERNEEDNUM";
 
-    case DT_AUXILIARY: return "AUXILARY";
+    case DT_AUXILIARY: return "AUXILIARY";
     case DT_USED:      return "USED";
     case DT_FILTER:    return "FILTER";
 
@@ -1235,7 +1259,8 @@ get_machine_name (e_machine)
     case EM_SVX:               return "Silicon Graphics SVx";
     case EM_ST19:              return "STMicroelectronics ST19 8-bit microcontroller";
     case EM_VAX:               return "Digital VAX";
-    case EM_AVR:                return "AVR";
+    case EM_AVR:                return "Atmel AVR 8-bit microcontroller";
+    case EM_CRIS:              return "Axis Communications 32-bit embedded processor";
     default:
       sprintf (buff, _("<unknown>: %x"), e_machine);
       return buff;
@@ -1436,6 +1461,16 @@ get_machine_flags (e_flags, e_machine)
 
          if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_4)
            strcat (buf, ", mips4");
+
+         switch ((e_flags & EF_MIPS_MACH))
+           {
+           case E_MIPS_MACH_3900: strcat (buf, ", 3900"); break;
+           case E_MIPS_MACH_4010: strcat (buf, ", 4010"); break;
+           case E_MIPS_MACH_4100: strcat (buf, ", 4100"); break;
+           case E_MIPS_MACH_4650: strcat (buf, ", 4650"); break;
+           case E_MIPS_MACH_4111: strcat (buf, ", 4111"); break;
+           case E_MIPS_MACH_MIPS32: strcat (buf, ", mips32"); break;
+           }
          break;
 
        case EM_SPARCV9:
@@ -2046,9 +2081,18 @@ get_osabi_name (osabi)
 
   switch (osabi)
     {
-    case ELFOSABI_SYSV:       return _("UNIX - System V");
+    case ELFOSABI_NONE:       return _("UNIX - System V");
     case ELFOSABI_HPUX:       return _("UNIX - HP-UX");
+    case ELFOSABI_NETBSD:     return _("UNIX - NetBSD");
     case ELFOSABI_LINUX:      return _("UNIX - Linux");
+    case ELFOSABI_HURD:       return _("GNU/Hurd");
+    case ELFOSABI_SOLARIS:    return _("UNIX - Solaris");
+    case ELFOSABI_MONTEREY:   return _("UNIX - Monterey");
+    case ELFOSABI_IRIX:       return _("UNIX - IRIX");
+    case ELFOSABI_FREEBSD:    return _("UNIX - FreeBSD");
+    case ELFOSABI_TRU64:      return _("UNIX - TRU64");
+    case ELFOSABI_MODESTO:    return _("Novell - Modesto");
+    case ELFOSABI_OPENBSD:    return _("UNIX - OpenBSD");
     case ELFOSABI_STANDALONE: return _("Standalone App");
     case ELFOSABI_ARM:        return _("ARM");
     default:
@@ -3308,12 +3352,33 @@ process_dynamic_segment (file)
          
        case DT_AUXILIARY:
        case DT_FILTER:
+       case DT_CONFIG:
+       case DT_DEPAUDIT:
+       case DT_AUDIT:
          if (do_dynamic)
            {
-             if (entry->d_tag == DT_AUXILIARY)
-               printf (_("Auxiliary library"));
-             else
-               printf (_("Filter library"));
+             switch (entry->d_tag)
+               {
+               case DT_AUXILIARY:
+                 printf (_("Auxiliary library"));
+                 break;
+
+               case DT_FILTER:
+                 printf (_("Filter library"));
+                 break;
+
+               case DT_CONFIG:
+                 printf (_("Configuration file"));
+                 break;
+
+               case DT_DEPAUDIT:
+                 printf (_("Dependency audit library"));
+                 break;
+
+               case DT_AUDIT:
+                 printf (_("Audit library"));
+                 break;
+               }
 
              if (dynamic_strings)
                printf (": [%s]\n", dynamic_strings + entry->d_un.d_val);
@@ -3326,7 +3391,7 @@ process_dynamic_segment (file)
            }
          break;
 
-       case DT_FEATURE_1:
+       case DT_FEATURE:
          if (do_dynamic)
            {
              printf (_("Flags:"));
@@ -3340,6 +3405,11 @@ process_dynamic_segment (file)
                      printf (" PARINIT");
                      val ^= DTF_1_PARINIT;
                    }
+                 if (val & DTF_1_CONFEXP)
+                   {
+                     printf (" CONFEXP");
+                     val ^= DTF_1_CONFEXP;
+                   }
                  if (val != 0)
                    printf (" %lx", val);
                  puts ("");
@@ -3437,6 +3507,21 @@ process_dynamic_segment (file)
                      printf (" INTERPOSE");
                      val ^= DF_1_INTERPOSE;
                    }
+                 if (val & DF_1_NODEFLIB)
+                   {
+                     printf (" NODEFLIB");
+                     val ^= DF_1_NODEFLIB;
+                   }
+                 if (val & DF_1_NODUMP)
+                   {
+                     printf (" NODUMP");
+                     val ^= DF_1_NODUMP;
+                   }
+                 if (val & DF_1_CONLFAT)
+                   {
+                     printf (" CONLFAT");
+                     val ^= DF_1_CONLFAT;
+                   }
                  if (val != 0)
                    printf (" %lx", val);
                  puts ("");
@@ -3465,6 +3550,7 @@ process_dynamic_segment (file)
        case DT_DEBUG   :
        case DT_TEXTREL :
        case DT_JMPREL  :
+       case DT_RUNPATH :
          dynamic_info[entry->d_tag] = entry->d_un.d_val;
 
          if (do_dynamic)
@@ -3495,6 +3581,10 @@ process_dynamic_segment (file)
                      printf (_("Library rpath: [%s]"), name);
                      break;
 
+                   case DT_RUNPATH:
+                     printf (_("Library runpath: [%s]"), name);
+                     break;
+
                    default:
                      print_vma (entry->d_un.d_val, PREFIX_HEX);
                      break;
@@ -4215,10 +4305,10 @@ get_dynamic_data (file, number)
      FILE *       file;
      unsigned int number;
 {
-  char * e_data;
+  unsigned char * e_data;
   int *  i_data;
 
-  e_data = (char *) malloc (number * 4);
+  e_data = (unsigned char *) malloc (number * 4);
 
   if (e_data == NULL)
     {
@@ -4255,8 +4345,8 @@ process_symbol_table (file)
      FILE * file;
 {
   Elf32_Internal_Shdr *   section;
-  char   nb [4];
-  char   nc [4];
+  unsigned char   nb [4];
+  unsigned char   nc [4];
   int    nbuckets = 0;
   int    nchains = 0;
   int *  buckets = NULL;
@@ -4870,7 +4960,7 @@ process_extended_line_op (data, is_stmt, pointer_size)
 
       printf (_("   %d\t"), ++ state_machine_regs.last_file_entry);
       name = data;
-      data += strlen (data) + 1;
+      data += strlen ((char *) data) + 1;
       printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
       data += bytes_read;
       printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
@@ -4975,7 +5065,7 @@ display_debug_lines (section, start, file)
            {
              printf (_("  %s\n"), data);
 
-             data += strlen (data) + 1;
+             data += strlen ((char *) data) + 1;
            }
        }
 
@@ -4992,13 +5082,13 @@ display_debug_lines (section, start, file)
 
          while (* data != 0)
            {
-             char * name;
+             unsigned char * name;
              int bytes_read;
 
              printf (_("  %d\t"), ++ state_machine_regs.last_file_entry);
              name = data;
 
-             data += strlen (data) + 1;
+             data += strlen ((char *) data) + 1;
 
              printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
              data += bytes_read;
@@ -5145,7 +5235,14 @@ display_debug_pubnames (section, start, file)
 
       if (pubnames.pn_version != 2)
        {
-         warn (_("Only DWARF 2 pubnames are currently supported"));
+         static int warned = 0;
+
+         if (! warned)
+           {
+             warn (_("Only DWARF 2 pubnames are currently supported\n"));
+             warned = 1;
+           }
+         
          continue;
        }
 
@@ -5168,7 +5265,7 @@ display_debug_pubnames (section, start, file)
            {
              data += 4;
              printf ("    %ld\t\t%s\n", offset, data);
-             data += strlen (data) + 1;
+             data += strlen ((char *) data) + 1;
            }
        }
       while (offset != 0);
@@ -5919,6 +6016,9 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
 
   switch (form)
     {
+    default:
+      break;
+      
     case DW_FORM_ref_addr:
     case DW_FORM_addr:
       uvalue = byte_get (data, pointer_size);
@@ -5990,7 +6090,7 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
 
     case DW_FORM_string:
       printf (" %s", data);
-      data += strlen (data) + 1;
+      data += strlen ((char *) data) + 1;
       break;
 
     case DW_FORM_block:
@@ -6314,6 +6414,12 @@ display_debug_aranges (section, start, file)
       arange.ar_pointer_size = BYTE_GET (external->ar_pointer_size);
       arange.ar_segment_size = BYTE_GET (external->ar_segment_size);
 
+      if (arange.ar_version != 2)
+       {
+         warn (_("Only DWARF 2 aranges are currently supported.\n"));
+         break;
+       }
+
       printf (_("  Length:                   %ld\n"), arange.ar_length);
       printf (_("  Version:                  %d\n"), arange.ar_version);
       printf (_("  Offset into .debug_info:  %lx\n"), arange.ar_info_offset);
This page took 0.030334 seconds and 4 git commands to generate.