elf/riscv: Fix relaxation with aliases [PR28021]
authorMichael Matz <matz@suse.de>
Mon, 28 Jun 2021 15:57:17 +0000 (17:57 +0200)
committerMichael Matz <matz@suse.de>
Tue, 6 Jul 2021 13:49:03 +0000 (15:49 +0200)
commit235f5ef4a6b8fbdcfaea8b629f7c6a9792a789de
tree147f3a5973fd72d560102b3689083714b5b1326c
parent46f2c22eabb3d2b13ed56f528a4f45dc5e8f3a32
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
bfd/elfnn-riscv.c
ld/ChangeLog
ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
ld/testsuite/ld-riscv-elf/relax-twice-1.s [new file with mode: 0644]
ld/testsuite/ld-riscv-elf/relax-twice-2.s [new file with mode: 0644]
ld/testsuite/ld-riscv-elf/relax-twice.ver [new file with mode: 0644]