Use consistent error messages for missing files.
[binutils-gdb.git] / binutils / readelf.c
index 9a881069d5ef166c76ed92606586774f9d475f43..9b8b12ee303619ef3be742a1dbae43a3aa4774b6 100644 (file)
@@ -310,7 +310,7 @@ byte_get_little_endian (unsigned char *field, int size)
       /* This is a special case, generated by the BYTE_GET8 macro.
         It means that we are loading an 8 byte value from a field
         in an external structure into an 8 byte value in a field
-        in an internal strcuture.  */
+        in an internal structure.  */
       return  ((bfd_vma) (field[0]))
        |    (((bfd_vma) (field[1])) << 8)
        |    (((bfd_vma) (field[2])) << 16)
@@ -536,7 +536,7 @@ byte_get_big_endian (unsigned char *field, int size)
       /* This is a special case, generated by the BYTE_GET8 macro.
         It means that we are loading an 8 byte value from a field
         in an external structure into an 8 byte value in a field
-        in an internal strcuture.  */
+        in an internal structure.  */
       return ((bfd_vma) (field[7]))
        |   (((bfd_vma) (field[6])) << 8)
        |   (((bfd_vma) (field[5])) << 16)
@@ -6055,7 +6055,7 @@ dump_section (Elf_Internal_Shdr *section, FILE *file)
 
   bytes = section->sh_size;
 
-  if (bytes == 0)
+  if (bytes == 0 || section->sh_type == SHT_NOBITS)
     {
       printf (_("\nSection '%s' has no data to dump.\n"),
              SECTION_NAME (section));
@@ -6115,7 +6115,7 @@ dump_section (Elf_Internal_Shdr *section, FILE *file)
       for (j = 0; j < lbytes; j++)
        {
          k = data[j];
-         if (k >= ' ' && k < 0x80)
+         if (k >= ' ' && k < 0x7f)
            printf ("%c", k);
          else
            printf (".");
@@ -6847,7 +6847,7 @@ get_FORM_name (unsigned long form)
     }
 }
 
-/* FIXME:  There are better and more effiecint ways to handle
+/* FIXME:  There are better and more efficient ways to handle
    these structures.  For now though, I just want something that
    is simple to implement.  */
 typedef struct abbrev_attr
@@ -7541,7 +7541,7 @@ display_debug_loc (Elf_Internal_Shdr *section,
          /* Normally, the lists in the debug_loc section are related to a
             given compilation unit, and thus, we would use the pointer size
             of that compilation unit.  However, since we are displaying it
-            seperately here, we either have to store pointer sizes of all
+            separately here, we either have to store pointer sizes of all
             compilation units, or assume they don't change.   We assume,
             like the debug_line display, that it doesn't change.  */
          begin = byte_get (start, debug_line_pointer_size);
@@ -7843,7 +7843,7 @@ read_and_display_attr_value (unsigned long attribute,
       break;
     }
 
-  /* For some attributes we can display futher information.  */
+  /* For some attributes we can display further information.  */
 
   printf ("\t");
 
@@ -10135,7 +10135,7 @@ get_file_header (FILE *file)
       /* If we have been compiled with sizeof (bfd_vma) == 4, then
         we will not be able to cope with the 64bit data found in
         64 ELF files.  Detect this now and abort before we start
-        overwritting things.  */
+        overwriting things.  */
       if (sizeof (bfd_vma) < 8)
        {
          error (_("This instance of readelf has been built without support for a\n\
@@ -10457,14 +10457,24 @@ process_file (char *file_name)
 
   if (stat (file_name, &statbuf) < 0)
     {
-      error (_("Cannot stat input file %s.\n"), file_name);
+      if (errno == ENOENT)
+       error (_("'%s': No such file\n"), file_name);
+      else
+       error (_("Could not locate '%s'.  System error message: %s\n"),
+              file_name, strerror (errno));
+      return 1;
+    }
+
+  if (! S_ISREG (statbuf.st_mode))
+    {
+      error (_("'%s' is not an ordinary file\n"), file_name);
       return 1;
     }
 
   file = fopen (file_name, "rb");
   if (file == NULL)
     {
-      error (_("Input file %s not found.\n"), file_name);
+      error (_("Input file '%s' is not readable.\n"), file_name);
       return 1;
     }