RISC-V: Optimize lui and auipc relaxations for undefweak symbol.
authorJim Wilson <jimw@sifive.com>
Fri, 20 Sep 2019 22:01:20 +0000 (15:01 -0700)
committerJim Wilson <jimw@sifive.com>
Fri, 20 Sep 2019 22:01:20 +0000 (15:01 -0700)
commit9d1da81b261a20050ef2ad01a5b4c8cf78404222
treebc9c73aaa8be63ebed399e1d3666a7fc84811883
parentabf516c6931af1683d1e51203de1ca01467f9f85
RISC-V: Optimize lui and auipc relaxations for undefweak symbol.

For the lui and auipc relaxations, since the symbol value of an undefined weak
symbol is always be zero, we can optimize the patterns into a single LI/MV/ADDI
instruction.

bfd/
* elfnn-riscv.c (riscv_pcgp_hi_reloc): Add new field undefined_weak.
(riscv_record_pcgp_hi_reloc): New parameter undefined_weak.
Set undefined_weak field from it.
(relax_func_t): New parameter undefined_weak.
(_bfd_riscv_relax_call): New ignored parameter undefined_weak.
(_bfd_riscv_relax_tls_le): Likewise.
(_bfd_riscv_relax_align): Likewise.
(_bfd_riscv_relax_delete): Likewise.
(_bfd_riscv_relax_lui): New parameter undefined_weak.  If true,
allow relaxing.  For LO12* relocs, set rs1 to x0 when undefined_weak.
(_bfd_riscv_relax_pc): New parameter undefined_weak.  For LO12* relocs,
set undefined_weak from hi_reloc.  If true, allow relaxing.  For LO12*
relocs, set rs1 to x0 when undefined_weak and change to non-pcrel
reloc.
(_bfd_riscv_relax_section): New local undefined_weak.  Set for
undef weak relocs that can be relaxed.  Pass to relax_func call.

ld/
* testsuite/ld-riscv-elf/weakref32.s: Add relaxable undef weak code.
* testsuite/ld-riscv-elf/weakref64.s: Likewise.
* testsuite/ld-riscv-elf/weakref32.d: Updated.
* testsuite/ld-riscv-elf/weakref64.d: Updated.
bfd/ChangeLog
bfd/elfnn-riscv.c
ld/ChangeLog
ld/testsuite/ld-riscv-elf/weakref32.d
ld/testsuite/ld-riscv-elf/weakref32.s
ld/testsuite/ld-riscv-elf/weakref64.d
ld/testsuite/ld-riscv-elf/weakref64.s
This page took 0.02437 seconds and 4 git commands to generate.