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

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