Blame SOURCES/binutils-readelf-other-sym-info.patch

fcd040
diff -rupN --no-dereference binutils-2.38/binutils/readelf.c binutils-2.38-new/binutils/readelf.c
fcd040
--- binutils-2.38/binutils/readelf.c	2022-04-26 13:54:50.369529409 +0200
fcd040
+++ binutils-2.38-new/binutils/readelf.c	2022-04-26 13:54:51.333530785 +0200
fcd040
@@ -12991,11 +12991,13 @@ print_dynamic_symbol (Filedata *filedata
e89428
       unsigned int vis = ELF_ST_VISIBILITY (psym->st_other);
e89428
 
e89428
       printf (" %-7s", get_symbol_visibility (vis));
e89428
+#if 0
e89428
       /* Check to see if any other bits in the st_other field are set.
e89428
 	 Note - displaying this information disrupts the layout of the
e89428
 	 table being generated, but for the moment this case is very rare.  */
e89428
       if (psym->st_other ^ vis)
e89428
 	printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis));
e89428
+#endif
e89428
     }
e89428
   printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx));
e89428
 
fcd040
@@ -13049,7 +13051,17 @@ print_dynamic_symbol (Filedata *filedata
e89428
 		version_string);
e89428
     }
e89428
 
e89428
-  putchar ('\n');
e89428
+#if 1
e89428
+    {
e89428
+      unsigned int vis = ELF_ST_VISIBILITY (psym->st_other);
e89428
+
e89428
+      /* Check to see if any other bits in the st_other field are set.  */
e89428
+      if (psym->st_other ^ vis)
e89428
+	printf (" \t[%s]", get_symbol_other (filedata, psym->st_other ^ vis));
e89428
+    }
e89428
+#endif
e89428
+
e89428
+    putchar ('\n');
e89428
 
e89428
   if (ELF_ST_BIND (psym->st_info) == STB_LOCAL
e89428
       && section != NULL
fcd040
diff -rupN --no-dereference binutils-2.38/binutils/readelf.c.orig binutils-2.38-new/binutils/readelf.c.orig
fcd040
--- binutils-2.38/binutils/readelf.c.orig	2022-04-26 13:54:50.375529417 +0200
fcd040
+++ binutils-2.38-new/binutils/readelf.c.orig	2022-04-26 13:54:49.332527928 +0200
fcd040
@@ -22327,46 +22327,53 @@ process_file (char * file_name)
fcd040
   Filedata * filedata = NULL;
fcd040
   struct stat statbuf;
fcd040
   char armag[SARMAG];
fcd040
-  bool ret = true;
fcd040
+  bool ret = false;
fcd040
+  char * name;
fcd040
+  char * saved_program_name;
fcd040
+
fcd040
+  /* Overload program_name to include file_name.  Doing this means
fcd040
+     that warning/error messages will positively identify the file
fcd040
+     concerned even when multiple instances of readelf are running.  */
fcd040
+  name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
fcd040
+  sprintf (name, "%s: %s", program_name, file_name);
fcd040
+  saved_program_name = program_name;
fcd040
+  program_name = name;
fcd040
 
fcd040
   if (stat (file_name, &statbuf) < 0)
fcd040
     {
fcd040
       if (errno == ENOENT)
fcd040
-	error (_("'%s': No such file\n"), file_name);
fcd040
+	error (_("No such file\n"));
fcd040
       else
fcd040
-	error (_("Could not locate '%s'.  System error message: %s\n"),
fcd040
-	       file_name, strerror (errno));
fcd040
-      return false;
fcd040
+	error (_("Could not locate file.  System error message: %s\n"),
fcd040
+	       strerror (errno));
fcd040
+      goto done;
fcd040
     }
fcd040
 
fcd040
   if (! S_ISREG (statbuf.st_mode))
fcd040
     {
fcd040
-      error (_("'%s' is not an ordinary file\n"), file_name);
fcd040
-      return false;
fcd040
+      error (_("Not an ordinary file\n"));
fcd040
+      goto done;
fcd040
     }
fcd040
 
fcd040
   filedata = calloc (1, sizeof * filedata);
fcd040
   if (filedata == NULL)
fcd040
     {
fcd040
       error (_("Out of memory allocating file data structure\n"));
fcd040
-      return false;
fcd040
+      goto done;
fcd040
     }
fcd040
 
fcd040
   filedata->file_name = file_name;
fcd040
   filedata->handle = fopen (file_name, "rb");
fcd040
   if (filedata->handle == NULL)
fcd040
     {
fcd040
-      error (_("Input file '%s' is not readable.\n"), file_name);
fcd040
-      free (filedata);
fcd040
-      return false;
fcd040
+      error (_("Not readable\n"));
fcd040
+      goto done;
fcd040
     }
fcd040
 
fcd040
   if (fread (armag, SARMAG, 1, filedata->handle) != 1)
fcd040
     {
fcd040
-      error (_("%s: Failed to read file's magic number\n"), file_name);
fcd040
-      fclose (filedata->handle);
fcd040
-      free (filedata);
fcd040
-      return false;
fcd040
+      error (_("Failed to read file's magic number\n"));
fcd040
+      goto done;
fcd040
     }
fcd040
 
fcd040
   filedata->file_size = (bfd_size_type) statbuf.st_size;
fcd040
@@ -22374,33 +22381,39 @@ process_file (char * file_name)
fcd040
 
fcd040
   if (memcmp (armag, ARMAG, SARMAG) == 0)
fcd040
     {
fcd040
-      if (! process_archive (filedata, false))
fcd040
-	ret = false;
fcd040
+      if (process_archive (filedata, false))
fcd040
+	ret = true;
fcd040
     }
fcd040
   else if (memcmp (armag, ARMAGT, SARMAG) == 0)
fcd040
     {
fcd040
-      if ( ! process_archive (filedata, true))
fcd040
-	ret = false;
fcd040
+      if (process_archive (filedata, true))
fcd040
+	ret = true;
fcd040
     }
fcd040
   else
fcd040
     {
fcd040
       if (do_archive_index && !check_all)
fcd040
-	error (_("File %s is not an archive so its index cannot be displayed.\n"),
fcd040
-	       file_name);
fcd040
+	error (_("Not an archive so its index cannot be displayed.\n"));
fcd040
 
fcd040
       rewind (filedata->handle);
fcd040
       filedata->archive_file_size = filedata->archive_file_offset = 0;
fcd040
 
fcd040
-      if (! process_object (filedata))
fcd040
-	ret = false;
fcd040
+      if (process_object (filedata))
fcd040
+	ret = true;
fcd040
     }
fcd040
 
fcd040
-  fclose (filedata->handle);
fcd040
-  free (filedata->section_headers);
fcd040
-  free (filedata->program_headers);
fcd040
-  free (filedata->string_table);
fcd040
-  free (filedata->dump.dump_sects);
fcd040
-  free (filedata);
fcd040
+ done:
fcd040
+  if (filedata)
fcd040
+    {
fcd040
+      if (filedata->handle != NULL)
fcd040
+	fclose (filedata->handle);
fcd040
+      free (filedata->section_headers);
fcd040
+      free (filedata->program_headers);
fcd040
+      free (filedata->string_table);
fcd040
+      free (filedata->dump.dump_sects);
fcd040
+      free (filedata);
fcd040
+    }
fcd040
+  free (program_name);
fcd040
+  program_name = saved_program_name;
fcd040
 
fcd040
   free (ba_cache.strtab);
fcd040
   ba_cache.strtab = NULL;