RISC-V: Fix symbol address problem with versioned symbols.

Message ID 20180603214643.16936-1-jimw@sifive.com
State New
Headers show
Series
  • RISC-V: Fix symbol address problem with versioned symbols.
Related show

Commit Message

Jim Wilson June 3, 2018, 9:46 p.m.
This fixes another symbol address problem, this time with versioned symbols.

For testing, I added some code to check for duplicate symbols and abort if not
already handled.  I then tested this with binutils/gcc toolchain builds and
make check for newlib/glibc based toolchains, and a linux kernel/buildroot
build and boot.  The abort was not hit.  And there were no binutils/gcc
testsuite regressions.

Committed.

Jim

	bfd/
	PR ld/22756
	* elfnn-riscv.c (riscv_relax_delete_bytes): Add versioned_hidden check
	to code that ignores duplicate symbols.
---
 bfd/elfnn-riscv.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

-- 
2.17.0

Patch

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index b82e655b7b..a0bdee54b2 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2708,9 +2708,12 @@  riscv_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, size_t count,
 	 call to SYMBOL as well. Since both __wrap_SYMBOL and SYMBOL reference
 	 the same symbol (which is __wrap_SYMBOL), but still exist as two
 	 different symbols in 'sym_hashes', we don't want to adjust
-	 the global symbol __wrap_SYMBOL twice.
-	 This check is only relevant when symbols are being wrapped.  */
-      if (link_info->wrap_hash != NULL)
+	 the global symbol __wrap_SYMBOL twice.  */
+      /* The same problem occurs with symbols that are versioned_hidden, as
+	 foo becomes an alias for foo@BAR, and hence they need the same
+	 treatment.  */
+      if (link_info->wrap_hash != NULL
+	  || sym_hash->versioned == versioned_hidden)
 	{
 	  struct elf_link_hash_entry **cur_sym_hashes;