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

58725c
--- binutils-2.27.orig/binutils/readelf.c	2017-01-16 11:51:05.043922264 +0000
58725c
+++ binutils-2.27/binutils/readelf.c	2017-01-16 12:01:34.389053872 +0000
58725c
@@ -16733,39 +16733,49 @@ process_archive (char * file_name, FILE
58725c
 static int
58725c
 process_file (char * file_name)
58725c
 {
58725c
+  char * name;
58725c
+  char * saved_program_name;
58725c
   FILE * file;
58725c
   struct stat statbuf;
58725c
   char armag[SARMAG];
58725c
-  int ret;
58725c
+  int ret = 1;
58725c
+
58725c
+  /* Overload program_name to include file_name.  Doing this means
58725c
+     that warning/error messages will positively identify the file
58725c
+     concerned even when multiple instances of readelf are running.  */
58725c
+  name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
58725c
+  sprintf (name, "%s: %s", program_name, file_name);
58725c
+  saved_program_name = program_name;
58725c
+  program_name = name;
58725c
 
58725c
   if (stat (file_name, &statbuf) < 0)
58725c
     {
58725c
       if (errno == ENOENT)
58725c
-	error (_("'%s': No such file\n"), file_name);
58725c
+	error (_("No such file\n"));
58725c
       else
58725c
-	error (_("Could not locate '%s'.  System error message: %s\n"),
58725c
-	       file_name, strerror (errno));
58725c
-      return 1;
58725c
+	error (_("Could not locate file.  System error message: %s\n"),
58725c
+	       strerror (errno));
58725c
+      goto done;
58725c
     }
58725c
 
58725c
   if (! S_ISREG (statbuf.st_mode))
58725c
     {
58725c
-      error (_("'%s' is not an ordinary file\n"), file_name);
58725c
-      return 1;
58725c
+      error (_("Not an ordinary file\n"));
58725c
+      goto done;
58725c
     }
58725c
 
58725c
   file = fopen (file_name, "rb");
58725c
   if (file == NULL)
58725c
     {
58725c
-      error (_("Input file '%s' is not readable.\n"), file_name);
58725c
-      return 1;
58725c
+      error (_("Not readable\n"));
58725c
+      goto done;
58725c
     }
58725c
 
58725c
   if (fread (armag, SARMAG, 1, file) != 1)
58725c
     {
58725c
-      error (_("%s: Failed to read file's magic number\n"), file_name);
58725c
+      error (_("Failed to read file's magic number\n"));
58725c
       fclose (file);
58725c
-      return 1;
58725c
+      goto done;
58725c
     }
58725c
 
58725c
   current_file_size = (bfd_size_type) statbuf.st_size;
58725c
@@ -16777,8 +16787,7 @@ process_file (char * file_name)
58725c
   else
58725c
     {
58725c
       if (do_archive_index)
58725c
-	error (_("File %s is not an archive so its index cannot be displayed.\n"),
58725c
-	       file_name);
58725c
+	error (_("Not an archive so its index cannot be displayed\n"));
58725c
 
58725c
       rewind (file);
58725c
       archive_file_size = archive_file_offset = 0;
58725c
@@ -16787,7 +16796,10 @@ process_file (char * file_name)
58725c
 
58725c
   fclose (file);
58725c
 
58725c
+ done:
58725c
   current_file_size = 0;
58725c
+  free (program_name);
58725c
+  program_name = saved_program_name;
58725c
   return ret;
58725c
 }
58725c