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

12f9d8
--- binutils.orig/binutils/readelf.c	2021-07-19 12:39:14.206556025 +0100
12f9d8
+++ binutils-2.37/binutils/readelf.c	2021-07-19 12:44:37.712728732 +0100
12f9d8
@@ -21873,45 +21873,52 @@ process_file (char * file_name)
12f9d8
   struct stat statbuf;
12f9d8
   char armag[SARMAG];
12f9d8
   bool ret = true;
12f9d8
+  char * name;
12f9d8
+  char * saved_program_name;
12f9d8
+
12f9d8
+  /* Overload program_name to include file_name.  Doing this means
12f9d8
+     that warning/error messages will positively identify the file
12f9d8
+     concerned even when multiple instances of readelf are running.  */
12f9d8
+  name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
12f9d8
+  sprintf (name, "%s: %s", program_name, file_name);
12f9d8
+  saved_program_name = program_name;
12f9d8
+  program_name = name;
12f9d8
 
12f9d8
   if (stat (file_name, &statbuf) < 0)
12f9d8
     {
12f9d8
       if (errno == ENOENT)
12f9d8
-	error (_("'%s': No such file\n"), file_name);
12f9d8
+	error (_("No such file\n"));
12f9d8
       else
12f9d8
-	error (_("Could not locate '%s'.  System error message: %s\n"),
12f9d8
-	       file_name, strerror (errno));
12f9d8
-      return false;
12f9d8
+	error (_("Could not locate file.  System error message: %s\n"),
12f9d8
+	       strerror (errno));
12f9d8
+      goto done;
12f9d8
     }
12f9d8
 
12f9d8
   if (! S_ISREG (statbuf.st_mode))
12f9d8
     {
12f9d8
-      error (_("'%s' is not an ordinary file\n"), file_name);
12f9d8
-      return false;
12f9d8
+      error (_("Not an ordinary file\n"));
12f9d8
+      goto done;
12f9d8
     }
12f9d8
 
12f9d8
   filedata = calloc (1, sizeof * filedata);
12f9d8
   if (filedata == NULL)
12f9d8
     {
12f9d8
       error (_("Out of memory allocating file data structure\n"));
12f9d8
-      return false;
12f9d8
+      goto done;
12f9d8
     }
12f9d8
 
12f9d8
   filedata->file_name = file_name;
12f9d8
   filedata->handle = fopen (file_name, "rb");
12f9d8
   if (filedata->handle == NULL)
12f9d8
     {
12f9d8
-      error (_("Input file '%s' is not readable.\n"), file_name);
12f9d8
-      free (filedata);
12f9d8
-      return false;
12f9d8
+      error (_("Not readable\n"));
12f9d8
+      goto done;
12f9d8
     }
12f9d8
 
12f9d8
   if (fread (armag, SARMAG, 1, filedata->handle) != 1)
12f9d8
     {
12f9d8
-      error (_("%s: Failed to read file's magic number\n"), file_name);
12f9d8
-      fclose (filedata->handle);
12f9d8
-      free (filedata);
12f9d8
-      return false;
12f9d8
+      error (_("Failed to read file's magic number\n"));
12f9d8
+      goto done;
12f9d8
     }
12f9d8
 
12f9d8
   filedata->file_size = (bfd_size_type) statbuf.st_size;
12f9d8
@@ -21919,33 +21926,39 @@ process_file (char * file_name)
12f9d8
 
12f9d8
   if (memcmp (armag, ARMAG, SARMAG) == 0)
12f9d8
     {
12f9d8
-      if (! process_archive (filedata, false))
12f9d8
-	ret = false;
12f9d8
+      if (process_archive (filedata, false))
12f9d8
+	ret = true;
12f9d8
     }
12f9d8
   else if (memcmp (armag, ARMAGT, SARMAG) == 0)
12f9d8
     {
12f9d8
-      if ( ! process_archive (filedata, true))
12f9d8
-	ret = false;
12f9d8
+      if (process_archive (filedata, true))
12f9d8
+	ret = true;
12f9d8
     }
12f9d8
   else
12f9d8
     {
12f9d8
       if (do_archive_index && !check_all)
12f9d8
-	error (_("File %s is not an archive so its index cannot be displayed.\n"),
12f9d8
-	       file_name);
12f9d8
+	error (_("Not an archive so its index cannot be displayed.\n"));
12f9d8
 
12f9d8
       rewind (filedata->handle);
12f9d8
       filedata->archive_file_size = filedata->archive_file_offset = 0;
12f9d8
 
12f9d8
-      if (! process_object (filedata))
12f9d8
-	ret = false;
12f9d8
+      if (process_object (filedata))
12f9d8
+	ret = true;
12f9d8
     }
12f9d8
 
12f9d8
-  fclose (filedata->handle);
12f9d8
-  free (filedata->section_headers);
12f9d8
-  free (filedata->program_headers);
12f9d8
-  free (filedata->string_table);
12f9d8
-  free (filedata->dump.dump_sects);
12f9d8
-  free (filedata);
12f9d8
+ done:
12f9d8
+  if (filedata)
12f9d8
+    {
12f9d8
+      if (filedata->handle != NULL)
12f9d8
+	fclose (filedata->handle);
12f9d8
+      free (filedata->section_headers);
12f9d8
+      free (filedata->program_headers);
12f9d8
+      free (filedata->string_table);
12f9d8
+      free (filedata->dump.dump_sects);
12f9d8
+      free (filedata);
12f9d8
+    }
12f9d8
+  free (program_name);
12f9d8
+  program_name = saved_program_name;
12f9d8
 
12f9d8
   free (ba_cache.strtab);
12f9d8
   ba_cache.strtab = NULL;
12f9d8
--- binutils.orig/binutils/readelf.c	2021-08-10 10:15:22.088016072 +0100
12f9d8
+++ binutils-2.37/binutils/readelf.c	2021-08-10 10:15:55.567907891 +0100
12f9d8
@@ -21884,7 +21884,7 @@ process_file (char * file_name)
12f9d8
   Filedata * filedata = NULL;
12f9d8
   struct stat statbuf;
12f9d8
   char armag[SARMAG];
12f9d8
-  bool ret = true;
12f9d8
+  bool ret = false;
12f9d8
   char * name;
12f9d8
   char * saved_program_name;
12f9d8