Blame SOURCES/binutils-2.29-filename-in-error-messages.patch

8c00d6
--- binutils.orig/binutils/readelf.c	2018-01-22 15:48:10.450701702 +0000
8c00d6
+++ binutils-2.30.0/binutils/readelf.c	2018-01-22 15:55:26.739588657 +0000
8c00d6
@@ -19019,75 +19019,85 @@ process_file (char * file_name)
8c00d6
   Filedata * filedata = NULL;
8c00d6
   struct stat statbuf;
8c00d6
   char armag[SARMAG];
8c00d6
-  bfd_boolean ret = TRUE;
8c00d6
+  bfd_boolean ret = FALSE;
8c00d6
+  char * name;
8c00d6
+  char * saved_program_name;
8c00d6
+
8c00d6
+  /* Overload program_name to include file_name.  Doing this means
8c00d6
+     that warning/error messages will positively identify the file
8c00d6
+     concerned even when multiple instances of readelf are running.  */
8c00d6
+  name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
8c00d6
+  sprintf (name, "%s: %s", program_name, file_name);
8c00d6
+  saved_program_name = program_name;
8c00d6
+  program_name = name;
8c00d6
 
8c00d6
   if (stat (file_name, &statbuf) < 0)
8c00d6
     {
8c00d6
       if (errno == ENOENT)
8c00d6
-	error (_("'%s': No such file\n"), file_name);
8c00d6
+	error (_("No such file\n"));
8c00d6
       else
8c00d6
-	error (_("Could not locate '%s'.  System error message: %s\n"),
8c00d6
-	       file_name, strerror (errno));
8c00d6
-      return FALSE;
8c00d6
+	error (_("Could not locate file.  System error message: %s\n"),
8c00d6
+	       strerror (errno));
8c00d6
+      goto done;
8c00d6
     }
8c00d6
 
8c00d6
   if (! S_ISREG (statbuf.st_mode))
8c00d6
     {
8c00d6
-      error (_("'%s' is not an ordinary file\n"), file_name);
8c00d6
-      return FALSE;
8c00d6
+      error (_("Not an ordinary file\n"));
8c00d6
+      goto done;
8c00d6
     }
8c00d6
 
8c00d6
   filedata = calloc (1, sizeof * filedata);
8c00d6
   if (filedata == NULL)
8c00d6
     {
8c00d6
       error (_("Out of memory allocating file data structure\n"));
8c00d6
-      return FALSE;
8c00d6
+      goto done;
8c00d6
     }
8c00d6
 
8c00d6
   filedata->file_name = file_name;
8c00d6
   filedata->handle = fopen (file_name, "rb");
8c00d6
   if (filedata->handle == NULL)
8c00d6
     {
8c00d6
-      error (_("Input file '%s' is not readable.\n"), file_name);
8c00d6
-      free (filedata);
8c00d6
-      return FALSE;
8c00d6
+      error (_("Not readable\n"));
8c00d6
+      goto done;
8c00d6
     }
8c00d6
 
8c00d6
   if (fread (armag, SARMAG, 1, filedata->handle) != 1)
8c00d6
     {
8c00d6
-      error (_("%s: Failed to read file's magic number\n"), file_name);
8c00d6
-      fclose (filedata->handle);
8c00d6
-      free (filedata);
8c00d6
-      return FALSE;
8c00d6
-    }
8c00d6
-
8c00d6
-  filedata->file_size = (bfd_size_type) statbuf.st_size;
8c00d6
-
8c00d6
-  if (memcmp (armag, ARMAG, SARMAG) == 0)
8c00d6
-    {
8c00d6
-      if (! process_archive (filedata, FALSE))
8c00d6
-	ret = FALSE;
8c00d6
-    }
8c00d6
-  else if (memcmp (armag, ARMAGT, SARMAG) == 0)
8c00d6
-    {
8c00d6
-      if ( ! process_archive (filedata, TRUE))
8c00d6
-	ret = FALSE;
8c00d6
+      error (_("Failed to read file's magic number\n"));
8c00d6
     }
8c00d6
   else
8c00d6
     {
8c00d6
-      if (do_archive_index)
8c00d6
-	error (_("File %s is not an archive so its index cannot be displayed.\n"),
8c00d6
-	       file_name);
8c00d6
+      filedata->file_size = (bfd_size_type) statbuf.st_size;
8c00d6
 
8c00d6
-      rewind (filedata->handle);
8c00d6
-      archive_file_size = archive_file_offset = 0;
8c00d6
-
8c00d6
-      if (! process_object (filedata))
8c00d6
-	ret = FALSE;
8c00d6
+      if (memcmp (armag, ARMAG, SARMAG) == 0)
8c00d6
+	{
8c00d6
+	  if (process_archive (filedata, FALSE))
8c00d6
+	    ret = TRUE;
8c00d6
+	}
8c00d6
+      else if (memcmp (armag, ARMAGT, SARMAG) == 0)
8c00d6
+	{
8c00d6
+	  if (process_archive (filedata, TRUE))
8c00d6
+	    ret = TRUE;
8c00d6
+	}
8c00d6
+      else
8c00d6
+	{
8c00d6
+	  if (do_archive_index)
8c00d6
+	    error (_("Not an archive so its index cannot be displayed.\n"));
8c00d6
+
8c00d6
+	  rewind (filedata->handle);
8c00d6
+	  archive_file_size = archive_file_offset = 0;
8c00d6
+
8c00d6
+	  if (process_object (filedata))
8c00d6
+	    ret = TRUE;
8c00d6
+	}
8c00d6
     }
8c00d6
 
8c00d6
   fclose (filedata->handle);
8c00d6
+ done:
8c00d6
   free (filedata);
8c00d6
+  free (program_name);
8c00d6
+  program_name = saved_program_name;
8c00d6
 
8c00d6
   return ret;
8c00d6
 }