]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V: Added ld testcase for pcgp relaxation.
authorLewis Revill <lewis.revill@embecosm.com>
Fri, 22 Oct 2021 03:32:46 +0000 (11:32 +0800)
committerNelson Chu <nelson.chu@sifive.com>
Fri, 22 Oct 2021 08:44:43 +0000 (16:44 +0800)
Consider the the pcgp-relax-02 testcase,

        .text
        .globl _start
_start:
.L1:    auipc   a0, %pcrel_hi(data_a)
.L2:    auipc   a1, %pcrel_hi(data_b)
        addi    a0, a0, %pcrel_lo(.L1)
        addi    a1, a1, %pcrel_lo(.L2)

        .data
        .word 0x0
        .globl data_a
data_a:
        .word 0x1

        .section .rodata
        .globl data_b
data_b:
        .word 0x2

If the first auipc is deleted, but we are still building the pcgp
table (connect the high and low pcrel relocations), then there is
an aliasing issue that we need some way to disambiguate which of
the two symbols we are targeting.  Therefore, Palmer thought of a
way to use R_RISCV_DELETE to split this into two phases, so we
could resolve the addresses before creating the ambiguities.

This patch just add the ld testcase for the above case, in case we
have changed something but break this.

ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Renamed pcgp-relax
to pcgp-relax-01, and added pcgp-relax-02.
* testsuite/ld-riscv-elf/pcgp-relax-01.d: Renmaed from pcgp-relax.
* testsuite/ld-riscv-elf/pcgp-relax-01.s: Likewise.
* testsuite/ld-riscv-elf/pcgp-relax-02.d: New testcase.
* testsuite/ld-riscv-elf/pcgp-relax-02.s: Likewise.

ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
ld/testsuite/ld-riscv-elf/pcgp-relax-01.d [moved from ld/testsuite/ld-riscv-elf/pcgp-relax.d with 94% similarity]
ld/testsuite/ld-riscv-elf/pcgp-relax-01.s [moved from ld/testsuite/ld-riscv-elf/pcgp-relax.s with 100% similarity]
ld/testsuite/ld-riscv-elf/pcgp-relax-02.d [new file with mode: 0644]
ld/testsuite/ld-riscv-elf/pcgp-relax-02.s [new file with mode: 0644]

index 20ca3bdb1959b71ca81490fb69999e5ae137c4be..78a71345bf288fc0c1be64168f4c1b12f496d51e 100644 (file)
@@ -121,7 +121,8 @@ proc run_relax_twice_test {} {
 if [istarget "riscv*-*-*"] {
     run_dump_test "align-small-region"
     run_dump_test "call-relax"
-    run_dump_test "pcgp-relax"
+    run_dump_test "pcgp-relax-01"
+    run_dump_test "pcgp-relax-02"
     run_dump_test "c-lui"
     run_dump_test "c-lui-2"
     run_dump_test "disas-jalr"
similarity index 94%
rename from ld/testsuite/ld-riscv-elf/pcgp-relax.d
rename to ld/testsuite/ld-riscv-elf/pcgp-relax-01.d
index dae2b62b9a73abe8d29712d14c75840b0efaf55a..f9425678559f7eacdfb222b9de198470d6894090 100644 (file)
@@ -1,4 +1,4 @@
-#source: pcgp-relax.s
+#source: pcgp-relax-01.s
 #ld: --relax
 #objdump: -d -Mno-aliases
 
diff --git a/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d b/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d
new file mode 100644 (file)
index 0000000..c6c73c5
--- /dev/null
@@ -0,0 +1,15 @@
+#source: pcgp-relax-02.s
+#as:
+#ld: --relax
+#objdump: -d
+
+.*:[   ]+file format .*
+
+
+Disassembly of section .text:
+
+[0-9a-f]+ <_start>:
+.*:[   ]+[0-9a-f]+[    ]+auipc[        ]+a1.*
+.*:[   ]+[0-9a-f]+[    ]+addi[         ]+a0,gp.*<data_a>
+.*:[   ]+[0-9a-f]+[    ]+addi[         ]+a1,a1.*<data_b>
+#pass
diff --git a/ld/testsuite/ld-riscv-elf/pcgp-relax-02.s b/ld/testsuite/ld-riscv-elf/pcgp-relax-02.s
new file mode 100644 (file)
index 0000000..ca4aa1f
--- /dev/null
@@ -0,0 +1,18 @@
+       .text
+       .globl _start
+_start:
+.L1:   auipc   a0, %pcrel_hi(data_a)
+.L2:   auipc   a1, %pcrel_hi(data_b)
+       addi    a0, a0, %pcrel_lo(.L1)
+       addi    a1, a1, %pcrel_lo(.L2)
+
+       .data
+       .word 0x0
+       .globl data_a
+data_a:
+       .word 0x1
+
+       .section .rodata
+       .globl data_b
+data_b:
+       .word 0x2