elf: Check if the first symbol version is base version

Check VER_FLG_BASE instead of assuming that the first symbol version is
base version.

bfd/

	PR binutils/23267
	* elf.c (_bfd_elf_get_symbol_version_string): Check if the first
	symbol version is base version.

binutils/

	PR binutils/23267
	* readelf.c (get_symbol_version_string): Check if the first
	symbol version is base version.
This commit is contained in:
H.J. Lu 2018-06-14 05:37:19 -07:00
parent 7b045207d1
commit 1f6f5dba57
4 changed files with 22 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2018-06-14 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23267
* elf.c (_bfd_elf_get_symbol_version_string): Check if the first
symbol version is base version.
2018-06-14 Alan Modra <amodra@gmail.com> 2018-06-14 Alan Modra <amodra@gmail.com>
* elf-bfd.h (struct elf_link_hash_table): Add "dynamic_relocs". * elf-bfd.h (struct elf_link_hash_table): Add "dynamic_relocs".

View File

@ -1865,7 +1865,10 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
if (vernum == 0) if (vernum == 0)
version_string = ""; version_string = "";
else if (vernum == 1) else if (vernum == 1
&& (vernum > elf_tdata (abfd)->cverdefs
|| (elf_tdata (abfd)->verdef[0].vd_flags
== VER_FLG_BASE)))
version_string = "Base"; version_string = "Base";
else if (vernum <= elf_tdata (abfd)->cverdefs) else if (vernum <= elf_tdata (abfd)->cverdefs)
version_string = version_string =

View File

@ -1,3 +1,9 @@
2018-06-14 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23267
* readelf.c (get_symbol_version_string): Check if the first
symbol version is base version.
2018-06-13 Scott Egerton <scott.egerton@imgtec.com> 2018-06-13 Scott Egerton <scott.egerton@imgtec.com>
Faraz Shahbazker <Faraz.Shahbazker@mips.com> Faraz Shahbazker <Faraz.Shahbazker@mips.com>

View File

@ -11266,7 +11266,7 @@ get_symbol_version_string (Filedata * filedata,
vers_data = byte_get (data, 2); vers_data = byte_get (data, 2);
if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data <= 1) if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data == 0)
return NULL; return NULL;
/* Usually we'd only see verdef for defined symbols, and verneed for /* Usually we'd only see verdef for defined symbols, and verneed for
@ -11301,12 +11301,14 @@ get_symbol_version_string (Filedata * filedata,
ivd.vd_ndx = 0; ivd.vd_ndx = 0;
ivd.vd_aux = 0; ivd.vd_aux = 0;
ivd.vd_next = 0; ivd.vd_next = 0;
ivd.vd_flags = 0;
} }
else else
{ {
ivd.vd_ndx = BYTE_GET (evd.vd_ndx); ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
ivd.vd_aux = BYTE_GET (evd.vd_aux); ivd.vd_aux = BYTE_GET (evd.vd_aux);
ivd.vd_next = BYTE_GET (evd.vd_next); ivd.vd_next = BYTE_GET (evd.vd_next);
ivd.vd_flags = BYTE_GET (evd.vd_flags);
} }
off += ivd.vd_next; off += ivd.vd_next;
@ -11315,6 +11317,9 @@ get_symbol_version_string (Filedata * filedata,
if (ivd.vd_ndx == (vers_data & VERSYM_VERSION)) if (ivd.vd_ndx == (vers_data & VERSYM_VERSION))
{ {
if (ivd.vd_ndx == 1 && ivd.vd_flags == VER_FLG_BASE)
return NULL;
off -= ivd.vd_next; off -= ivd.vd_next;
off += ivd.vd_aux; off += ivd.vd_aux;