aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2021-06-28 17:57:17 +0200
committerMichael Matz <matz@suse.de>2021-07-06 15:49:03 +0200
commit235f5ef4a6b8fbdcfaea8b629f7c6a9792a789de (patch)
tree147f3a5973fd72d560102b3689083714b5b1326c /ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
parent46f2c22eabb3d2b13ed56f528a4f45dc5e8f3a32 (diff)
downloadgdb-235f5ef4a6b8fbdcfaea8b629f7c6a9792a789de.zip
gdb-235f5ef4a6b8fbdcfaea8b629f7c6a9792a789de.tar.gz
gdb-235f5ef4a6b8fbdcfaea8b629f7c6a9792a789de.tar.bz2
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.
Diffstat (limited to 'ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp')
-rw-r--r--ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp41
1 files changed, 41 insertions, 0 deletions
diff --git a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
index 1f6eceb..1197761 100644
--- a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
+++ b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
@@ -78,6 +78,46 @@ proc run_dump_test_ifunc { name target output} {
"$name-$target.$ext"]]
}
+proc run_relax_twice_test {} {
+ global as
+ global ld
+ global nm
+ global nm_output
+ global srcdir
+ global subdir
+ global runtests
+
+ set testname "relax-twice"
+ if ![runtest_file_p $runtests $testname] then {
+ return
+ }
+
+ # assemble and link the two input files with a version script, then
+ # capture output of nm and compare addresses of the two symbols
+ # 'foobar_new' and 'foobar@@New'. They must be equal.
+ # Bitness doesn't matter so we simply force 64bit.
+ if { ![ld_assemble_flags $as "-march=rv64i" $srcdir/$subdir/relax-twice-1.s tmpdir/relax-twice-1.o ]
+ || ![ld_assemble_flags $as "-march=rv64i" $srcdir/$subdir/relax-twice-2.s tmpdir/relax-twice-2.o]
+ || ![ld_link $ld tmpdir/relax-twice.so "-m[riscv_choose_lp64_emul] -shared --relax --version-script $srcdir/$subdir/relax-twice.ver tmpdir/relax-twice-1.o tmpdir/relax-twice-2.o"] } {
+ fail $testname
+ } elseif { ![ld_nm $nm "" tmpdir/relax-twice.so] } {
+ fail $testname
+ } elseif { ![info exists nm_output(foobar_new)]
+ || ![info exists nm_output(foobar@@New)]} {
+ send_log "bad output from nm\n"
+ verbose "bad output from nm"
+ fail $testname
+ } elseif {$nm_output(foobar_new) != $nm_output(foobar@@New)} {
+ send_log "foobar_new == $nm_output(foobar_new)\n"
+ verbose "foobar_new == $nm_output(foobar_new)"
+ send_log "foobar@@New == $nm_output(foobar@@New)\n"
+ verbose "foobar@@New == $nm_output(foobar@@New)"
+ fail $testname
+ } else {
+ pass $testname
+ }
+}
+
if [istarget "riscv*-*-*"] {
run_dump_test "call-relax"
run_dump_test "pcgp-relax"
@@ -128,6 +168,7 @@ if [istarget "riscv*-*-*"] {
run_dump_test "relro-relax-lui"
run_dump_test "relro-relax-pcrel"
+ run_relax_twice_test
set abis [list rv32gc ilp32 [riscv_choose_ilp32_emul] rv64gc lp64 [riscv_choose_lp64_emul]]
foreach { arch abi emul } $abis {