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

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