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

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