public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
@ 2014-01-24 19:16 H.J. Lu
  2014-01-30  5:33 ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2014-01-24 19:16 UTC (permalink / raw)
  To: binutils


Both readelf/objdump know how to get symbol version string for dynamic
symbols.  This patch extracts this functionality into a separate
function and uses it to add symbol version string to versioned symbol
names when dumping dynamic relocations.  OK for trunk?

Thanks.


H.J.
--
bfd/

	PR binutils/16496
	* elf-bfd.h (bfd_elf_get_symbol_version_string): New.
	* elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
	from bfd_elf_print_symbol.
	(bfd_elf_print_symbol): Use it.

binutils/

	PR binutils/16496
	* objdump.c (objdump_print_symname): Call
	bfd_elf_get_symbol_version_string to get ELF symbol version
	string.  Append version string if needed.

	* readelf.c (versioned_symbol_info): New enum.
	(get_symbol_version_string): New.  Extracted from
	process_symbol_table.
	(dump_relocations): Add a new argument to indicate if dynamic
	symbol table is used.  Use get_symbol_version_string to get
	symbol version string for dynamic symbol.  Append version string
	if needed.
	(process_relocs): Updated dump_relocations call.
	(process_symbol_table): Use get_symbol_version_string.

ld/testsuite/

	PR binutils/16496
	* ld-cris/weakref3.d: Add symbol version string to versioned
	symbol names in dynamic relocation.
	* ld-cris/weakref4.d: Likewise.
	* ld-elfvers/vers24.rd: Likewise.

	* ld-elf/pr16496a.c: New file.
	* ld-elf/pr16496a.map: Likewise.
	* ld-elf/pr16496b.c: Likewise.
	* ld-elf/pr16496b.od: Likewise.

	* ld-elf/shared.exp (build_tests): Add libpr16496a.so and
	libpr16496b.so tests.
---
 bfd/ChangeLog                     |   8 +
 bfd/elf-bfd.h                     |   2 +
 bfd/elf.c                         |  92 +++++----
 binutils/ChangeLog                |  17 ++
 binutils/objdump.c                |  23 ++-
 binutils/readelf.c                | 393 ++++++++++++++++++++++----------------
 ld/testsuite/ChangeLog            |  16 ++
 ld/testsuite/ld-cris/weakref3.d   |   4 +-
 ld/testsuite/ld-cris/weakref4.d   |   2 +-
 ld/testsuite/ld-elf/pr16496a.c    |   4 +
 ld/testsuite/ld-elf/pr16496a.map  |   4 +
 ld/testsuite/ld-elf/pr16496b.c    |   5 +
 ld/testsuite/ld-elf/pr16496b.od   |   3 +
 ld/testsuite/ld-elf/shared.exp    |   9 +
 ld/testsuite/ld-elfvers/vers24.rd |   2 +-
 15 files changed, 378 insertions(+), 206 deletions(-)
 create mode 100644 ld/testsuite/ld-elf/pr16496a.c
 create mode 100644 ld/testsuite/ld-elf/pr16496a.map
 create mode 100644 ld/testsuite/ld-elf/pr16496b.c
 create mode 100644 ld/testsuite/ld-elf/pr16496b.od

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a5fcadf..75a81fe 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR binutils/16496
+	* elf-bfd.h (bfd_elf_get_symbol_version_string): New.
+	* elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
+	from bfd_elf_print_symbol.
+	(bfd_elf_print_symbol): Use it.
+
 2014-01-24  Alan Modra  <amodra@gmail.com>
 
 	* elf64-ppc.c (ppc_build_one_stub): Correct reloc count passed
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 0aab5fa..b9c55e7 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1767,6 +1767,8 @@ extern bfd_boolean _bfd_elf_copy_private_bfd_data
   (bfd *, bfd *);
 extern bfd_boolean _bfd_elf_print_private_bfd_data
   (bfd *, void *);
+const char * bfd_elf_get_symbol_version_string
+  (bfd *, asymbol *, bfd_boolean *);
 extern void bfd_elf_print_symbol
   (bfd *, void *, asymbol *, bfd_print_symbol_type);
 
diff --git a/bfd/elf.c b/bfd/elf.c
index c0303fc..5783d88 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1396,6 +1396,53 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
   return FALSE;
 }
 
+/* Get version string.  */
+
+const char *
+bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
+				   bfd_boolean *hidden)
+{
+  const char *version_string = NULL;
+  if (elf_dynversym (abfd) != 0
+      && (elf_dynverdef (abfd) != 0 || elf_dynverref (abfd) != 0))
+    {
+      unsigned int vernum = ((elf_symbol_type *) symbol)->version;
+
+      *hidden = (vernum & VERSYM_HIDDEN) != 0;
+      vernum &= VERSYM_VERSION;
+
+      if (vernum == 0)
+	version_string = "";
+      else if (vernum == 1)
+	version_string = "Base";
+      else if (vernum <= elf_tdata (abfd)->cverdefs)
+	version_string =
+	  elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
+      else
+	{
+	  Elf_Internal_Verneed *t;
+
+	  version_string = "";
+	  for (t = elf_tdata (abfd)->verref;
+	       t != NULL;
+	       t = t->vn_nextref)
+	    {
+	      Elf_Internal_Vernaux *a;
+
+	      for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+		{
+		  if (a->vna_other == vernum)
+		    {
+		      version_string = a->vna_nodename;
+		      break;
+		    }
+		}
+	    }
+	}
+    }
+  return version_string;
+}
+
 /* Display ELF-specific fields of a symbol.  */
 
 void
@@ -1422,6 +1469,8 @@ bfd_elf_print_symbol (bfd *abfd,
 	const struct elf_backend_data *bed;
 	unsigned char st_other;
 	bfd_vma val;
+	const char *version_string;
+	bfd_boolean hidden;
 
 	section_name = symbol->section ? symbol->section->name : "(*none*)";
 
@@ -1447,45 +1496,12 @@ bfd_elf_print_symbol (bfd *abfd,
 	bfd_fprintf_vma (abfd, file, val);
 
 	/* If we have version information, print it.  */
-	if (elf_dynversym (abfd) != 0
-	    && (elf_dynverdef (abfd) != 0
-		|| elf_dynverref (abfd) != 0))
+	version_string = bfd_elf_get_symbol_version_string (abfd,
+							    symbol,
+							    &hidden);
+	if (version_string)
 	  {
-	    unsigned int vernum;
-	    const char *version_string;
-
-	    vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION;
-
-	    if (vernum == 0)
-	      version_string = "";
-	    else if (vernum == 1)
-	      version_string = "Base";
-	    else if (vernum <= elf_tdata (abfd)->cverdefs)
-	      version_string =
-		elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
-	    else
-	      {
-		Elf_Internal_Verneed *t;
-
-		version_string = "";
-		for (t = elf_tdata (abfd)->verref;
-		     t != NULL;
-		     t = t->vn_nextref)
-		  {
-		    Elf_Internal_Vernaux *a;
-
-		    for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
-		      {
-			if (a->vna_other == vernum)
-			  {
-			    version_string = a->vna_nodename;
-			    break;
-			  }
-		      }
-		  }
-	      }
-
-	    if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0)
+	    if (!hidden)
 	      fprintf (file, "  %-11s", version_string);
 	    else
 	      {
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6f107e1..6545d62 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,20 @@
+2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR binutils/16496
+	* objdump.c (objdump_print_symname): Call
+	bfd_elf_get_symbol_version_string to get ELF symbol version
+	string.  Append version string if needed.
+
+	* readelf.c (versioned_symbol_info): New enum.
+	(get_symbol_version_string): New.  Extracted from
+	process_symbol_table.
+	(dump_relocations): Add a new argument to indicate if dynamic
+	symbol table is used.  Use get_symbol_version_string to get
+	symbol version string for dynamic symbol.  Append version string
+	if needed.
+	(process_relocs): Updated dump_relocations call.
+	(process_symbol_table): Use get_symbol_version_string.
+
 2014-01-08  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* version.c (print_version): Update copyright year to 2014.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 0098ae7..af7bfce 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -792,7 +792,8 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
 		       asymbol *sym)
 {
   char *alloc;
-  const char *name;
+  const char *name, *version_string = NULL;
+  bfd_boolean hidden = FALSE;
 
   alloc = NULL;
   name = bfd_asymbol_name (sym);
@@ -804,10 +805,26 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
 	name = alloc;
     }
 
+  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+    version_string = bfd_elf_get_symbol_version_string (abfd, sym,
+							&hidden);
+
+  if (bfd_is_und_section (bfd_get_section (sym)))
+    hidden = TRUE;
+
   if (inf != NULL)
-    (*inf->fprintf_func) (inf->stream, "%s", name);
+    {
+      (*inf->fprintf_func) (inf->stream, "%s", name);
+      if (version_string && *version_string != '\0')
+	(*inf->fprintf_func) (inf->stream, hidden ? "@%s" : "@@%s",
+			      version_string);
+    }
   else
-    printf ("%s", name);
+    {
+      printf ("%s", name);
+      if (version_string && *version_string != '\0')
+	printf (hidden ? "@%s" : "@@%s", version_string);
+    }
 
   if (alloc != NULL)
     free (alloc);
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 7d228d6..669cda7 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -271,6 +271,20 @@ typedef enum print_mode
 }
 print_mode;
 
+/* Versioned symbol info.  */
+enum versioned_symbol_info
+{
+  symbol_undefined,
+  symbol_hidden,
+  symbol_public
+};
+
+static const char *get_symbol_version_string
+  (FILE *file, int is_dynsym, const char *strtab,
+   unsigned long int strtab_size, unsigned int si,
+   Elf_Internal_Sym *psym, enum versioned_symbol_info *sym_info,
+   unsigned short *vna_other);
+
 #define UNKNOWN -1
 
 #define SECTION_NAME(X)						\
@@ -926,7 +940,8 @@ dump_relocations (FILE * file,
 		  unsigned long nsyms,
 		  char * strtab,
 		  unsigned long strtablen,
-		  int is_rela)
+		  int is_rela,
+		  int is_dynsym)
 {
   unsigned int i;
   Elf_Internal_Rela * rels;
@@ -1360,9 +1375,20 @@ dump_relocations (FILE * file,
 	  else
 	    {
 	      Elf_Internal_Sym * psym;
+	      const char * version_string;
+	      enum versioned_symbol_info sym_info;
+	      unsigned short vna_other;
 
 	      psym = symtab + symtab_index;
 
+	      version_string
+		= get_symbol_version_string (file, is_dynsym,
+					     strtab, strtablen,
+					     symtab_index,
+					     psym,
+					     &sym_info,
+					     &vna_other);
+
 	      printf (" ");
 
 	      if (ELF_ST_TYPE (psym->st_info) == STT_GNU_IFUNC)
@@ -1389,6 +1415,9 @@ dump_relocations (FILE * file,
 		    name = strtab + psym->st_name;
 
 		  len = print_symbol (width, name);
+		  if (version_string)
+		    printf (sym_info == symbol_public ? "@@%s" : "@%s", 
+			    version_string);
 		  printf ("()%-*s", len <= width ? (width + 1) - len : 1, " ");
 		}
 	      else
@@ -1446,7 +1475,12 @@ dump_relocations (FILE * file,
 	      else if (psym->st_name >= strtablen)
 		printf (_("<corrupt string table index: %3ld>"), psym->st_name);
 	      else
-		print_symbol (22, strtab + psym->st_name);
+		{
+		  print_symbol (22, strtab + psym->st_name);
+		  if (version_string)
+		    printf (sym_info == symbol_public ? "@@%s" : "@%s", 
+			    version_string);
+		}
 
 	      if (is_rela)
 		{
@@ -5920,7 +5954,8 @@ process_relocs (FILE * file)
 				offset_from_vma (file, rel_offset, rel_size),
 				rel_size,
 				dynamic_symbols, num_dynamic_syms,
-				dynamic_strings, dynamic_strings_length, is_rela);
+				dynamic_strings, dynamic_strings_length,
+				is_rela, 1);
 	    }
 	}
 
@@ -5995,14 +6030,16 @@ process_relocs (FILE * file)
 		    }
 
 		  dump_relocations (file, rel_offset, rel_size,
-				    symtab, nsyms, strtab, strtablen, is_rela);
+				    symtab, nsyms, strtab, strtablen,
+				    is_rela,
+				    symsec->sh_type == SHT_DYNSYM);
 		  if (strtab)
 		    free (strtab);
 		  free (symtab);
 		}
 	      else
 		dump_relocations (file, rel_offset, rel_size,
-				  NULL, 0, NULL, 0, is_rela);
+				  NULL, 0, NULL, 0, is_rela, 0);
 
 	      found = 1;
 	    }
@@ -9581,6 +9618,181 @@ print_dynamic_symbol (bfd_vma si, unsigned long hn)
   putchar ('\n');
 }
 
+static const char *
+get_symbol_version_string (FILE *file, int is_dynsym,
+			   const char *strtab,
+			   unsigned long int strtab_size,
+			   unsigned int si, Elf_Internal_Sym *psym,
+			   enum versioned_symbol_info *sym_info,
+			   unsigned short *vna_other)
+{
+  const char *version_string = NULL;
+
+  if (is_dynsym
+      && version_info[DT_VERSIONTAGIDX (DT_VERSYM)] != 0)
+    {
+      unsigned char data[2];
+      unsigned short vers_data;
+      unsigned long offset;
+      int is_nobits;
+      int check_def;
+
+      offset = offset_from_vma
+	(file, version_info[DT_VERSIONTAGIDX (DT_VERSYM)],
+	 sizeof data + si * sizeof (vers_data));
+
+      if (get_data (&data, file, offset + si * sizeof (vers_data),
+		    sizeof (data), 1, _("version data")) == NULL)
+	return NULL;
+
+      vers_data = byte_get (data, 2);
+
+      is_nobits = (psym->st_shndx < elf_header.e_shnum
+		   && section_headers[psym->st_shndx].sh_type
+		   == SHT_NOBITS);
+
+      check_def = (psym->st_shndx != SHN_UNDEF);
+
+      if ((vers_data & VERSYM_HIDDEN) || vers_data > 1)
+	{
+	  if (version_info[DT_VERSIONTAGIDX (DT_VERNEED)]
+	      && (is_nobits || ! check_def))
+	    {
+	      Elf_External_Verneed evn;
+	      Elf_Internal_Verneed ivn;
+	      Elf_Internal_Vernaux ivna;
+
+	      /* We must test both.  */
+	      offset = offset_from_vma
+		(file, version_info[DT_VERSIONTAGIDX (DT_VERNEED)],
+		 sizeof evn);
+
+	      do
+		{
+		  unsigned long vna_off;
+
+		  if (get_data (&evn, file, offset, sizeof (evn), 1,
+				_("version need")) == NULL)
+		    {
+		      ivna.vna_next = 0;
+		      ivna.vna_other = 0;
+		      ivna.vna_name = 0;
+		      break;
+		    }
+
+		  ivn.vn_aux  = BYTE_GET (evn.vn_aux);
+		  ivn.vn_next = BYTE_GET (evn.vn_next);
+
+		  vna_off = offset + ivn.vn_aux;
+
+		  do
+		    {
+		      Elf_External_Vernaux evna;
+
+		      if (get_data (&evna, file, vna_off,
+				    sizeof (evna), 1,
+				    _("version need aux (3)")) == NULL)
+			{
+			  ivna.vna_next = 0;
+			  ivna.vna_other = 0;
+			  ivna.vna_name = 0;
+			}
+		      else
+			{
+			  ivna.vna_other = BYTE_GET (evna.vna_other);
+			  ivna.vna_next  = BYTE_GET (evna.vna_next);
+			  ivna.vna_name  = BYTE_GET (evna.vna_name);
+			}
+
+		      vna_off += ivna.vna_next;
+		    }
+		  while (ivna.vna_other != vers_data
+			 && ivna.vna_next != 0);
+
+		  if (ivna.vna_other == vers_data)
+		    break;
+
+		  offset += ivn.vn_next;
+		}
+	      while (ivn.vn_next != 0);
+
+	      if (ivna.vna_other == vers_data)
+		{
+		  *sym_info = symbol_undefined;
+		  *vna_other = ivna.vna_other;
+		  version_string = (ivna.vna_name < strtab_size
+				    ? strtab + ivna.vna_name
+				    : _("<corrupt>"));
+		  check_def = 0;
+		}
+	      else if (! is_nobits)
+		error (_("bad dynamic symbol\n"));
+	      else
+		check_def = 1;
+	    }
+
+	  if (check_def)
+	    {
+	      if (vers_data != 0x8001
+		  && version_info[DT_VERSIONTAGIDX (DT_VERDEF)])
+		{
+		  Elf_Internal_Verdef ivd;
+		  Elf_Internal_Verdaux ivda;
+		  Elf_External_Verdaux evda;
+		  unsigned long off;
+
+		  off = offset_from_vma
+		    (file,
+		     version_info[DT_VERSIONTAGIDX (DT_VERDEF)],
+		     sizeof (Elf_External_Verdef));
+
+		  do
+		    {
+		      Elf_External_Verdef evd;
+
+		      if (get_data (&evd, file, off, sizeof (evd),
+				    1, _("version def")) == NULL)
+			{
+			  ivd.vd_ndx = 0;
+			  ivd.vd_aux = 0;
+			  ivd.vd_next = 0;
+			}
+		      else
+			{
+			  ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
+			  ivd.vd_aux = BYTE_GET (evd.vd_aux);
+			  ivd.vd_next = BYTE_GET (evd.vd_next);
+			}
+
+		      off += ivd.vd_next;
+		    }
+		  while (ivd.vd_ndx != (vers_data & VERSYM_VERSION)
+			 && ivd.vd_next != 0);
+
+		  off -= ivd.vd_next;
+		  off += ivd.vd_aux;
+
+		  if (get_data (&evda, file, off, sizeof (evda),
+				1, _("version def aux")) == NULL)
+		    return version_string;
+
+		  ivda.vda_name = BYTE_GET (evda.vda_name);
+
+		  if (psym->st_name != ivda.vda_name)
+		    {
+		      *sym_info = ((vers_data & VERSYM_HIDDEN) != 0
+				   ? symbol_hidden : symbol_public);
+		      version_string = (ivda.vda_name < strtab_size
+					? strtab + ivda.vda_name
+					: _("<corrupt>"));
+		    }
+		}
+	    }
+	}
+    }
+  return version_string;
+}
+
 /* Dump the symbol table.  */
 static int
 process_symbol_table (FILE * file)
@@ -9877,6 +10089,10 @@ process_symbol_table (FILE * file)
 
 	  for (si = 0, psym = symtab; si < num_syms; si++, psym++)
 	    {
+	      const char *version_string;
+	      enum versioned_symbol_info sym_info;
+	      unsigned short vna_other;
+
 	      printf ("%6d: ", si);
 	      print_vma (psym->st_value, LONG_HEX);
 	      putchar (' ');
@@ -9893,163 +10109,18 @@ process_symbol_table (FILE * file)
 	      print_symbol (25, psym->st_name < strtab_size
 			    ? strtab + psym->st_name : _("<corrupt>"));
 
-	      if (section->sh_type == SHT_DYNSYM
-		  && version_info[DT_VERSIONTAGIDX (DT_VERSYM)] != 0)
+	      version_string
+		= get_symbol_version_string (file,
+					     section->sh_type == SHT_DYNSYM,
+					     strtab, strtab_size, si,
+					     psym, &sym_info, &vna_other);
+	      if (version_string)
 		{
-		  unsigned char data[2];
-		  unsigned short vers_data;
-		  unsigned long offset;
-		  int is_nobits;
-		  int check_def;
-
-		  offset = offset_from_vma
-		    (file, version_info[DT_VERSIONTAGIDX (DT_VERSYM)],
-		     sizeof data + si * sizeof (vers_data));
-
-		  if (get_data (&data, file, offset + si * sizeof (vers_data),
-				sizeof (data), 1, _("version data")) == NULL)
-		    break;
-
-		  vers_data = byte_get (data, 2);
-
-		  is_nobits = (psym->st_shndx < elf_header.e_shnum
-			       && section_headers[psym->st_shndx].sh_type
-				  == SHT_NOBITS);
-
-		  check_def = (psym->st_shndx != SHN_UNDEF);
-
-		  if ((vers_data & VERSYM_HIDDEN) || vers_data > 1)
-		    {
-		      if (version_info[DT_VERSIONTAGIDX (DT_VERNEED)]
-			  && (is_nobits || ! check_def))
-			{
-			  Elf_External_Verneed evn;
-			  Elf_Internal_Verneed ivn;
-			  Elf_Internal_Vernaux ivna;
-
-			  /* We must test both.  */
-			  offset = offset_from_vma
-			    (file, version_info[DT_VERSIONTAGIDX (DT_VERNEED)],
-			     sizeof evn);
-
-			  do
-			    {
-			      unsigned long vna_off;
-
-			      if (get_data (&evn, file, offset, sizeof (evn), 1,
-					    _("version need")) == NULL)
-				{
-				  ivna.vna_next = 0;
-				  ivna.vna_other = 0;
-				  ivna.vna_name = 0;
-				  break;
-				}
-
-			      ivn.vn_aux  = BYTE_GET (evn.vn_aux);
-			      ivn.vn_next = BYTE_GET (evn.vn_next);
-
-			      vna_off = offset + ivn.vn_aux;
-
-			      do
-				{
-				  Elf_External_Vernaux evna;
-
-				  if (get_data (&evna, file, vna_off,
-						sizeof (evna), 1,
-						_("version need aux (3)")) == NULL)
-				    {
-				      ivna.vna_next = 0;
-				      ivna.vna_other = 0;
-				      ivna.vna_name = 0;
-				    }
-				  else
-				    {
-				      ivna.vna_other = BYTE_GET (evna.vna_other);
-				      ivna.vna_next  = BYTE_GET (evna.vna_next);
-				      ivna.vna_name  = BYTE_GET (evna.vna_name);
-				    }
-
-				  vna_off += ivna.vna_next;
-				}
-			      while (ivna.vna_other != vers_data
-				     && ivna.vna_next != 0);
-
-			      if (ivna.vna_other == vers_data)
-				break;
-
-			      offset += ivn.vn_next;
-			    }
-			  while (ivn.vn_next != 0);
-
-			  if (ivna.vna_other == vers_data)
-			    {
-			      printf ("@%s (%d)",
-				      ivna.vna_name < strtab_size
-				      ? strtab + ivna.vna_name : _("<corrupt>"),
-				      ivna.vna_other);
-			      check_def = 0;
-			    }
-			  else if (! is_nobits)
-			    error (_("bad dynamic symbol\n"));
-			  else
-			    check_def = 1;
-			}
-
-		      if (check_def)
-			{
-			  if (vers_data != 0x8001
-			      && version_info[DT_VERSIONTAGIDX (DT_VERDEF)])
-			    {
-			      Elf_Internal_Verdef ivd;
-			      Elf_Internal_Verdaux ivda;
-			      Elf_External_Verdaux evda;
-			      unsigned long off;
-
-			      off = offset_from_vma
-				(file,
-				 version_info[DT_VERSIONTAGIDX (DT_VERDEF)],
-				 sizeof (Elf_External_Verdef));
-
-			      do
-				{
-				  Elf_External_Verdef evd;
-
-				  if (get_data (&evd, file, off, sizeof (evd),
-						1, _("version def")) == NULL)
-				    {
-				      ivd.vd_ndx = 0;
-				      ivd.vd_aux = 0;
-				      ivd.vd_next = 0;
-				    }
-				  else
-				    {
-				      ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
-				      ivd.vd_aux = BYTE_GET (evd.vd_aux);
-				      ivd.vd_next = BYTE_GET (evd.vd_next);
-				    }
-
-				  off += ivd.vd_next;
-				}
-			      while (ivd.vd_ndx != (vers_data & VERSYM_VERSION)
-				     && ivd.vd_next != 0);
-
-			      off -= ivd.vd_next;
-			      off += ivd.vd_aux;
-
-			      if (get_data (&evda, file, off, sizeof (evda),
-					    1, _("version def aux")) == NULL)
-				break;
-
-			      ivda.vda_name = BYTE_GET (evda.vda_name);
-
-			      if (psym->st_name != ivda.vda_name)
-				printf ((vers_data & VERSYM_HIDDEN)
-					? "@%s" : "@@%s",
-					ivda.vda_name < strtab_size
-					? strtab + ivda.vda_name : _("<corrupt>"));
-			    }
-			}
-		    }
+		  if (sym_info == symbol_undefined)
+		    printf ("@%s (%d)", version_string, vna_other);
+		  else
+		    printf (sym_info == symbol_hidden ? "@%s" : "@@%s",
+			    version_string);
 		}
 
 	      putchar ('\n');
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 39cc0fb..e104817 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,21 @@
 2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
 
+	PR binutils/16496
+	* ld-cris/weakref3.d: Add symbol version string to versioned
+	symbol names in dynamic relocation.
+	* ld-cris/weakref4.d: Likewise.
+	* ld-elfvers/vers24.rd: Likewise.
+
+	* ld-elf/pr16496a.c: New file.
+	* ld-elf/pr16496a.map: Likewise.
+	* ld-elf/pr16496b.c: Likewise.
+	* ld-elf/pr16496b.od: Likewise.
+
+	* ld-elf/shared.exp (build_tests): Add libpr16496a.so and
+	libpr16496b.so tests.
+
+2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* ld-elf/pr16498a.s: Replace .align with .p2align.
 
 2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
diff --git a/ld/testsuite/ld-cris/weakref3.d b/ld/testsuite/ld-cris/weakref3.d
index aea3ad6..4807106 100644
--- a/ld/testsuite/ld-cris/weakref3.d
+++ b/ld/testsuite/ld-cris/weakref3.d
@@ -16,11 +16,11 @@
 #...
 Relocation section '.rela.dyn' at offset 0x... contains 1 entries:
  Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
-.* R_CRIS_COPY .* __expobj2 \+ 0
+.* R_CRIS_COPY .* __expobj2@TST3 \+ 0
 
 Relocation section '.rela.plt' at offset 0x... contains 1 entries:
  Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
-.* R_CRIS_JUMP_SLOT .* expfn2 \+ 0
+.* R_CRIS_JUMP_SLOT .* expfn2@TST3 \+ 0
 
 The decoding of unwind sections for machine type Axis Communications 32-bit embedded processor is not currently supported.
 
diff --git a/ld/testsuite/ld-cris/weakref4.d b/ld/testsuite/ld-cris/weakref4.d
index 79de291..aed0f39 100644
--- a/ld/testsuite/ld-cris/weakref4.d
+++ b/ld/testsuite/ld-cris/weakref4.d
@@ -17,7 +17,7 @@
 #...
 Relocation section '.rela.dyn' at offset 0x... contains 1 entries:
 #...
-.* R_CRIS_COPY .* __expobj2 \+ 0
+.* R_CRIS_COPY .* __expobj2@TST3 \+ 0
 
 The decoding of unwind sections for machine type Axis Communications 32-bit embedded processor is not currently supported.
 
diff --git a/ld/testsuite/ld-elf/pr16496a.c b/ld/testsuite/ld-elf/pr16496a.c
new file mode 100644
index 0000000..35e8555
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr16496a.c
@@ -0,0 +1,4 @@
+void
+sd_get_seats (void)
+{
+}
diff --git a/ld/testsuite/ld-elf/pr16496a.map b/ld/testsuite/ld-elf/pr16496a.map
new file mode 100644
index 0000000..d677f37
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr16496a.map
@@ -0,0 +1,4 @@
+LIBSYSTEMD_209 {
+global:
+        sd_get_seats;
+};
diff --git a/ld/testsuite/ld-elf/pr16496b.c b/ld/testsuite/ld-elf/pr16496b.c
new file mode 100644
index 0000000..94a0f30
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr16496b.c
@@ -0,0 +1,5 @@
+void sd_get_seats (void);
+void call_sd_get_seats (void)
+{
+  sd_get_seats ();
+}
diff --git a/ld/testsuite/ld-elf/pr16496b.od b/ld/testsuite/ld-elf/pr16496b.od
new file mode 100644
index 0000000..6fb54c1
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr16496b.od
@@ -0,0 +1,3 @@
+#...
+.* sd_get_seats@LIBSYSTEMD_209
+#pass
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index bbfd464..da5f8e4 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -224,6 +224,15 @@ set build_tests {
   {"Build libpr2404b.a"
    "" ""
    {pr2404b.c} {} "libpr2404b.a"}
+  {"Build libpr16496a.so"
+   "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
+   {pr16496a.c} {} "libpr16496a.so"}
+  {"Build libpr16496b.a"
+   "" "-fPIC"
+   {pr16496b.c} {} "libpr16496b.a"}
+  {"Build libpr16496b.so"
+   "-shared tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
+   {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
 }
 
 run_cc_link_tests $build_tests
diff --git a/ld/testsuite/ld-elfvers/vers24.rd b/ld/testsuite/ld-elfvers/vers24.rd
index fb464f9..2360447 100644
--- a/ld/testsuite/ld-elfvers/vers24.rd
+++ b/ld/testsuite/ld-elfvers/vers24.rd
@@ -1,7 +1,7 @@
 Relocation section .*
 # Ensure there is a dynamic relocation against x
 #...
-[0-9a-f]+ +[0-9a-f]+ R_.* +_?x(| \+ 0)
+[0-9a-f]+ +[0-9a-f]+ R_.* +_?x@VERS.0(| \+ 0)
 #...
 Symbol table '.dynsym' contains [0-9]+ entries:
 # And ensure the dynamic symbol table contains at least x@VERS.0
-- 
1.8.4.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-01-24 19:16 [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs H.J. Lu
@ 2014-01-30  5:33 ` H.J. Lu
  2014-01-30  9:39   ` Andreas Schwab
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2014-01-30  5:33 UTC (permalink / raw)
  Cc: Binutils

On Fri, Jan 24, 2014 at 11:16 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>
> Both readelf/objdump know how to get symbol version string for dynamic
> symbols.  This patch extracts this functionality into a separate
> function and uses it to add symbol version string to versioned symbol
> names when dumping dynamic relocations.  OK for trunk?
>
> Thanks.
>
>
> H.J.
> --
> bfd/
>
>         PR binutils/16496
>         * elf-bfd.h (bfd_elf_get_symbol_version_string): New.
>         * elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
>         from bfd_elf_print_symbol.
>         (bfd_elf_print_symbol): Use it.
>
> binutils/
>
>         PR binutils/16496
>         * objdump.c (objdump_print_symname): Call
>         bfd_elf_get_symbol_version_string to get ELF symbol version
>         string.  Append version string if needed.
>
>         * readelf.c (versioned_symbol_info): New enum.
>         (get_symbol_version_string): New.  Extracted from
>         process_symbol_table.
>         (dump_relocations): Add a new argument to indicate if dynamic
>         symbol table is used.  Use get_symbol_version_string to get
>         symbol version string for dynamic symbol.  Append version string
>         if needed.
>         (process_relocs): Updated dump_relocations call.
>         (process_symbol_table): Use get_symbol_version_string.
>
> ld/testsuite/
>
>         PR binutils/16496
>         * ld-cris/weakref3.d: Add symbol version string to versioned
>         symbol names in dynamic relocation.
>         * ld-cris/weakref4.d: Likewise.
>         * ld-elfvers/vers24.rd: Likewise.
>
>         * ld-elf/pr16496a.c: New file.
>         * ld-elf/pr16496a.map: Likewise.
>         * ld-elf/pr16496b.c: Likewise.
>         * ld-elf/pr16496b.od: Likewise.
>
>         * ld-elf/shared.exp (build_tests): Add libpr16496a.so and
>         libpr16496b.so tests.
> ---
>  bfd/ChangeLog                     |   8 +
>  bfd/elf-bfd.h                     |   2 +
>  bfd/elf.c                         |  92 +++++----
>  binutils/ChangeLog                |  17 ++
>  binutils/objdump.c                |  23 ++-
>  binutils/readelf.c                | 393 ++++++++++++++++++++++----------------
>  ld/testsuite/ChangeLog            |  16 ++
>  ld/testsuite/ld-cris/weakref3.d   |   4 +-
>  ld/testsuite/ld-cris/weakref4.d   |   2 +-
>  ld/testsuite/ld-elf/pr16496a.c    |   4 +
>  ld/testsuite/ld-elf/pr16496a.map  |   4 +
>  ld/testsuite/ld-elf/pr16496b.c    |   5 +
>  ld/testsuite/ld-elf/pr16496b.od   |   3 +
>  ld/testsuite/ld-elf/shared.exp    |   9 +
>  ld/testsuite/ld-elfvers/vers24.rd |   2 +-
>  15 files changed, 378 insertions(+), 206 deletions(-)
>  create mode 100644 ld/testsuite/ld-elf/pr16496a.c
>  create mode 100644 ld/testsuite/ld-elf/pr16496a.map
>  create mode 100644 ld/testsuite/ld-elf/pr16496b.c
>  create mode 100644 ld/testsuite/ld-elf/pr16496b.od
>
> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
> index a5fcadf..75a81fe 100644
> --- a/bfd/ChangeLog
> +++ b/bfd/ChangeLog
> @@ -1,3 +1,11 @@
> +2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
> +
> +       PR binutils/16496
> +       * elf-bfd.h (bfd_elf_get_symbol_version_string): New.
> +       * elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
> +       from bfd_elf_print_symbol.
> +       (bfd_elf_print_symbol): Use it.
> +
>  2014-01-24  Alan Modra  <amodra@gmail.com>
>
>         * elf64-ppc.c (ppc_build_one_stub): Correct reloc count passed
> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
> index 0aab5fa..b9c55e7 100644
> --- a/bfd/elf-bfd.h
> +++ b/bfd/elf-bfd.h
> @@ -1767,6 +1767,8 @@ extern bfd_boolean _bfd_elf_copy_private_bfd_data
>    (bfd *, bfd *);
>  extern bfd_boolean _bfd_elf_print_private_bfd_data
>    (bfd *, void *);
> +const char * bfd_elf_get_symbol_version_string
> +  (bfd *, asymbol *, bfd_boolean *);
>  extern void bfd_elf_print_symbol
>    (bfd *, void *, asymbol *, bfd_print_symbol_type);
>
> diff --git a/bfd/elf.c b/bfd/elf.c
> index c0303fc..5783d88 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -1396,6 +1396,53 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
>    return FALSE;
>  }
>
> +/* Get version string.  */
> +
> +const char *
> +bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
> +                                  bfd_boolean *hidden)
> +{
> +  const char *version_string = NULL;
> +  if (elf_dynversym (abfd) != 0
> +      && (elf_dynverdef (abfd) != 0 || elf_dynverref (abfd) != 0))
> +    {
> +      unsigned int vernum = ((elf_symbol_type *) symbol)->version;
> +
> +      *hidden = (vernum & VERSYM_HIDDEN) != 0;
> +      vernum &= VERSYM_VERSION;
> +
> +      if (vernum == 0)
> +       version_string = "";
> +      else if (vernum == 1)
> +       version_string = "Base";
> +      else if (vernum <= elf_tdata (abfd)->cverdefs)
> +       version_string =
> +         elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
> +      else
> +       {
> +         Elf_Internal_Verneed *t;
> +
> +         version_string = "";
> +         for (t = elf_tdata (abfd)->verref;
> +              t != NULL;
> +              t = t->vn_nextref)
> +           {
> +             Elf_Internal_Vernaux *a;
> +
> +             for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
> +               {
> +                 if (a->vna_other == vernum)
> +                   {
> +                     version_string = a->vna_nodename;
> +                     break;
> +                   }
> +               }
> +           }
> +       }
> +    }
> +  return version_string;
> +}
> +
>  /* Display ELF-specific fields of a symbol.  */
>
>  void
> @@ -1422,6 +1469,8 @@ bfd_elf_print_symbol (bfd *abfd,
>         const struct elf_backend_data *bed;
>         unsigned char st_other;
>         bfd_vma val;
> +       const char *version_string;
> +       bfd_boolean hidden;
>
>         section_name = symbol->section ? symbol->section->name : "(*none*)";
>
> @@ -1447,45 +1496,12 @@ bfd_elf_print_symbol (bfd *abfd,
>         bfd_fprintf_vma (abfd, file, val);
>
>         /* If we have version information, print it.  */
> -       if (elf_dynversym (abfd) != 0
> -           && (elf_dynverdef (abfd) != 0
> -               || elf_dynverref (abfd) != 0))
> +       version_string = bfd_elf_get_symbol_version_string (abfd,
> +                                                           symbol,
> +                                                           &hidden);
> +       if (version_string)
>           {
> -           unsigned int vernum;
> -           const char *version_string;
> -
> -           vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION;
> -
> -           if (vernum == 0)
> -             version_string = "";
> -           else if (vernum == 1)
> -             version_string = "Base";
> -           else if (vernum <= elf_tdata (abfd)->cverdefs)
> -             version_string =
> -               elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
> -           else
> -             {
> -               Elf_Internal_Verneed *t;
> -
> -               version_string = "";
> -               for (t = elf_tdata (abfd)->verref;
> -                    t != NULL;
> -                    t = t->vn_nextref)
> -                 {
> -                   Elf_Internal_Vernaux *a;
> -
> -                   for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
> -                     {
> -                       if (a->vna_other == vernum)
> -                         {
> -                           version_string = a->vna_nodename;
> -                           break;
> -                         }
> -                     }
> -                 }
> -             }
> -
> -           if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0)
> +           if (!hidden)
>               fprintf (file, "  %-11s", version_string);
>             else
>               {
> diff --git a/binutils/ChangeLog b/binutils/ChangeLog
> index 6f107e1..6545d62 100644
> --- a/binutils/ChangeLog
> +++ b/binutils/ChangeLog
> @@ -1,3 +1,20 @@
> +2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
> +
> +       PR binutils/16496
> +       * objdump.c (objdump_print_symname): Call
> +       bfd_elf_get_symbol_version_string to get ELF symbol version
> +       string.  Append version string if needed.
> +
> +       * readelf.c (versioned_symbol_info): New enum.
> +       (get_symbol_version_string): New.  Extracted from
> +       process_symbol_table.
> +       (dump_relocations): Add a new argument to indicate if dynamic
> +       symbol table is used.  Use get_symbol_version_string to get
> +       symbol version string for dynamic symbol.  Append version string
> +       if needed.
> +       (process_relocs): Updated dump_relocations call.
> +       (process_symbol_table): Use get_symbol_version_string.
> +
>  2014-01-08  H.J. Lu  <hongjiu.lu@intel.com>
>
>         * version.c (print_version): Update copyright year to 2014.
> diff --git a/binutils/objdump.c b/binutils/objdump.c
> index 0098ae7..af7bfce 100644
> --- a/binutils/objdump.c
> +++ b/binutils/objdump.c
> @@ -792,7 +792,8 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
>                        asymbol *sym)
>  {
>    char *alloc;
> -  const char *name;
> +  const char *name, *version_string = NULL;
> +  bfd_boolean hidden = FALSE;
>
>    alloc = NULL;
>    name = bfd_asymbol_name (sym);
> @@ -804,10 +805,26 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
>         name = alloc;
>      }
>
> +  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
> +    version_string = bfd_elf_get_symbol_version_string (abfd, sym,
> +                                                       &hidden);
> +
> +  if (bfd_is_und_section (bfd_get_section (sym)))
> +    hidden = TRUE;
> +
>    if (inf != NULL)
> -    (*inf->fprintf_func) (inf->stream, "%s", name);
> +    {
> +      (*inf->fprintf_func) (inf->stream, "%s", name);
> +      if (version_string && *version_string != '\0')
> +       (*inf->fprintf_func) (inf->stream, hidden ? "@%s" : "@@%s",
> +                             version_string);
> +    }
>    else
> -    printf ("%s", name);
> +    {
> +      printf ("%s", name);
> +      if (version_string && *version_string != '\0')
> +       printf (hidden ? "@%s" : "@@%s", version_string);
> +    }
>
>    if (alloc != NULL)
>      free (alloc);
> diff --git a/binutils/readelf.c b/binutils/readelf.c
> index 7d228d6..669cda7 100644
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -271,6 +271,20 @@ typedef enum print_mode
>  }
>  print_mode;
>
> +/* Versioned symbol info.  */
> +enum versioned_symbol_info
> +{
> +  symbol_undefined,
> +  symbol_hidden,
> +  symbol_public
> +};
> +
> +static const char *get_symbol_version_string
> +  (FILE *file, int is_dynsym, const char *strtab,
> +   unsigned long int strtab_size, unsigned int si,
> +   Elf_Internal_Sym *psym, enum versioned_symbol_info *sym_info,
> +   unsigned short *vna_other);
> +
>  #define UNKNOWN -1
>
>  #define SECTION_NAME(X)                                                \
> @@ -926,7 +940,8 @@ dump_relocations (FILE * file,
>                   unsigned long nsyms,
>                   char * strtab,
>                   unsigned long strtablen,
> -                 int is_rela)
> +                 int is_rela,
> +                 int is_dynsym)
>  {
>    unsigned int i;
>    Elf_Internal_Rela * rels;
> @@ -1360,9 +1375,20 @@ dump_relocations (FILE * file,
>           else
>             {
>               Elf_Internal_Sym * psym;
> +             const char * version_string;
> +             enum versioned_symbol_info sym_info;
> +             unsigned short vna_other;
>
>               psym = symtab + symtab_index;
>
> +             version_string
> +               = get_symbol_version_string (file, is_dynsym,
> +                                            strtab, strtablen,
> +                                            symtab_index,
> +                                            psym,
> +                                            &sym_info,
> +                                            &vna_other);
> +
>               printf (" ");
>
>               if (ELF_ST_TYPE (psym->st_info) == STT_GNU_IFUNC)
> @@ -1389,6 +1415,9 @@ dump_relocations (FILE * file,
>                     name = strtab + psym->st_name;
>
>                   len = print_symbol (width, name);
> +                 if (version_string)
> +                   printf (sym_info == symbol_public ? "@@%s" : "@%s",
> +                           version_string);
>                   printf ("()%-*s", len <= width ? (width + 1) - len : 1, " ");
>                 }
>               else
> @@ -1446,7 +1475,12 @@ dump_relocations (FILE * file,
>               else if (psym->st_name >= strtablen)
>                 printf (_("<corrupt string table index: %3ld>"), psym->st_name);
>               else
> -               print_symbol (22, strtab + psym->st_name);
> +               {
> +                 print_symbol (22, strtab + psym->st_name);
> +                 if (version_string)
> +                   printf (sym_info == symbol_public ? "@@%s" : "@%s",
> +                           version_string);
> +               }
>
>               if (is_rela)
>                 {
> @@ -5920,7 +5954,8 @@ process_relocs (FILE * file)
>                                 offset_from_vma (file, rel_offset, rel_size),
>                                 rel_size,
>                                 dynamic_symbols, num_dynamic_syms,
> -                               dynamic_strings, dynamic_strings_length, is_rela);
> +                               dynamic_strings, dynamic_strings_length,
> +                               is_rela, 1);
>             }
>         }
>
> @@ -5995,14 +6030,16 @@ process_relocs (FILE * file)
>                     }
>
>                   dump_relocations (file, rel_offset, rel_size,
> -                                   symtab, nsyms, strtab, strtablen, is_rela);
> +                                   symtab, nsyms, strtab, strtablen,
> +                                   is_rela,
> +                                   symsec->sh_type == SHT_DYNSYM);
>                   if (strtab)
>                     free (strtab);
>                   free (symtab);
>                 }
>               else
>                 dump_relocations (file, rel_offset, rel_size,
> -                                 NULL, 0, NULL, 0, is_rela);
> +                                 NULL, 0, NULL, 0, is_rela, 0);
>
>               found = 1;
>             }
> @@ -9581,6 +9618,181 @@ print_dynamic_symbol (bfd_vma si, unsigned long hn)
>    putchar ('\n');
>  }
>
> +static const char *
> +get_symbol_version_string (FILE *file, int is_dynsym,
> +                          const char *strtab,
> +                          unsigned long int strtab_size,
> +                          unsigned int si, Elf_Internal_Sym *psym,
> +                          enum versioned_symbol_info *sym_info,
> +                          unsigned short *vna_other)
> +{
> +  const char *version_string = NULL;
> +
> +  if (is_dynsym
> +      && version_info[DT_VERSIONTAGIDX (DT_VERSYM)] != 0)
> +    {
> +      unsigned char data[2];
> +      unsigned short vers_data;
> +      unsigned long offset;
> +      int is_nobits;
> +      int check_def;
> +
> +      offset = offset_from_vma
> +       (file, version_info[DT_VERSIONTAGIDX (DT_VERSYM)],
> +        sizeof data + si * sizeof (vers_data));
> +
> +      if (get_data (&data, file, offset + si * sizeof (vers_data),
> +                   sizeof (data), 1, _("version data")) == NULL)
> +       return NULL;
> +
> +      vers_data = byte_get (data, 2);
> +
> +      is_nobits = (psym->st_shndx < elf_header.e_shnum
> +                  && section_headers[psym->st_shndx].sh_type
> +                  == SHT_NOBITS);
> +
> +      check_def = (psym->st_shndx != SHN_UNDEF);
> +
> +      if ((vers_data & VERSYM_HIDDEN) || vers_data > 1)
> +       {
> +         if (version_info[DT_VERSIONTAGIDX (DT_VERNEED)]
> +             && (is_nobits || ! check_def))
> +           {
> +             Elf_External_Verneed evn;
> +             Elf_Internal_Verneed ivn;
> +             Elf_Internal_Vernaux ivna;
> +
> +             /* We must test both.  */
> +             offset = offset_from_vma
> +               (file, version_info[DT_VERSIONTAGIDX (DT_VERNEED)],
> +                sizeof evn);
> +
> +             do
> +               {
> +                 unsigned long vna_off;
> +
> +                 if (get_data (&evn, file, offset, sizeof (evn), 1,
> +                               _("version need")) == NULL)
> +                   {
> +                     ivna.vna_next = 0;
> +                     ivna.vna_other = 0;
> +                     ivna.vna_name = 0;
> +                     break;
> +                   }
> +
> +                 ivn.vn_aux  = BYTE_GET (evn.vn_aux);
> +                 ivn.vn_next = BYTE_GET (evn.vn_next);
> +
> +                 vna_off = offset + ivn.vn_aux;
> +
> +                 do
> +                   {
> +                     Elf_External_Vernaux evna;
> +
> +                     if (get_data (&evna, file, vna_off,
> +                                   sizeof (evna), 1,
> +                                   _("version need aux (3)")) == NULL)
> +                       {
> +                         ivna.vna_next = 0;
> +                         ivna.vna_other = 0;
> +                         ivna.vna_name = 0;
> +                       }
> +                     else
> +                       {
> +                         ivna.vna_other = BYTE_GET (evna.vna_other);
> +                         ivna.vna_next  = BYTE_GET (evna.vna_next);
> +                         ivna.vna_name  = BYTE_GET (evna.vna_name);
> +                       }
> +
> +                     vna_off += ivna.vna_next;
> +                   }
> +                 while (ivna.vna_other != vers_data
> +                        && ivna.vna_next != 0);
> +
> +                 if (ivna.vna_other == vers_data)
> +                   break;
> +
> +                 offset += ivn.vn_next;
> +               }
> +             while (ivn.vn_next != 0);
> +
> +             if (ivna.vna_other == vers_data)
> +               {
> +                 *sym_info = symbol_undefined;
> +                 *vna_other = ivna.vna_other;
> +                 version_string = (ivna.vna_name < strtab_size
> +                                   ? strtab + ivna.vna_name
> +                                   : _("<corrupt>"));
> +                 check_def = 0;
> +               }
> +             else if (! is_nobits)
> +               error (_("bad dynamic symbol\n"));
> +             else
> +               check_def = 1;
> +           }
> +
> +         if (check_def)
> +           {
> +             if (vers_data != 0x8001
> +                 && version_info[DT_VERSIONTAGIDX (DT_VERDEF)])
> +               {
> +                 Elf_Internal_Verdef ivd;
> +                 Elf_Internal_Verdaux ivda;
> +                 Elf_External_Verdaux evda;
> +                 unsigned long off;
> +
> +                 off = offset_from_vma
> +                   (file,
> +                    version_info[DT_VERSIONTAGIDX (DT_VERDEF)],
> +                    sizeof (Elf_External_Verdef));
> +
> +                 do
> +                   {
> +                     Elf_External_Verdef evd;
> +
> +                     if (get_data (&evd, file, off, sizeof (evd),
> +                                   1, _("version def")) == NULL)
> +                       {
> +                         ivd.vd_ndx = 0;
> +                         ivd.vd_aux = 0;
> +                         ivd.vd_next = 0;
> +                       }
> +                     else
> +                       {
> +                         ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
> +                         ivd.vd_aux = BYTE_GET (evd.vd_aux);
> +                         ivd.vd_next = BYTE_GET (evd.vd_next);
> +                       }
> +
> +                     off += ivd.vd_next;
> +                   }
> +                 while (ivd.vd_ndx != (vers_data & VERSYM_VERSION)
> +                        && ivd.vd_next != 0);
> +
> +                 off -= ivd.vd_next;
> +                 off += ivd.vd_aux;
> +
> +                 if (get_data (&evda, file, off, sizeof (evda),
> +                               1, _("version def aux")) == NULL)
> +                   return version_string;
> +
> +                 ivda.vda_name = BYTE_GET (evda.vda_name);
> +
> +                 if (psym->st_name != ivda.vda_name)
> +                   {
> +                     *sym_info = ((vers_data & VERSYM_HIDDEN) != 0
> +                                  ? symbol_hidden : symbol_public);
> +                     version_string = (ivda.vda_name < strtab_size
> +                                       ? strtab + ivda.vda_name
> +                                       : _("<corrupt>"));
> +                   }
> +               }
> +           }
> +       }
> +    }
> +  return version_string;
> +}
> +
>  /* Dump the symbol table.  */
>  static int
>  process_symbol_table (FILE * file)
> @@ -9877,6 +10089,10 @@ process_symbol_table (FILE * file)
>
>           for (si = 0, psym = symtab; si < num_syms; si++, psym++)
>             {
> +             const char *version_string;
> +             enum versioned_symbol_info sym_info;
> +             unsigned short vna_other;
> +
>               printf ("%6d: ", si);
>               print_vma (psym->st_value, LONG_HEX);
>               putchar (' ');
> @@ -9893,163 +10109,18 @@ process_symbol_table (FILE * file)
>               print_symbol (25, psym->st_name < strtab_size
>                             ? strtab + psym->st_name : _("<corrupt>"));
>
> -             if (section->sh_type == SHT_DYNSYM
> -                 && version_info[DT_VERSIONTAGIDX (DT_VERSYM)] != 0)
> +             version_string
> +               = get_symbol_version_string (file,
> +                                            section->sh_type == SHT_DYNSYM,
> +                                            strtab, strtab_size, si,
> +                                            psym, &sym_info, &vna_other);
> +             if (version_string)
>                 {
> -                 unsigned char data[2];
> -                 unsigned short vers_data;
> -                 unsigned long offset;
> -                 int is_nobits;
> -                 int check_def;
> -
> -                 offset = offset_from_vma
> -                   (file, version_info[DT_VERSIONTAGIDX (DT_VERSYM)],
> -                    sizeof data + si * sizeof (vers_data));
> -
> -                 if (get_data (&data, file, offset + si * sizeof (vers_data),
> -                               sizeof (data), 1, _("version data")) == NULL)
> -                   break;
> -
> -                 vers_data = byte_get (data, 2);
> -
> -                 is_nobits = (psym->st_shndx < elf_header.e_shnum
> -                              && section_headers[psym->st_shndx].sh_type
> -                                 == SHT_NOBITS);
> -
> -                 check_def = (psym->st_shndx != SHN_UNDEF);
> -
> -                 if ((vers_data & VERSYM_HIDDEN) || vers_data > 1)
> -                   {
> -                     if (version_info[DT_VERSIONTAGIDX (DT_VERNEED)]
> -                         && (is_nobits || ! check_def))
> -                       {
> -                         Elf_External_Verneed evn;
> -                         Elf_Internal_Verneed ivn;
> -                         Elf_Internal_Vernaux ivna;
> -
> -                         /* We must test both.  */
> -                         offset = offset_from_vma
> -                           (file, version_info[DT_VERSIONTAGIDX (DT_VERNEED)],
> -                            sizeof evn);
> -
> -                         do
> -                           {
> -                             unsigned long vna_off;
> -
> -                             if (get_data (&evn, file, offset, sizeof (evn), 1,
> -                                           _("version need")) == NULL)
> -                               {
> -                                 ivna.vna_next = 0;
> -                                 ivna.vna_other = 0;
> -                                 ivna.vna_name = 0;
> -                                 break;
> -                               }
> -
> -                             ivn.vn_aux  = BYTE_GET (evn.vn_aux);
> -                             ivn.vn_next = BYTE_GET (evn.vn_next);
> -
> -                             vna_off = offset + ivn.vn_aux;
> -
> -                             do
> -                               {
> -                                 Elf_External_Vernaux evna;
> -
> -                                 if (get_data (&evna, file, vna_off,
> -                                               sizeof (evna), 1,
> -                                               _("version need aux (3)")) == NULL)
> -                                   {
> -                                     ivna.vna_next = 0;
> -                                     ivna.vna_other = 0;
> -                                     ivna.vna_name = 0;
> -                                   }
> -                                 else
> -                                   {
> -                                     ivna.vna_other = BYTE_GET (evna.vna_other);
> -                                     ivna.vna_next  = BYTE_GET (evna.vna_next);
> -                                     ivna.vna_name  = BYTE_GET (evna.vna_name);
> -                                   }
> -
> -                                 vna_off += ivna.vna_next;
> -                               }
> -                             while (ivna.vna_other != vers_data
> -                                    && ivna.vna_next != 0);
> -
> -                             if (ivna.vna_other == vers_data)
> -                               break;
> -
> -                             offset += ivn.vn_next;
> -                           }
> -                         while (ivn.vn_next != 0);
> -
> -                         if (ivna.vna_other == vers_data)
> -                           {
> -                             printf ("@%s (%d)",
> -                                     ivna.vna_name < strtab_size
> -                                     ? strtab + ivna.vna_name : _("<corrupt>"),
> -                                     ivna.vna_other);
> -                             check_def = 0;
> -                           }
> -                         else if (! is_nobits)
> -                           error (_("bad dynamic symbol\n"));
> -                         else
> -                           check_def = 1;
> -                       }
> -
> -                     if (check_def)
> -                       {
> -                         if (vers_data != 0x8001
> -                             && version_info[DT_VERSIONTAGIDX (DT_VERDEF)])
> -                           {
> -                             Elf_Internal_Verdef ivd;
> -                             Elf_Internal_Verdaux ivda;
> -                             Elf_External_Verdaux evda;
> -                             unsigned long off;
> -
> -                             off = offset_from_vma
> -                               (file,
> -                                version_info[DT_VERSIONTAGIDX (DT_VERDEF)],
> -                                sizeof (Elf_External_Verdef));
> -
> -                             do
> -                               {
> -                                 Elf_External_Verdef evd;
> -
> -                                 if (get_data (&evd, file, off, sizeof (evd),
> -                                               1, _("version def")) == NULL)
> -                                   {
> -                                     ivd.vd_ndx = 0;
> -                                     ivd.vd_aux = 0;
> -                                     ivd.vd_next = 0;
> -                                   }
> -                                 else
> -                                   {
> -                                     ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
> -                                     ivd.vd_aux = BYTE_GET (evd.vd_aux);
> -                                     ivd.vd_next = BYTE_GET (evd.vd_next);
> -                                   }
> -
> -                                 off += ivd.vd_next;
> -                               }
> -                             while (ivd.vd_ndx != (vers_data & VERSYM_VERSION)
> -                                    && ivd.vd_next != 0);
> -
> -                             off -= ivd.vd_next;
> -                             off += ivd.vd_aux;
> -
> -                             if (get_data (&evda, file, off, sizeof (evda),
> -                                           1, _("version def aux")) == NULL)
> -                               break;
> -
> -                             ivda.vda_name = BYTE_GET (evda.vda_name);
> -
> -                             if (psym->st_name != ivda.vda_name)
> -                               printf ((vers_data & VERSYM_HIDDEN)
> -                                       ? "@%s" : "@@%s",
> -                                       ivda.vda_name < strtab_size
> -                                       ? strtab + ivda.vda_name : _("<corrupt>"));
> -                           }
> -                       }
> -                   }
> +                 if (sym_info == symbol_undefined)
> +                   printf ("@%s (%d)", version_string, vna_other);
> +                 else
> +                   printf (sym_info == symbol_hidden ? "@%s" : "@@%s",
> +                           version_string);
>                 }
>
>               putchar ('\n');
> diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
> index 39cc0fb..e104817 100644
> --- a/ld/testsuite/ChangeLog
> +++ b/ld/testsuite/ChangeLog
> @@ -1,5 +1,21 @@
>  2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
>
> +       PR binutils/16496
> +       * ld-cris/weakref3.d: Add symbol version string to versioned
> +       symbol names in dynamic relocation.
> +       * ld-cris/weakref4.d: Likewise.
> +       * ld-elfvers/vers24.rd: Likewise.
> +
> +       * ld-elf/pr16496a.c: New file.
> +       * ld-elf/pr16496a.map: Likewise.
> +       * ld-elf/pr16496b.c: Likewise.
> +       * ld-elf/pr16496b.od: Likewise.
> +
> +       * ld-elf/shared.exp (build_tests): Add libpr16496a.so and
> +       libpr16496b.so tests.
> +
> +2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
> +
>         * ld-elf/pr16498a.s: Replace .align with .p2align.
>
>  2014-01-24  H.J. Lu  <hongjiu.lu@intel.com>
> diff --git a/ld/testsuite/ld-cris/weakref3.d b/ld/testsuite/ld-cris/weakref3.d
> index aea3ad6..4807106 100644
> --- a/ld/testsuite/ld-cris/weakref3.d
> +++ b/ld/testsuite/ld-cris/weakref3.d
> @@ -16,11 +16,11 @@
>  #...
>  Relocation section '.rela.dyn' at offset 0x... contains 1 entries:
>   Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
> -.* R_CRIS_COPY .* __expobj2 \+ 0
> +.* R_CRIS_COPY .* __expobj2@TST3 \+ 0
>
>  Relocation section '.rela.plt' at offset 0x... contains 1 entries:
>   Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
> -.* R_CRIS_JUMP_SLOT .* expfn2 \+ 0
> +.* R_CRIS_JUMP_SLOT .* expfn2@TST3 \+ 0
>
>  The decoding of unwind sections for machine type Axis Communications 32-bit embedded processor is not currently supported.
>
> diff --git a/ld/testsuite/ld-cris/weakref4.d b/ld/testsuite/ld-cris/weakref4.d
> index 79de291..aed0f39 100644
> --- a/ld/testsuite/ld-cris/weakref4.d
> +++ b/ld/testsuite/ld-cris/weakref4.d
> @@ -17,7 +17,7 @@
>  #...
>  Relocation section '.rela.dyn' at offset 0x... contains 1 entries:
>  #...
> -.* R_CRIS_COPY .* __expobj2 \+ 0
> +.* R_CRIS_COPY .* __expobj2@TST3 \+ 0
>
>  The decoding of unwind sections for machine type Axis Communications 32-bit embedded processor is not currently supported.
>
> diff --git a/ld/testsuite/ld-elf/pr16496a.c b/ld/testsuite/ld-elf/pr16496a.c
> new file mode 100644
> index 0000000..35e8555
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/pr16496a.c
> @@ -0,0 +1,4 @@
> +void
> +sd_get_seats (void)
> +{
> +}
> diff --git a/ld/testsuite/ld-elf/pr16496a.map b/ld/testsuite/ld-elf/pr16496a.map
> new file mode 100644
> index 0000000..d677f37
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/pr16496a.map
> @@ -0,0 +1,4 @@
> +LIBSYSTEMD_209 {
> +global:
> +        sd_get_seats;
> +};
> diff --git a/ld/testsuite/ld-elf/pr16496b.c b/ld/testsuite/ld-elf/pr16496b.c
> new file mode 100644
> index 0000000..94a0f30
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/pr16496b.c
> @@ -0,0 +1,5 @@
> +void sd_get_seats (void);
> +void call_sd_get_seats (void)
> +{
> +  sd_get_seats ();
> +}
> diff --git a/ld/testsuite/ld-elf/pr16496b.od b/ld/testsuite/ld-elf/pr16496b.od
> new file mode 100644
> index 0000000..6fb54c1
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/pr16496b.od
> @@ -0,0 +1,3 @@
> +#...
> +.* sd_get_seats@LIBSYSTEMD_209
> +#pass
> diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
> index bbfd464..da5f8e4 100644
> --- a/ld/testsuite/ld-elf/shared.exp
> +++ b/ld/testsuite/ld-elf/shared.exp
> @@ -224,6 +224,15 @@ set build_tests {
>    {"Build libpr2404b.a"
>     "" ""
>     {pr2404b.c} {} "libpr2404b.a"}
> +  {"Build libpr16496a.so"
> +   "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
> +   {pr16496a.c} {} "libpr16496a.so"}
> +  {"Build libpr16496b.a"
> +   "" "-fPIC"
> +   {pr16496b.c} {} "libpr16496b.a"}
> +  {"Build libpr16496b.so"
> +   "-shared tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
> +   {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
>  }
>
>  run_cc_link_tests $build_tests
> diff --git a/ld/testsuite/ld-elfvers/vers24.rd b/ld/testsuite/ld-elfvers/vers24.rd
> index fb464f9..2360447 100644
> --- a/ld/testsuite/ld-elfvers/vers24.rd
> +++ b/ld/testsuite/ld-elfvers/vers24.rd
> @@ -1,7 +1,7 @@
>  Relocation section .*
>  # Ensure there is a dynamic relocation against x
>  #...
> -[0-9a-f]+ +[0-9a-f]+ R_.* +_?x(| \+ 0)
> +[0-9a-f]+ +[0-9a-f]+ R_.* +_?x@VERS.0(| \+ 0)
>  #...
>  Symbol table '.dynsym' contains [0-9]+ entries:
>  # And ensure the dynamic symbol table contains at least x@VERS.0
> --
> 1.8.4.2
>

Does anyone have comments on this?

-- 
H.J.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-01-30  5:33 ` H.J. Lu
@ 2014-01-30  9:39   ` Andreas Schwab
  2014-01-30 12:41     ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2014-01-30  9:39 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

Since it breaks building glibc, perhaps there is another way to display
the symbol version?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-01-30  9:39   ` Andreas Schwab
@ 2014-01-30 12:41     ` H.J. Lu
  2014-11-25 14:36       ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2014-01-30 12:41 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Binutils

On Thu, Jan 30, 2014 at 1:39 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Since it breaks building glibc, perhaps there is another way to display

It is the most consistent way to display symbol version.  But It did cause:

make[4]: *** [/export/build/gnu/glibc/build-x86_64-linux/elf/check-localplt.out]
Error 1
Extra PLT reference: libc.so: realloc@@GLIBC_2.2.5
Extra PLT reference: libc.so: malloc@@GLIBC_2.2.5
Extra PLT reference: libc.so: memalign@@GLIBC_2.2.5
Extra PLT reference: libc.so: calloc@@GLIBC_2.2.5
Extra PLT reference: libc.so: free@@GLIBC_2.2.5
Extra PLT reference: libm.so: matherr@@GLIBC_2.2.5
Missing required PLT reference: libc.so: realloc
Missing required PLT reference: libc.so: malloc
Missing required PLT reference: libc.so: calloc
Missing required PLT reference: libc.so: memalign
Missing required PLT reference: libc.so: free
Missing required PLT reference: libm.so: matherr

It is easy to fix by stripping @@GLIBC_2.2.5 from readelf -r output.

> the symbol version?
>


-- 
H.J.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-01-30 12:41     ` H.J. Lu
@ 2014-11-25 14:36       ` H.J. Lu
  2014-11-25 17:37         ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2014-11-25 14:36 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Binutils

On Thu, Jan 30, 2014 at 4:41 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Jan 30, 2014 at 1:39 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> Since it breaks building glibc, perhaps there is another way to display
>
> It is the most consistent way to display symbol version.  But It did cause:
>
> make[4]: *** [/export/build/gnu/glibc/build-x86_64-linux/elf/check-localplt.out]
> Error 1
> Extra PLT reference: libc.so: realloc@@GLIBC_2.2.5
> Extra PLT reference: libc.so: malloc@@GLIBC_2.2.5
> Extra PLT reference: libc.so: memalign@@GLIBC_2.2.5
> Extra PLT reference: libc.so: calloc@@GLIBC_2.2.5
> Extra PLT reference: libc.so: free@@GLIBC_2.2.5
> Extra PLT reference: libm.so: matherr@@GLIBC_2.2.5
> Missing required PLT reference: libc.so: realloc
> Missing required PLT reference: libc.so: malloc
> Missing required PLT reference: libc.so: calloc
> Missing required PLT reference: libc.so: memalign
> Missing required PLT reference: libc.so: free
> Missing required PLT reference: libm.so: matherr
>
> It is easy to fix by stripping @@GLIBC_2.2.5 from readelf -r output.
>
>> the symbol version?

A very old patch:

https://sourceware.org/ml/binutils/2014-01/msg00310.html

My binutils PLT optimization commit:

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=dd7e64d45b317128f5fe813a8da0b13b4ad046ae

will require updating elf/check-localplt test in glibc.  I am checking in this
so that elf/check-localplt will be updated for both.

-- 
H.J.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-11-25 14:36       ` H.J. Lu
@ 2014-11-25 17:37         ` H.J. Lu
  2014-11-27  8:33           ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2014-11-25 17:37 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Binutils

[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]

On Tue, Nov 25, 2014 at 6:36 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Jan 30, 2014 at 4:41 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Jan 30, 2014 at 1:39 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>> Since it breaks building glibc, perhaps there is another way to display
>>
>> It is the most consistent way to display symbol version.  But It did cause:
>>
>> make[4]: *** [/export/build/gnu/glibc/build-x86_64-linux/elf/check-localplt.out]
>> Error 1
>> Extra PLT reference: libc.so: realloc@@GLIBC_2.2.5
>> Extra PLT reference: libc.so: malloc@@GLIBC_2.2.5
>> Extra PLT reference: libc.so: memalign@@GLIBC_2.2.5
>> Extra PLT reference: libc.so: calloc@@GLIBC_2.2.5
>> Extra PLT reference: libc.so: free@@GLIBC_2.2.5
>> Extra PLT reference: libm.so: matherr@@GLIBC_2.2.5
>> Missing required PLT reference: libc.so: realloc
>> Missing required PLT reference: libc.so: malloc
>> Missing required PLT reference: libc.so: calloc
>> Missing required PLT reference: libc.so: memalign
>> Missing required PLT reference: libc.so: free
>> Missing required PLT reference: libm.so: matherr
>>
>> It is easy to fix by stripping @@GLIBC_2.2.5 from readelf -r output.
>>
>>> the symbol version?
>
> A very old patch:
>
> https://sourceware.org/ml/binutils/2014-01/msg00310.html
>
> My binutils PLT optimization commit:
>
> https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=dd7e64d45b317128f5fe813a8da0b13b4ad046ae
>
> will require updating elf/check-localplt test in glibc.  I am checking in this
> so that elf/check-localplt will be updated for both.
>

I checked in this patch to add get_symbol_version_string to
BFD_JUMP_TABLE_SYMBOLS so that we can use
bfd_get_symbol_version_string in objdump for non-ELF targets.


-- 
H.J.

[-- Attachment #2: 0001-Use-get_symbol_version_string-in-BFD_JUMP_TABLE_SYMB.patch --]
[-- Type: text/x-patch, Size: 29621 bytes --]

From 60bb06bc89858ee50ad02907a833565dcc317182 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 25 Nov 2014 09:28:32 -0800
Subject: [PATCH] Use get_symbol_version_string in BFD_JUMP_TABLE_SYMBOLS

This patch adds get_symbol_version_string to BFD_JUMP_TABLE_SYMBOLS so
that we can use bfd_get_symbol_version_string in objdump for non-ELF
targets.

bfd/

	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Use
	NAME##_get_symbol_version_string.
	(bfd_get_symbol_version_string): New.
	* aout-adobe.c (aout_32_get_symbol_version_string): Define using
	_bfd_nosymbols define.
	* aout-target.h (MY_get_symbol_version_string): Likewise.
	* aout-tic30.c (MY_get_symbol_version_string): Likewise.
	* binary.c (binary_get_symbol_version_string): Likewise.
	* bout.c (aout_32_get_symbol_version_string): Likewise.
	* coff-rs6000.c (_bfd_xcoff_get_symbol_version_string): Likewise.
	* i386msdos.c (msdos_get_symbol_version_string): Likewise.
	* i386os9k.c (aout_32_get_symbol_version_string): Likewise.
	* ieee.c (ieee_get_symbol_version_string): Likewise.
	* ihex.c (ihex_get_symbol_version_string): Likewise.
	* libecoff.h (_bfd_ecoff_get_symbol_version_string): Likewise.
	* mach-o-target.c (bfd_mach_o_get_symbol_version_string): Likewise.
	* mmo.c (mmo_get_symbol_version_string): Likewise.
	* nlm-target.h (nlm_get_symbol_version_string): Likewise.
	* oasys.c (oasys_get_symbol_version_string): Likewise.
	* pef.c (bfd_pef_get_symbol_version_string): Likewise.
	* plugin.c (bfd_plugin_get_symbol_version_string): Likewise.
	* ppcboot.c (ppcboot_get_symbol_version_string): Likewise.
	* som.c (som_get_symbol_version_string): Likewise.
	* srec.c (srec_get_symbol_version_string): Likewise.
	* tekhex.c (tekhex_get_symbol_version_string): Likewise.
	* versados.c (versados_get_symbol_version_string): Likewise.
	* vms-alpha.c (alpha_vms_get_symbol_version_string): Likewise.
	* xsym.c (bfd_sym_get_symbol_version_string): Likewise.

	* coff64-rs6000.c (rs6000_xcoff64_vec): Use
	coff_get_symbol_version_string.
	(rs6000_xcoff64_aix_vec): Likewise.

	* elf-bfd.h (bfd_elf_get_symbol_version_string): Renamed to ...
	(_bfd_elf_get_symbol_version_string): This.
	* elf.c: Likewise.
	(bfd_elf_print_symbol): Updated.
	* elfxx-target.h (bfd_elfNN_get_symbol_version_string): Define.

	* libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Define.
	* libcoff-in.h (coff_get_symbol_version_string): Likewise.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.
	* libcoff.h: Likewise.

binutils/

	* objdump.c (objdump_print_symname): Replace
	bfd_elf_get_symbol_version_string with
	bfd_get_symbol_version_string.
---
 bfd/ChangeLog       | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 bfd/aout-adobe.c    |  1 +
 bfd/aout-target.h   |  4 ++++
 bfd/aout-tic30.c    |  4 ++++
 bfd/bfd-in2.h       |  4 ++++
 bfd/binary.c        |  2 ++
 bfd/bout.c          |  1 +
 bfd/coff-rs6000.c   |  2 ++
 bfd/coff64-rs6000.c |  2 ++
 bfd/elf-bfd.h       |  2 +-
 bfd/elf.c           | 10 +++++-----
 bfd/elfxx-target.h  |  4 ++++
 bfd/i386msdos.c     |  2 ++
 bfd/i386os9k.c      |  2 ++
 bfd/ieee.c          |  2 ++
 bfd/ihex.c          |  1 +
 bfd/libbfd-in.h     |  2 ++
 bfd/libbfd.h        |  2 ++
 bfd/libcoff-in.h    |  2 ++
 bfd/libcoff.h       |  2 ++
 bfd/libecoff.h      |  2 ++
 bfd/mach-o-target.c |  1 +
 bfd/mmo.c           |  3 +++
 bfd/nlm-target.h    |  1 +
 bfd/oasys.c         |  1 +
 bfd/pef.c           |  1 +
 bfd/plugin.c        |  1 +
 bfd/ppcboot.c       |  2 ++
 bfd/som.c           |  1 +
 bfd/srec.c          |  1 +
 bfd/targets.c       |  4 ++++
 bfd/tekhex.c        |  1 +
 bfd/versados.c      |  1 +
 bfd/vms-alpha.c     |  3 +++
 bfd/xsym.c          |  1 +
 binutils/ChangeLog  |  6 ++++++
 binutils/objdump.c  |  4 +---
 37 files changed, 123 insertions(+), 9 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7b3971e..54942a1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,52 @@
 2014-11-25  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Use
+	NAME##_get_symbol_version_string.
+	(bfd_get_symbol_version_string): New.
+	* aout-adobe.c (aout_32_get_symbol_version_string): Define using
+	_bfd_nosymbols define.
+	* aout-target.h (MY_get_symbol_version_string): Likewise.
+	* aout-tic30.c (MY_get_symbol_version_string): Likewise.
+	* binary.c (binary_get_symbol_version_string): Likewise.
+	* bout.c (aout_32_get_symbol_version_string): Likewise.
+	* coff-rs6000.c (_bfd_xcoff_get_symbol_version_string): Likewise.
+	* i386msdos.c (msdos_get_symbol_version_string): Likewise.
+	* i386os9k.c (aout_32_get_symbol_version_string): Likewise.
+	* ieee.c (ieee_get_symbol_version_string): Likewise.
+	* ihex.c (ihex_get_symbol_version_string): Likewise.
+	* libecoff.h (_bfd_ecoff_get_symbol_version_string): Likewise.
+	* mach-o-target.c (bfd_mach_o_get_symbol_version_string): Likewise.
+	* mmo.c (mmo_get_symbol_version_string): Likewise.
+	* nlm-target.h (nlm_get_symbol_version_string): Likewise.
+	* oasys.c (oasys_get_symbol_version_string): Likewise.
+	* pef.c (bfd_pef_get_symbol_version_string): Likewise.
+	* plugin.c (bfd_plugin_get_symbol_version_string): Likewise.
+	* ppcboot.c (ppcboot_get_symbol_version_string): Likewise.
+	* som.c (som_get_symbol_version_string): Likewise.
+	* srec.c (srec_get_symbol_version_string): Likewise.
+	* tekhex.c (tekhex_get_symbol_version_string): Likewise.
+	* versados.c (versados_get_symbol_version_string): Likewise.
+	* vms-alpha.c (alpha_vms_get_symbol_version_string): Likewise.
+	* xsym.c (bfd_sym_get_symbol_version_string): Likewise.
+
+	* coff64-rs6000.c (rs6000_xcoff64_vec): Use
+	coff_get_symbol_version_string.
+	(rs6000_xcoff64_aix_vec): Likewise.
+
+	* elf-bfd.h (bfd_elf_get_symbol_version_string): Renamed to ...
+	(_bfd_elf_get_symbol_version_string): This.
+	* elf.c: Likewise.
+	(bfd_elf_print_symbol): Updated.
+	* elfxx-target.h (bfd_elfNN_get_symbol_version_string): Define.
+
+	* libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Define.
+	* libcoff-in.h (coff_get_symbol_version_string): Likewise.
+	* bfd-in2.h: Regenerated.
+	* libbfd.h: Likewise.
+	* libcoff.h: Likewise.
+
+2014-11-25  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR binutils/16496
 	* elf-bfd.h (bfd_elf_get_symbol_version_string): New.
 	* elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c
index cfdcc64..50394a2 100644
--- a/bfd/aout-adobe.c
+++ b/bfd/aout-adobe.c
@@ -447,6 +447,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED,
 /* Build the transfer vector for Adobe A.Out files.  */
 
 #define aout_32_find_line			    _bfd_nosymbols_find_line
+#define aout_32_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
 #define aout_32_bfd_make_debug_symbol		    _bfd_nosymbols_bfd_make_debug_symbol
 #define aout_32_bfd_reloc_type_lookup		    _bfd_norelocs_bfd_reloc_type_lookup
 #define aout_32_bfd_reloc_name_lookup		    _bfd_norelocs_bfd_reloc_name_lookup
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index 3bca8b5..7982bf0 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -459,6 +459,10 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_get_symbol_info
 #define MY_get_symbol_info NAME (aout, get_symbol_info)
 #endif
+#ifndef MY_get_symbol_version_string
+#define MY_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
+#endif
 #ifndef MY_get_lineno
 #define MY_get_lineno NAME (aout, get_lineno)
 #endif
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index e74464d..e164446 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -917,6 +917,10 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_get_symbol_info
 #define MY_get_symbol_info NAME (aout, get_symbol_info)
 #endif
+#ifndef MY_get_symbol_version_string
+#define MY_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
+#endif
 #ifndef MY_get_lineno
 #define MY_get_lineno NAME (aout, get_lineno)
 #endif
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 433b171..ed7be29 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7015,6 +7015,7 @@ typedef struct bfd_target
   NAME##_make_empty_symbol, \
   NAME##_print_symbol, \
   NAME##_get_symbol_info, \
+  NAME##_get_symbol_version_string, \
   NAME##_bfd_is_local_label_name, \
   NAME##_bfd_is_target_special_symbol, \
   NAME##_get_lineno, \
@@ -7036,6 +7037,9 @@ typedef struct bfd_target
   void        (*_bfd_get_symbol_info)
     (bfd *, struct bfd_symbol *, symbol_info *);
 #define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
+  const char *(*_bfd_get_symbol_version_string)
+    (bfd *, struct bfd_symbol *, bfd_boolean *);
+#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h))
   bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
   bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
   alent *     (*_get_lineno) (bfd *, struct bfd_symbol *);
diff --git a/bfd/binary.c b/bfd/binary.c
index d35e859..93a0cff 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -190,6 +190,8 @@ binary_canonicalize_symtab (bfd *abfd, asymbol **alocation)
 
 #define binary_make_empty_symbol  _bfd_generic_make_empty_symbol
 #define binary_print_symbol       _bfd_nosymbols_print_symbol
+#define binary_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 
 /* Get information about a symbol.  */
 
diff --git a/bfd/bout.c b/bfd/bout.c
index a27df58..de9c7c7 100644
--- a/bfd/bout.c
+++ b/bfd/bout.c
@@ -1375,6 +1375,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd,
 /* Build the transfer vectors for Big and Little-Endian B.OUT files.  */
 
 #define aout_32_find_line                      _bfd_nosymbols_find_line
+#define aout_32_get_symbol_version_string      _bfd_nosymbols_get_symbol_version_string
 #define aout_32_bfd_make_debug_symbol          _bfd_nosymbols_bfd_make_debug_symbol
 #define aout_32_close_and_cleanup              aout_32_bfd_free_cached_info
 #define b_out_bfd_link_hash_table_create       _bfd_generic_link_hash_table_create
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index fea5f3b..05c45cf 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -4008,6 +4008,8 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #define _bfd_xcoff_make_empty_symbol coff_make_empty_symbol
 #define _bfd_xcoff_print_symbol coff_print_symbol
 #define _bfd_xcoff_get_symbol_info coff_get_symbol_info
+#define _bfd_xcoff_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 #define _bfd_xcoff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
 #define _bfd_xcoff_bfd_is_target_special_symbol \
   coff_bfd_is_target_special_symbol
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 5985d81..72ea58b 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2712,6 +2712,7 @@ const bfd_target rs6000_xcoff64_vec =
     coff_make_empty_symbol,
     coff_print_symbol,
     coff_get_symbol_info,
+    coff_get_symbol_version_string,
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
     coff_get_lineno,
@@ -2969,6 +2970,7 @@ const bfd_target rs6000_xcoff64_aix_vec =
     coff_make_empty_symbol,
     coff_print_symbol,
     coff_get_symbol_info,
+    coff_get_symbol_version_string,
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
     coff_get_lineno,
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index bee0ea1..4368658 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1772,7 +1772,7 @@ extern bfd_boolean _bfd_elf_copy_private_bfd_data
   (bfd *, bfd *);
 extern bfd_boolean _bfd_elf_print_private_bfd_data
   (bfd *, void *);
-const char * bfd_elf_get_symbol_version_string
+const char * _bfd_elf_get_symbol_version_string
   (bfd *, asymbol *, bfd_boolean *);
 extern void bfd_elf_print_symbol
   (bfd *, void *, asymbol *, bfd_print_symbol_type);
diff --git a/bfd/elf.c b/bfd/elf.c
index c0c7fef..0cf1991 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1425,8 +1425,8 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
 /* Get version string.  */
 
 const char *
-bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
-				   bfd_boolean *hidden)
+_bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
+				    bfd_boolean *hidden)
 {
   const char *version_string = NULL;
   if (elf_dynversym (abfd) != 0
@@ -1522,9 +1522,9 @@ bfd_elf_print_symbol (bfd *abfd,
 	bfd_fprintf_vma (abfd, file, val);
 
 	/* If we have version information, print it.  */
-	version_string = bfd_elf_get_symbol_version_string (abfd,
-							    symbol,
-							    &hidden);
+	version_string = _bfd_elf_get_symbol_version_string (abfd,
+							     symbol,
+							     &hidden);
 	if (version_string)
 	  {
 	    if (!hidden)
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 692fb46..9bf4b18 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -66,6 +66,10 @@
 #ifndef bfd_elfNN_get_symbol_info
 #define bfd_elfNN_get_symbol_info	_bfd_elf_get_symbol_info
 #endif
+#ifndef bfd_elfNN_get_symbol_version_string
+#define bfd_elfNN_get_symbol_version_string \
+  _bfd_elf_get_symbol_version_string
+#endif
 #define bfd_elfNN_canonicalize_symtab	_bfd_elf_canonicalize_symtab
 #define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
 #define bfd_elfNN_make_empty_symbol	_bfd_elf_make_empty_symbol
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index f02659f..bd2730a 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -162,6 +162,8 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_canonicalize_symtab _bfd_nosymbols_canonicalize_symtab
 #define msdos_print_symbol _bfd_nosymbols_print_symbol
 #define msdos_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define msdos_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 #define msdos_find_nearest_line _bfd_nosymbols_find_nearest_line
 #define msdos_find_line _bfd_nosymbols_find_line
 #define msdos_find_inliner_info _bfd_nosymbols_find_inliner_info
diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c
index d8d5408..a8f87e5 100644
--- a/bfd/i386os9k.c
+++ b/bfd/i386os9k.c
@@ -155,6 +155,8 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
 
 #define aout_32_find_line	      _bfd_nosymbols_find_line
+#define aout_32_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 #define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
 
 #define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 70ce4c5..04ac666 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -3828,6 +3828,8 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ieee_update_armap_timestamp bfd_true
 #define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
 
+#define ieee_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 #define ieee_bfd_is_target_special_symbol  \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 9b3b813..7ce8c4b 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -918,6 +918,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_make_empty_symbol                    _bfd_generic_make_empty_symbol
 #define ihex_print_symbol                         _bfd_nosymbols_print_symbol
 #define ihex_get_symbol_info                      _bfd_nosymbols_get_symbol_info
+#define ihex_get_symbol_version_string		  _bfd_nosymbols_get_symbol_version_string
 #define ihex_bfd_is_target_special_symbol         ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define ihex_bfd_is_local_label_name              _bfd_nosymbols_bfd_is_local_label_name
 #define ihex_get_lineno                           _bfd_nosymbols_get_lineno
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 50a46ac..f51bc11 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -392,6 +392,8 @@ extern bfd_boolean _bfd_vms_lib_ia64_mkarchive (bfd *abfd);
   ((void (*) (bfd *, void *, asymbol *, bfd_print_symbol_type)) bfd_void)
 #define _bfd_nosymbols_get_symbol_info \
   ((void (*) (bfd *, asymbol *, symbol_info *)) bfd_void)
+#define _bfd_nosymbols_get_symbol_version_string \
+  ((const char *(*) (bfd *, asymbol *, bfd_boolean *)) bfd_nullvoidptr)
 #define _bfd_nosymbols_bfd_is_local_label_name \
   ((bfd_boolean (*) (bfd *, const char *)) bfd_false)
 #define _bfd_nosymbols_bfd_is_target_special_symbol \
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 6c48f82..a1923c8 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -397,6 +397,8 @@ extern bfd_boolean _bfd_vms_lib_ia64_mkarchive (bfd *abfd);
   ((void (*) (bfd *, void *, asymbol *, bfd_print_symbol_type)) bfd_void)
 #define _bfd_nosymbols_get_symbol_info \
   ((void (*) (bfd *, asymbol *, symbol_info *)) bfd_void)
+#define _bfd_nosymbols_get_symbol_version_string \
+  ((const char *(*) (bfd *, asymbol *, bfd_boolean *)) bfd_nullvoidptr)
 #define _bfd_nosymbols_bfd_is_local_label_name \
   ((bfd_boolean (*) (bfd *, const char *)) bfd_false)
 #define _bfd_nosymbols_bfd_is_target_special_symbol \
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index 6b6eb28..dc7866d 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -353,6 +353,8 @@ extern void coff_print_symbol
   (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
 extern void coff_get_symbol_info
   (bfd *, asymbol *, symbol_info *ret);
+#define coff_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 extern bfd_boolean _bfd_coff_is_local_label_name
   (bfd *, const char *);
 extern asymbol *coff_bfd_make_debug_symbol
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index 9479985..d1c466a 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -357,6 +357,8 @@ extern void coff_print_symbol
   (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
 extern void coff_get_symbol_info
   (bfd *, asymbol *, symbol_info *ret);
+#define coff_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 extern bfd_boolean _bfd_coff_is_local_label_name
   (bfd *, const char *);
 extern asymbol *coff_bfd_make_debug_symbol
diff --git a/bfd/libecoff.h b/bfd/libecoff.h
index 06434c2..ebfa37e 100644
--- a/bfd/libecoff.h
+++ b/bfd/libecoff.h
@@ -285,6 +285,8 @@ extern void _bfd_ecoff_print_symbol
   (bfd *, void *, asymbol *, bfd_print_symbol_type);
 extern void _bfd_ecoff_get_symbol_info
   (bfd *, asymbol *, symbol_info *);
+#define _bfd_ecoff_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 extern bfd_boolean _bfd_ecoff_bfd_is_local_label_name
   (bfd *, const char *);
 #define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index a070e67..dd1ced1 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -31,6 +31,7 @@
 #define bfd_mach_o_bfd_is_local_label_name            bfd_generic_is_local_label_name
 #define bfd_mach_o_get_lineno                         _bfd_nosymbols_get_lineno
 #define bfd_mach_o_find_inliner_info                  _bfd_nosymbols_find_inliner_info
+#define bfd_mach_o_get_symbol_version_string	      _bfd_nosymbols_get_symbol_version_string
 #define bfd_mach_o_bfd_make_debug_symbol              _bfd_nosymbols_bfd_make_debug_symbol
 #define bfd_mach_o_read_minisymbols                   _bfd_generic_read_minisymbols
 #define bfd_mach_o_minisymbol_to_symbol               _bfd_generic_minisymbol_to_symbol
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 2c74c76..698ffa5 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3204,6 +3204,9 @@ mmo_write_object_contents (bfd *abfd)
 #define mmo_bfd_is_target_special_symbol  \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 
+#define mmo_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
+
 /* Is this one really used or defined by anyone?  */
 #define mmo_get_lineno _bfd_nosymbols_get_lineno
 
diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h
index 2343cff..44b41ed 100644
--- a/bfd/nlm-target.h
+++ b/bfd/nlm-target.h
@@ -25,6 +25,7 @@
 #define nlm_make_empty_symbol                   nlmNAME (make_empty_symbol)
 #define nlm_print_symbol                        nlmNAME (print_symbol)
 #define nlm_get_symbol_info                     nlmNAME (get_symbol_info)
+#define nlm_get_symbol_version_string		_bfd_nosymbols_get_symbol_version_string
 #define nlm_bfd_is_local_label_name             bfd_generic_is_local_label_name
 #define nlm_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define nlm_get_lineno                          _bfd_nosymbols_get_lineno
diff --git a/bfd/oasys.c b/bfd/oasys.c
index 9ff9b9e..9ff9117 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -1170,6 +1170,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define oasys_bfd_is_local_label_name              bfd_generic_is_local_label_name
 #define oasys_bfd_is_target_special_symbol         ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define oasys_get_lineno                           _bfd_nosymbols_get_lineno
+#define oasys_get_symbol_version_string		   _bfd_nosymbols_get_symbol_version_string
 #define oasys_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
 #define oasys_read_minisymbols                     _bfd_generic_read_minisymbols
 #define oasys_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
diff --git a/bfd/pef.c b/bfd/pef.c
index 4c29417..363e641 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -43,6 +43,7 @@
 #define bfd_pef_find_nearest_line                   _bfd_nosymbols_find_nearest_line
 #define bfd_pef_find_line                           _bfd_nosymbols_find_line
 #define bfd_pef_find_inliner_info                   _bfd_nosymbols_find_inliner_info
+#define bfd_pef_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
 #define bfd_pef_bfd_make_debug_symbol               _bfd_nosymbols_bfd_make_debug_symbol
 #define bfd_pef_read_minisymbols                    _bfd_generic_read_minisymbols
 #define bfd_pef_minisymbol_to_symbol                _bfd_generic_minisymbol_to_symbol
diff --git a/bfd/plugin.c b/bfd/plugin.c
index a068861..7f8f8b5 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -85,6 +85,7 @@ dlerror (void)
 #define bfd_plugin_find_nearest_line                  _bfd_nosymbols_find_nearest_line
 #define bfd_plugin_find_line                          _bfd_nosymbols_find_line
 #define bfd_plugin_find_inliner_info                  _bfd_nosymbols_find_inliner_info
+#define bfd_plugin_get_symbol_version_string	      _bfd_nosymbols_get_symbol_version_string
 #define bfd_plugin_bfd_make_debug_symbol              _bfd_nosymbols_bfd_make_debug_symbol
 #define bfd_plugin_read_minisymbols                   _bfd_generic_read_minisymbols
 #define bfd_plugin_minisymbol_to_symbol               _bfd_generic_minisymbol_to_symbol
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index 9ee8ab5..7599e20 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -326,6 +326,8 @@ ppcboot_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
   bfd_symbol_info (symbol, ret);
 }
 
+#define ppcboot_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 #define ppcboot_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define ppcboot_bfd_is_local_label_name bfd_generic_is_local_label_name
diff --git a/bfd/som.c b/bfd/som.c
index 513e4fa..5f96caa 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6718,6 +6718,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 }
 
 #define som_find_line			        _bfd_nosymbols_find_line
+#define som_get_symbol_version_string		_bfd_nosymbols_get_symbol_version_string
 #define	som_close_and_cleanup		        som_bfd_free_cached_info
 #define som_read_ar_hdr			        _bfd_generic_read_ar_hdr
 #define som_write_ar_hdr		        _bfd_generic_write_ar_hdr
diff --git a/bfd/srec.c b/bfd/srec.c
index 5f9a546..8de6e42 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -1258,6 +1258,7 @@ srec_print_symbol (bfd *abfd,
 #define srec_find_line                            _bfd_nosymbols_find_line
 #define srec_find_inliner_info                    _bfd_nosymbols_find_inliner_info
 #define srec_make_empty_symbol                    _bfd_generic_make_empty_symbol
+#define srec_get_symbol_version_string		  _bfd_nosymbols_get_symbol_version_string
 #define srec_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
 #define srec_read_minisymbols                     _bfd_generic_read_minisymbols
 #define srec_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
diff --git a/bfd/targets.c b/bfd/targets.c
index 8323e92..6a282ea 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -363,6 +363,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_make_empty_symbol, \
 .  NAME##_print_symbol, \
 .  NAME##_get_symbol_info, \
+.  NAME##_get_symbol_version_string, \
 .  NAME##_bfd_is_local_label_name, \
 .  NAME##_bfd_is_target_special_symbol, \
 .  NAME##_get_lineno, \
@@ -384,6 +385,9 @@ BFD_JUMP_TABLE macros.
 .  void        (*_bfd_get_symbol_info)
 .    (bfd *, struct bfd_symbol *, symbol_info *);
 .#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
+.  const char *(*_bfd_get_symbol_version_string)
+.    (bfd *, struct bfd_symbol *, bfd_boolean *);
+.#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h))
 .  bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
 .  bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
 .  alent *     (*_get_lineno) (bfd *, struct bfd_symbol *);
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 0328689..2f14194 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -957,6 +957,7 @@ tekhex_print_symbol (bfd *abfd,
 #define tekhex_find_nearest_line                    _bfd_nosymbols_find_nearest_line
 #define tekhex_find_line                            _bfd_nosymbols_find_line
 #define tekhex_find_inliner_info                    _bfd_nosymbols_find_inliner_info
+#define tekhex_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
 #define tekhex_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
 #define tekhex_read_minisymbols                     _bfd_generic_read_minisymbols
 #define tekhex_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
diff --git a/bfd/versados.c b/bfd/versados.c
index 5bafcb1..2368998 100644
--- a/bfd/versados.c
+++ b/bfd/versados.c
@@ -811,6 +811,7 @@ versados_canonicalize_reloc (bfd *abfd,
 #define versados_find_nearest_line                    _bfd_nosymbols_find_nearest_line
 #define versados_find_line                            _bfd_nosymbols_find_line
 #define versados_find_inliner_info                    _bfd_nosymbols_find_inliner_info
+#define versados_get_symbol_version_string	      _bfd_nosymbols_get_symbol_version_string
 #define versados_make_empty_symbol                    _bfd_generic_make_empty_symbol
 #define versados_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
 #define versados_read_minisymbols                     _bfd_generic_read_minisymbols
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 3789f79..8c24ef0 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -9191,6 +9191,9 @@ bfd_vms_get_data (bfd *abfd)
    ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define alpha_vms_print_symbol             vms_print_symbol
 #define alpha_vms_get_symbol_info          vms_get_symbol_info
+#define alpha_vms_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
+
 #define alpha_vms_read_minisymbols         _bfd_generic_read_minisymbols
 #define alpha_vms_minisymbol_to_symbol     _bfd_generic_minisymbol_to_symbol
 #define alpha_vms_get_lineno               _bfd_nosymbols_get_lineno
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 4e2a8ab..870795e 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -35,6 +35,7 @@
 #define bfd_sym_find_nearest_line                   _bfd_nosymbols_find_nearest_line
 #define bfd_sym_find_line                           _bfd_nosymbols_find_line
 #define bfd_sym_find_inliner_info                   _bfd_nosymbols_find_inliner_info
+#define bfd_sym_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
 #define bfd_sym_bfd_make_debug_symbol               _bfd_nosymbols_bfd_make_debug_symbol
 #define bfd_sym_read_minisymbols                    _bfd_generic_read_minisymbols
 #define bfd_sym_minisymbol_to_symbol                _bfd_generic_minisymbol_to_symbol
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index f4d9aa6..86c8555 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,11 @@
 2014-11-25  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* objdump.c (objdump_print_symname): Replace
+	bfd_elf_get_symbol_version_string with
+	bfd_get_symbol_version_string.
+
+2014-11-25  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR binutils/16496
 	* objdump.c (objdump_print_symname): Call
 	bfd_elf_get_symbol_version_string to get ELF symbol version
diff --git a/binutils/objdump.c b/binutils/objdump.c
index e04c3ee..fdfa602 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -808,9 +808,7 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
 	name = alloc;
     }
 
-  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
-    version_string = bfd_elf_get_symbol_version_string (abfd, sym,
-							&hidden);
+  version_string = bfd_get_symbol_version_string (abfd, sym, &hidden);
 
   if (bfd_is_und_section (bfd_get_section (sym)))
     hidden = TRUE;
-- 
1.9.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-11-25 17:37         ` H.J. Lu
@ 2014-11-27  8:33           ` Alan Modra
  2014-11-27 14:45             ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2014-11-27  8:33 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Tue, Nov 25, 2014 at 09:37:51AM -0800, H.J. Lu wrote:
> I checked in this patch to add get_symbol_version_string to
> BFD_JUMP_TABLE_SYMBOLS so that we can use
> bfd_get_symbol_version_string in objdump for non-ELF targets.

This caused
mips-linux  +FAIL: MIPS reloc estimation 1
mips-linux  +FAIL: Shared library with TLS and versioning
mips-linux  +FAIL: Dynamic executable with TLS and versioning
mips-linux  +FAIL: Dynamic executable with TLS and versioning (order 2)
mips-linux  +FAIL: Dynamic executable with TLS and versioning (order 3)
mips-linux  +FAIL: GOT and versioning 1
and similarly for other mips targets.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs
  2014-11-27  8:33           ` Alan Modra
@ 2014-11-27 14:45             ` H.J. Lu
  0 siblings, 0 replies; 8+ messages in thread
From: H.J. Lu @ 2014-11-27 14:45 UTC (permalink / raw)
  To: H.J. Lu, Binutils

On Thu, Nov 27, 2014 at 12:33 AM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Nov 25, 2014 at 09:37:51AM -0800, H.J. Lu wrote:
>> I checked in this patch to add get_symbol_version_string to
>> BFD_JUMP_TABLE_SYMBOLS so that we can use
>> bfd_get_symbol_version_string in objdump for non-ELF targets.
>
> This caused
> mips-linux  +FAIL: MIPS reloc estimation 1
> mips-linux  +FAIL: Shared library with TLS and versioning
> mips-linux  +FAIL: Dynamic executable with TLS and versioning
> mips-linux  +FAIL: Dynamic executable with TLS and versioning (order 2)
> mips-linux  +FAIL: Dynamic executable with TLS and versioning (order 3)
> mips-linux  +FAIL: GOT and versioning 1
> and similarly for other mips targets.
>

This is what I checked in.

Thanks.

-- 
H.J.
--
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 9b87101..c87cc57 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2014-11-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+ * ld-mips-elf/got-vers-1.rd: Add symbol version string to
+ versioned symbol names in dynamic relocation.
+ * ld-mips-elf/reloc-estimate-1.d: Likewise.
+ * ld-mips-elf/tlsdyn-o32-1.got: Likewise.
+ * ld-mips-elf/tlsdyn-o32-2.got: Likewise.
+ * ld-mips-elf/tlsdyn-o32-3.got: Likewise.
+ * ld-mips-elf/tlslib-o32-ver.got: Likewise.
+
 2014-11-25  H.J. Lu  <hongjiu.lu@intel.com>

  * ld-alpha/tlsbin.dd: Updated for secureplt.
diff --git a/ld/testsuite/ld-mips-elf/got-vers-1.rd
b/ld/testsuite/ld-mips-elf/got-vers-1.rd
index 48dcc64..f1d5a2c 100644
--- a/ld/testsuite/ld-mips-elf/got-vers-1.rd
+++ b/ld/testsuite/ld-mips-elf/got-vers-1.rd
@@ -3,4 +3,4 @@ Relocation section '\.rel\.dyn' at offset .* contains 2 entries:
  *Offset * Info * Type * Sym\.Value * Sym\. Name
 00000000 * 00000000 * R_MIPS_NONE *
 # This index must be the same as DT_MIPS_GOTSYM.
-[^ ]+ * 00000303 * R_MIPS_REL32 * [^ ]+ * foo
+[^ ]+ * 00000303 * R_MIPS_REL32 * [^ ]+ * foo@@V2
diff --git a/ld/testsuite/ld-mips-elf/reloc-estimate-1.d
b/ld/testsuite/ld-mips-elf/reloc-estimate-1.d
index 0d49b05..1269cb1 100644
--- a/ld/testsuite/ld-mips-elf/reloc-estimate-1.d
+++ b/ld/testsuite/ld-mips-elf/reloc-estimate-1.d
@@ -9,7 +9,7 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE
 00000000 R_MIPS_NONE       \*ABS\*
-00010000 R_MIPS_REL32      foo
+00010000 R_MIPS_REL32      foo@@V2


 # The address must be 0x810.  We should only ever allocate one dynamic
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
index d70fdd0..163aeb5 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
@@ -4,12 +4,12 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE
 00000000 R_MIPS_NONE       \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd
-1000002c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-10000030 R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000040 R_MIPS_TLS_TPREL32  tlsvar_ie
-10000034 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd@@Base
+1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd@@Base
+1000002c R_MIPS_TLS_DTPMOD32  tlsvar_gd@VER_1
+10000030 R_MIPS_TLS_DTPREL32  tlsvar_gd@VER_1
+10000040 R_MIPS_TLS_TPREL32  tlsvar_ie@VER_1
+10000034 R_MIPS_TLS_TPREL32  tlsbin_ie@@Base


 Contents of section .got:
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
index 6b00157..80e9148 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
@@ -4,12 +4,12 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE
 00000000 R_MIPS_NONE       \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd
-1000002c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-10000030 R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000040 R_MIPS_TLS_TPREL32  tlsvar_ie
-10000034 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd@@Base
+1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd@@Base
+1000002c R_MIPS_TLS_DTPMOD32  tlsvar_gd@VER_1
+10000030 R_MIPS_TLS_DTPREL32  tlsvar_gd@VER_1
+10000040 R_MIPS_TLS_TPREL32  tlsvar_ie@VER_1
+10000034 R_MIPS_TLS_TPREL32  tlsbin_ie@@Base


 Contents of section .got:
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
index 01eb44f..a1191e7 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
@@ -4,12 +4,12 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE
 00000000 R_MIPS_NONE       \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd
-1000002c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-10000030 R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000040 R_MIPS_TLS_TPREL32  tlsvar_ie
-10000034 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd@@Base
+1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd@@Base
+1000002c R_MIPS_TLS_DTPMOD32  tlsvar_gd@VER_1
+10000030 R_MIPS_TLS_DTPREL32  tlsvar_gd@VER_1
+10000040 R_MIPS_TLS_TPREL32  tlsvar_ie@VER_1
+10000034 R_MIPS_TLS_TPREL32  tlsbin_ie@@Base


 Contents of section .got:
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
b/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
index a5b0801..e675f9f 100644
--- a/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
+++ b/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
@@ -5,9 +5,9 @@ DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE
 00000000 R_MIPS_NONE       \*ABS\*
 000404d8 R_MIPS_TLS_DTPMOD32  \*ABS\*
-000404d0 R_MIPS_TLS_DTPMOD32  tlsvar_gd
-000404d4 R_MIPS_TLS_DTPREL32  tlsvar_gd
-000404cc R_MIPS_TLS_TPREL32  tlsvar_ie
+000404d0 R_MIPS_TLS_DTPMOD32  tlsvar_gd@@VER_1
+000404d4 R_MIPS_TLS_DTPREL32  tlsvar_gd@@VER_1
+000404cc R_MIPS_TLS_TPREL32  tlsvar_ie@@VER_1


 Contents of section .got:

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-11-27 14:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-24 19:16 [PATCH] PR binutils/16496: Display symbol version when dumping dynrelocs H.J. Lu
2014-01-30  5:33 ` H.J. Lu
2014-01-30  9:39   ` Andreas Schwab
2014-01-30 12:41     ` H.J. Lu
2014-11-25 14:36       ` H.J. Lu
2014-11-25 17:37         ` H.J. Lu
2014-11-27  8:33           ` Alan Modra
2014-11-27 14:45             ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).