15a78ff
--- binutils.orig/binutils/readelf.c	2020-07-24 14:55:25.163647522 +0100
15a78ff
+++ binutils-2.35/binutils/readelf.c	2020-07-24 15:02:39.613851369 +0100
15a78ff
@@ -20729,79 +20729,92 @@ process_file (char * file_name)
e0e1ae6
   Filedata * filedata = NULL;
4ae66ca
   struct stat statbuf;
4ae66ca
   char armag[SARMAG];
e0e1ae6
-  bfd_boolean ret = TRUE;
e0e1ae6
+  bfd_boolean ret = FALSE;
e0e1ae6
+  char * name;
e0e1ae6
+  char * saved_program_name;
e0e1ae6
+
4ae66ca
+  /* Overload program_name to include file_name.  Doing this means
4ae66ca
+     that warning/error messages will positively identify the file
4ae66ca
+     concerned even when multiple instances of readelf are running.  */
4ae66ca
+  name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
4ae66ca
+  sprintf (name, "%s: %s", program_name, file_name);
4ae66ca
+  saved_program_name = program_name;
4ae66ca
+  program_name = name;
e0e1ae6
 
4ae66ca
   if (stat (file_name, &statbuf) < 0)
4ae66ca
     {
4ae66ca
       if (errno == ENOENT)
4ae66ca
-	error (_("'%s': No such file\n"), file_name);
4ae66ca
+	error (_("No such file\n"));
4ae66ca
       else
4ae66ca
-	error (_("Could not locate '%s'.  System error message: %s\n"),
4ae66ca
-	       file_name, strerror (errno));
283a7e8
-      return FALSE;
4ae66ca
+	error (_("Could not locate file.  System error message: %s\n"),
4ae66ca
+	       strerror (errno));
4ae66ca
+      goto done;
4ae66ca
     }
4ae66ca
 
4ae66ca
   if (! S_ISREG (statbuf.st_mode))
4ae66ca
     {
4ae66ca
-      error (_("'%s' is not an ordinary file\n"), file_name);
283a7e8
-      return FALSE;
4ae66ca
+      error (_("Not an ordinary file\n"));
4ae66ca
+      goto done;
4ae66ca
     }
4ae66ca
 
e0e1ae6
   filedata = calloc (1, sizeof * filedata);
e0e1ae6
   if (filedata == NULL)
e0e1ae6
     {
e0e1ae6
       error (_("Out of memory allocating file data structure\n"));
e0e1ae6
-      return FALSE;
e0e1ae6
+      goto done;
e0e1ae6
     }
e0e1ae6
 
e0e1ae6
   filedata->file_name = file_name;
e0e1ae6
   filedata->handle = fopen (file_name, "rb");
e0e1ae6
   if (filedata->handle == NULL)
4ae66ca
     {
4ae66ca
-      error (_("Input file '%s' is not readable.\n"), file_name);
e0e1ae6
-      free (filedata);
283a7e8
-      return FALSE;
4ae66ca
+      error (_("Not readable\n"));
4ae66ca
+      goto done;
4ae66ca
     }
4ae66ca
 
e0e1ae6
   if (fread (armag, SARMAG, 1, filedata->handle) != 1)
4ae66ca
     {
4ae66ca
-      error (_("%s: Failed to read file's magic number\n"), file_name);
15a78ff
+      error (_("Failed to read file's magic number\n"));
15a78ff
       fclose (filedata->handle);
e0e1ae6
-      free (filedata);
283a7e8
-      return FALSE;
15a78ff
+      goto done;
15a78ff
     }
15a78ff
 
15a78ff
   filedata->file_size = (bfd_size_type) statbuf.st_size;
15a78ff
 
15a78ff
   if (memcmp (armag, ARMAG, SARMAG) == 0)
15a78ff
     {
e0e1ae6
-      if (! process_archive (filedata, FALSE))
e0e1ae6
-	ret = FALSE;
15a78ff
+      if (process_archive (filedata, FALSE))
15a78ff
+	ret = TRUE;
15a78ff
     }
15a78ff
   else if (memcmp (armag, ARMAGT, SARMAG) == 0)
15a78ff
     {
e0e1ae6
-      if ( ! process_archive (filedata, TRUE))
e0e1ae6
-	ret = FALSE;
15a78ff
+      if (process_archive (filedata, TRUE))
15a78ff
+	ret = TRUE;
4ae66ca
     }
e0e1ae6
   else
e0e1ae6
     {
15a78ff
       if (do_archive_index && !check_all)
e0e1ae6
-	error (_("File %s is not an archive so its index cannot be displayed.\n"),
e0e1ae6
-	       file_name);
15a78ff
+	error (_("Not an archive so its index cannot be displayed.\n"));
15a78ff
 
15a78ff
       rewind (filedata->handle);
15a78ff
       filedata->archive_file_size = filedata->archive_file_offset = 0;
4ae66ca
 
e0e1ae6
-      if (! process_object (filedata))
e0e1ae6
-	ret = FALSE;
15a78ff
+      if (process_object (filedata))
15a78ff
+	ret = TRUE;
283a7e8
     }
4ae66ca
 
15a78ff
-  fclose (filedata->handle);
15a78ff
-  free (filedata->section_headers);
15a78ff
-  free (filedata->program_headers);
15a78ff
-  free (filedata->string_table);
15a78ff
-  free (filedata->dump.dump_sects);
15a78ff
-  free (filedata);
4ae66ca
+ done:
15a78ff
+  if (filedata)
15a78ff
+    {
15a78ff
+      fclose (filedata->handle);
15a78ff
+      free (filedata->section_headers);
15a78ff
+      free (filedata->program_headers);
15a78ff
+      free (filedata->string_table);
15a78ff
+      free (filedata->dump.dump_sects);
15a78ff
+      free (filedata);
15a78ff
+    }
4ae66ca
+  free (program_name);
4ae66ca
+  program_name = saved_program_name;
283a7e8
 
15a78ff
   free (ba_cache.strtab);
15a78ff
   ba_cache.strtab = NULL;
e056abe
--- binutils.orig/binutils/readelf.c	2021-01-07 12:59:35.802994842 +0000
e056abe
+++ binutils-2.35.1/binutils/readelf.c	2021-01-07 13:02:36.591754005 +0000
e056abe
@@ -20818,7 +20818,8 @@ process_file (char * file_name)
e056abe
  done:
e056abe
   if (filedata)
e056abe
     {
e056abe
-      fclose (filedata->handle);
e056abe
+      if (filedata->handle != NULL)
e056abe
+	fclose (filedata->handle);
e056abe
       free (filedata->section_headers);
e056abe
       free (filedata->program_headers);
e056abe
       free (filedata->string_table);
eeeb57f
--- binutils.orig/binutils/readelf.c	2021-01-08 17:01:23.573093204 +0000
eeeb57f
+++ binutils-2.35.1/binutils/readelf.c	2021-01-08 17:02:23.095677242 +0000
eeeb57f
@@ -20787,7 +20787,6 @@ process_file (char * file_name)
eeeb57f
   if (fread (armag, SARMAG, 1, filedata->handle) != 1)
eeeb57f
     {
eeeb57f
       error (_("Failed to read file's magic number\n"));
eeeb57f
-      fclose (filedata->handle);
eeeb57f
       goto done;
eeeb57f
     }
eeeb57f