diff options
author | Fangrui Song <i@maskray.me> | 2023-02-23 22:11:14 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2023-02-23 22:11:14 -0800 |
commit | 50980ba351856dff75bb0743bfca62f4c3ab19ff (patch) | |
tree | 57293555d30735da578d765d9d4058b46d237df9 /ld/emultempl/riscvelf.em | |
parent | 6777dece58127236db900215857f9070ad63e0bf (diff) | |
download | gdb-50980ba351856dff75bb0743bfca62f4c3ab19ff.zip gdb-50980ba351856dff75bb0743bfca62f4c3ab19ff.tar.gz gdb-50980ba351856dff75bb0743bfca62f4c3ab19ff.tar.bz2 |
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.
Diffstat (limited to 'ld/emultempl/riscvelf.em')
-rw-r--r-- | ld/emultempl/riscvelf.em | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ld/emultempl/riscvelf.em b/ld/emultempl/riscvelf.em index b12d150..bb6298d 100644 --- a/ld/emultempl/riscvelf.em +++ b/ld/emultempl/riscvelf.em @@ -25,6 +25,40 @@ fragment <<EOF #include "elf/riscv.h" #include "elfxx-riscv.h" +static struct riscv_elf_params params = { .relax_gp = 1 }; +EOF + +# Define some shell vars to insert bits of code into the standard elf +# parse_args and list_options functions. */ +PARSE_AND_LIST_PROLOGUE=${PARSE_AND_LIST_PROLOGUE}' +enum risccv_opt +{ + OPTION_RELAX_GP = 321, + OPTION_NO_RELAX_GP, +}; +' + +PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}' + { "relax-gp", no_argument, NULL, OPTION_RELAX_GP }, + { "no-relax-gp", no_argument, NULL, OPTION_NO_RELAX_GP }, +' + +PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}' + fprintf (file, _(" --relax-gp Perform GP relaxation\n")); + fprintf (file, _(" --no-relax-gp Don'\''t perform GP relaxation\n")); +' + +PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}' + case OPTION_RELAX_GP: + params.relax_gp = 1; + break; + + case OPTION_NO_RELAX_GP: + params.relax_gp = 0; + break; +' + +fragment <<EOF static void riscv_elf_before_allocation (void) { @@ -96,6 +130,8 @@ riscv_create_output_section_statements (void) " whilst linking %s binaries\n"), "RISC-V"); return; } + + riscv_elf${ELFSIZE}_set_options (&link_info, ¶ms); } EOF |