Nick Clifton 283a7e
--- binutils.orig/binutils/readelf.c	2017-07-24 15:27:09.859116315 +0100
Nick Clifton 283a7e
+++ binutils-2.29/binutils/readelf.c	2017-07-24 15:30:33.557770525 +0100
Nick Clifton 283a7e
@@ -18414,39 +18414,49 @@ process_archive (char * file_name, FILE
Nick Clifton 283a7e
 static bfd_boolean
Nick Clifton 4ae66c
 process_file (char * file_name)
Nick Clifton 4ae66c
 {
Nick Clifton 4ae66c
+  char * name;
Nick Clifton 4ae66c
+  char * saved_program_name;
Nick Clifton 4ae66c
   FILE * file;
Nick Clifton 4ae66c
   struct stat statbuf;
Nick Clifton 4ae66c
   char armag[SARMAG];
Nick Clifton 283a7e
   bfd_boolean ret = TRUE;
Nick Clifton 283a7e
 
Nick Clifton 4ae66c
+  /* Overload program_name to include file_name.  Doing this means
Nick Clifton 4ae66c
+     that warning/error messages will positively identify the file
Nick Clifton 4ae66c
+     concerned even when multiple instances of readelf are running.  */
Nick Clifton 4ae66c
+  name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
Nick Clifton 4ae66c
+  sprintf (name, "%s: %s", program_name, file_name);
Nick Clifton 4ae66c
+  saved_program_name = program_name;
Nick Clifton 4ae66c
+  program_name = name;
Nick Clifton 283a7e
+
Nick Clifton 4ae66c
   if (stat (file_name, &statbuf) < 0)
Nick Clifton 4ae66c
     {
Nick Clifton 4ae66c
       if (errno == ENOENT)
Nick Clifton 4ae66c
-	error (_("'%s': No such file\n"), file_name);
Nick Clifton 4ae66c
+	error (_("No such file\n"));
Nick Clifton 4ae66c
       else
Nick Clifton 4ae66c
-	error (_("Could not locate '%s'.  System error message: %s\n"),
Nick Clifton 4ae66c
-	       file_name, strerror (errno));
Nick Clifton 283a7e
-      return FALSE;
Nick Clifton 4ae66c
+	error (_("Could not locate file.  System error message: %s\n"),
Nick Clifton 4ae66c
+	       strerror (errno));
Nick Clifton 4ae66c
+      goto done;
Nick Clifton 4ae66c
     }
Nick Clifton 4ae66c
 
Nick Clifton 4ae66c
   if (! S_ISREG (statbuf.st_mode))
Nick Clifton 4ae66c
     {
Nick Clifton 4ae66c
-      error (_("'%s' is not an ordinary file\n"), file_name);
Nick Clifton 283a7e
-      return FALSE;
Nick Clifton 4ae66c
+      error (_("Not an ordinary file\n"));
Nick Clifton 4ae66c
+      goto done;
Nick Clifton 4ae66c
     }
Nick Clifton 4ae66c
 
Nick Clifton 4ae66c
   file = fopen (file_name, "rb");
Nick Clifton 4ae66c
   if (file == NULL)
Nick Clifton 4ae66c
     {
Nick Clifton 4ae66c
-      error (_("Input file '%s' is not readable.\n"), file_name);
Nick Clifton 283a7e
-      return FALSE;
Nick Clifton 4ae66c
+      error (_("Not readable\n"));
Nick Clifton 4ae66c
+      goto done;
Nick Clifton 4ae66c
     }
Nick Clifton 4ae66c
 
Nick Clifton 4ae66c
   if (fread (armag, SARMAG, 1, file) != 1)
Nick Clifton 4ae66c
     {
Nick Clifton 4ae66c
-      error (_("%s: Failed to read file's magic number\n"), file_name);
Nick Clifton 4ae66c
+      error (_("Failed to read file's magic number\n"));
Nick Clifton 4ae66c
       fclose (file);
Nick Clifton 283a7e
-      return FALSE;
Nick Clifton 4ae66c
+      goto done;
Nick Clifton 4ae66c
     }
Nick Clifton 4ae66c
 
Nick Clifton 4ae66c
   current_file_size = (bfd_size_type) statbuf.st_size;
Nick Clifton 283a7e
@@ -18474,7 +18484,10 @@ process_file (char * file_name)
Nick Clifton 283a7e
     }
Nick Clifton 4ae66c
 
Nick Clifton 4ae66c
   fclose (file);
Nick Clifton 4ae66c
+ done:
Nick Clifton 4ae66c
   current_file_size = 0;
Nick Clifton 4ae66c
+  free (program_name);
Nick Clifton 4ae66c
+  program_name = saved_program_name;
Nick Clifton 283a7e
 
Nick Clifton 4ae66c
   return ret;
Nick Clifton 4ae66c
 }