diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 10 | ||||
-rw-r--r-- | ld/emultempl/riscvelf.em | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-riscv-elf/restart-relax.d | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-riscv-elf/restart-relax.s | 17 |
5 files changed, 47 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index ec78541..b5298b98 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2021-03-11 Nelson Chu <nelson.chu@sifive.com> + + * emultempl/riscvelf.em (after_allocation): Run ldelf_map_segments + many times if riscv_restart_relax_sections returns TRUE. + * testsuite/ld-riscv-elf/restart-relax.d: New testcase. Before + applying this patch, the call won't be relaxed to jal; But now we + have more chances to do relaxations. + * testsuite/ld-riscv-elf/restart-relax.s: Likewise. + * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. + 2021-03-10 Jan Beulich <jbeulich@suse.com> * testsuite/ld-scripts/pr22267.t: Avoid symbol value with more diff --git a/ld/emultempl/riscvelf.em b/ld/emultempl/riscvelf.em index 735eae0..5fa7c77 100644 --- a/ld/emultempl/riscvelf.em +++ b/ld/emultempl/riscvelf.em @@ -62,7 +62,11 @@ gld${EMULATION_NAME}_after_allocation (void) } } - ldelf_map_segments (need_layout); + do + { + ldelf_map_segments (need_layout); + } + while (bfd_elf${ELFSIZE}_riscv_restart_relax_sections (&link_info)); } /* This is a convenient point to tell BFD about target specific flags. diff --git a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp index 7081af1..f3ff95c 100644 --- a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp +++ b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp @@ -86,6 +86,7 @@ if [istarget "riscv*-*-*"] { run_dump_test "disas-jalr" run_dump_test "pcrel-lo-addend" run_dump_test "pcrel-lo-addend-2" + run_dump_test "restart-relax" run_dump_test "attr-merge-arch-01" run_dump_test "attr-merge-arch-02" run_dump_test "attr-merge-arch-03" diff --git a/ld/testsuite/ld-riscv-elf/restart-relax.d b/ld/testsuite/ld-riscv-elf/restart-relax.d new file mode 100644 index 0000000..57b62eb --- /dev/null +++ b/ld/testsuite/ld-riscv-elf/restart-relax.d @@ -0,0 +1,14 @@ +#source: restart-relax.s +#as: +#ld: +#objdump: -d + +#... +Disassembly of section .text: + +0+[0-9a-f]+ <_start>: +.*:[ ]+[0-9a-f]+[ ]+addi[ ]+.* +#... +.*:[ ]+[0-9a-f]+[ ]+jal[ ]+ra,[0-9a-f]+ <_start> +.*:[ ]+[0-9a-f]+[ ]+add[ ]+a0,a1,a2 +#pass diff --git a/ld/testsuite/ld-riscv-elf/restart-relax.s b/ld/testsuite/ld-riscv-elf/restart-relax.s new file mode 100644 index 0000000..efc881d --- /dev/null +++ b/ld/testsuite/ld-riscv-elf/restart-relax.s @@ -0,0 +1,17 @@ + .text + .global _start +_start: + lla a0, data_g +.rept 0x3fffe + nop +.endr + call _start + .option rvc + .align 2 + add a0, a1, a2 + + .data + .global data_g + .dword 0x0 +data_g: + .word 0x1000 |