Nick Clifton 126525
diff -rup binutils,orig/bfd/elf.c binutils-2.31.1/bfd/elf.c
Nick Clifton 126525
--- binutils,orig/bfd/elf.c	2018-08-28 12:38:29.987511521 +0100
Nick Clifton 126525
+++ binutils-2.31.1/bfd/elf.c	2018-08-28 12:39:35.010036349 +0100
Nick Clifton 126525
@@ -1877,7 +1877,7 @@ _bfd_elf_get_symbol_version_string (bfd
Nick Clifton 126525
 	{
Nick Clifton 126525
 	  Elf_Internal_Verneed *t;
Nick Clifton 126525
 
Nick Clifton 126525
-	  version_string = "";
Nick Clifton 126525
+	  version_string = _("<corrupt>");
Nick Clifton 126525
 	  for (t = elf_tdata (abfd)->verref;
Nick Clifton 126525
 	       t != NULL;
Nick Clifton 126525
 	       t = t->vn_nextref)
Nick Clifton 126525
diff -rup binutils,orig/binutils/readelf.c binutils-2.31.1/binutils/readelf.c
Nick Clifton 126525
--- binutils,orig/binutils/readelf.c	2018-08-28 12:38:30.552507392 +0100
Nick Clifton 126525
+++ binutils-2.31.1/binutils/readelf.c	2018-08-28 12:42:04.625942967 +0100
Nick Clifton 126525
@@ -11263,6 +11263,7 @@ get_symbol_version_string (Filedata *
Nick Clifton 126525
   unsigned char data[2];
Nick Clifton 126525
   unsigned short vers_data;
Nick Clifton 126525
   unsigned long offset;
Nick Clifton 126525
+  unsigned short max_vd_ndx;
Nick Clifton 126525
 
Nick Clifton 126525
   if (!is_dynsym
Nick Clifton 126525
       || version_info[DT_VERSIONTAGIDX (DT_VERSYM)] == 0)
Nick Clifton 126525
@@ -11280,6 +11281,8 @@ get_symbol_version_string (Filedata *
Nick Clifton 126525
   if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data == 0)
Nick Clifton 126525
     return NULL;
Nick Clifton 126525
 
Nick Clifton 126525
+  max_vd_ndx = 0;
Nick Clifton 126525
+
Nick Clifton 126525
   /* Usually we'd only see verdef for defined symbols, and verneed for
Nick Clifton 126525
      undefined symbols.  However, symbols defined by the linker in
Nick Clifton 126525
      .dynbss for variables copied from a shared library in order to
Nick Clifton 126525
@@ -11322,6 +11325,9 @@ get_symbol_version_string (Filedata *
Nick Clifton 126525
 	      ivd.vd_flags = BYTE_GET (evd.vd_flags);
Nick Clifton 126525
 	    }
Nick Clifton 126525
 
Nick Clifton 126525
+	  if ((ivd.vd_ndx & VERSYM_VERSION) > max_vd_ndx)
Nick Clifton 126525
+	    max_vd_ndx = ivd.vd_ndx & VERSYM_VERSION;
Nick Clifton 126525
+
Nick Clifton 126525
 	  off += ivd.vd_next;
Nick Clifton 126525
 	}
Nick Clifton 126525
       while (ivd.vd_ndx != (vers_data & VERSYM_VERSION) && ivd.vd_next != 0);
Nick Clifton 126525
@@ -11413,6 +11419,9 @@ get_symbol_version_string (Filedata *
Nick Clifton 126525
 	  return (ivna.vna_name < strtab_size
Nick Clifton 126525
 		  ? strtab + ivna.vna_name : _("<corrupt>"));
Nick Clifton 126525
 	}
Nick Clifton 126525
+      else if ((max_vd_ndx || (vers_data & VERSYM_VERSION) != 1)
Nick Clifton 126525
+	       && (vers_data & VERSYM_VERSION) > max_vd_ndx)
Nick Clifton 126525
+	return _("<corrupt>");
Nick Clifton 126525
     }
Nick Clifton 126525
   return NULL;
Nick Clifton 126525
 }