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

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