From 235f5ef4a6b8fbdcfaea8b629f7c6a9792a789de Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 28 Jun 2021 17:57:17 +0200 Subject: elf/riscv: Fix relaxation with aliases [PR28021] the fix for PR22756 only changed behaviour for hidden aliases, but the same situation exists for non-hidden aliases: sym_hashes[] can contain multiple entries pointing to the same symbol structure leading to relaxation adjustment to be applied twice. Fix this by testing for duplicates for everything that looks like it has a version. PR ld/28021 bfd/ * elfnn-riscv.c (riscv_relax_delete_bytes): Check for any versioning. ld/ * testsuite/ld-riscv-elf/relax-twice.ver: New. * testsuite/ld-riscv-elf/relax-twice-1.s: New. * testsuite/ld-riscv-elf/relax-twice-2.s: New. * testsuite/ld-riscv-elf/ld-riscv-elf.exp (run_relax_twice_test): New, and call it. --- bfd/ChangeLog | 6 ++++++ bfd/elfnn-riscv.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dd72561..7591469 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2021-07-06 Michael Matz + + PR ld/28021 + * elfnn-riscv.c (riscv_relax_delete_bytes): Check for any + versioning. + 2021-07-06 Alan Modra PR 28055 diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 2dfa635..85a99f3 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -3995,7 +3995,7 @@ riscv_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, size_t count, 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) + || sym_hash->versioned != unversioned) { struct elf_link_hash_entry **cur_sym_hashes; -- cgit v1.1