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

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