From 50980ba351856dff75bb0743bfca62f4c3ab19ff Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 23 Feb 2023 22:11:14 -0800 Subject: RISC-V: Add --[no-]relax-gp to ld --relax enables all relaxations. --no-relax-gp disables GP relaxation to allow measuring its effect. The option can test effectiveness of GP relaxation and support some ABI variants that use GP for other purposes. Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/298 bfd/ * elfnn-riscv.c (struct riscv_elf_link_hash_table): Add params. (riscv_elfNN_set_options): New. (riscv_info_to_howto_rela): Check relax_gp. (_bfd_riscv_relax_section): Likewise. * elfxx-riscv.h (struct riscv_elf_params): New. (riscv_elf32_set_options): New. (riscv_elf64_set_options): New. ld/ * emultempl/riscvelf.em: Add option parsing. * testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-02.d: Test --relax --relax-gp can be used together. --- ld/ChangeLog | 8 +++++ ld/emultempl/riscvelf.em | 36 ++++++++++++++++++++++ .../code-model-relax-medlow-01-norelaxgp.d | 4 +++ ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 2 ++ .../ld-riscv-elf/pcgp-relax-01-norelaxgp.d | 18 +++++++++++ ld/testsuite/ld-riscv-elf/pcgp-relax-02.d | 2 +- 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d create mode 100644 ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index de9ed2753bc..9f4ad7cbf25 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2023-02-23 Fangrui Song + + * emultempl/riscvelf.em: Add option parsing. + * testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d: New. + * testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d: New. + * testsuite/ld-riscv-elf/pcgp-relax-02.d: Test --relax --relax-gp can be + used together. + 2023-02-20 Nick Clifton PR 30004 diff --git a/ld/emultempl/riscvelf.em b/ld/emultempl/riscvelf.em index b12d15065c4..bb6298d3e8d 100644 --- a/ld/emultempl/riscvelf.em +++ b/ld/emultempl/riscvelf.em @@ -25,6 +25,40 @@ fragment <: +.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,[0-9]+ +.*:[ ]+[0-9a-f]+[ ]+jal[ ]+ra,[0-9a-f]+ <_start> +.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+a1,0x[0-9a-f]+ +.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,a1,[0-9]+ # [0-9a-f]+ +.*:[ ]+[0-9a-f]+[ ]+lui[ ]+a2,0x[0-9a-f]+ +.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a2,a2,[0-9]+ # [0-9a-f]+ +.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a3,tp,0 # 0 +.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+a0,0x[0-9a-f]+ diff --git a/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d b/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d index 1248132ab42..055f03e57f2 100644 --- a/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d +++ b/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d @@ -1,6 +1,6 @@ #source: pcgp-relax-02.s #as: -#ld: --relax +#ld: --relax --relax-gp #objdump: -d .*:[ ]+file format .* -- cgit v1.2.1