aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elfnn-riscv.c18
2 files changed, 21 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 250e416..a8f4688 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,9 @@
2018-06-03 Jim Wilson <jimw@sifive.com>
+ PR ld/23244
+ * elfnn-riscv.c (riscv_elf_relocate_section) <R_RISCV_CALL>: Check
+ for and handle an undefined weak with no PLT.
+
PR ld/22756
* elfnn-riscv.c (riscv_relax_delete_bytes): Add versioned_hidden check
to code that ignores duplicate symbols.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index a0bdee5..7b1ca47 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1931,8 +1931,24 @@ riscv_elf_relocate_section (bfd *output_bfd,
}
break;
- case R_RISCV_CALL_PLT:
case R_RISCV_CALL:
+ /* Handle a call to an undefined weak function. This won't be
+ relaxed, so we have to handle it here. */
+ if (h != NULL && h->root.type == bfd_link_hash_undefweak
+ && h->plt.offset == MINUS_ONE)
+ {
+ /* We can use x0 as the base register. */
+ bfd_vma insn = bfd_get_32 (input_bfd,
+ contents + rel->r_offset + 4);
+ insn &= ~(OP_MASK_RS1 << OP_SH_RS1);
+ bfd_put_32 (input_bfd, insn, contents + rel->r_offset + 4);
+ /* Set the relocation value so that we get 0 after the pc
+ relative adjustment. */
+ relocation = sec_addr (input_section) + rel->r_offset;
+ }
+ /* Fall through. */
+
+ case R_RISCV_CALL_PLT:
case R_RISCV_JAL:
case R_RISCV_RVC_JUMP:
if (bfd_link_pic (info) && h != NULL && h->plt.offset != MINUS_ONE)