[binutils-gdb] RISC-V: PR32772, fixed segfault caused by the accidental removal of `h != NULL'
Nelson Chu
nelsonc1225@sourceware.org
Sun Mar 9 06:20:16 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=512316811d47d689d75d25aa9d5b98bdafd64df6
commit 512316811d47d689d75d25aa9d5b98bdafd64df6
Author: Nelson Chu <nelson@rivosinc.com>
Date: Sun Mar 9 14:17:09 2025 +0800
RISC-V: PR32772, fixed segfault caused by the accidental removal of `h != NULL'
bfd/
PR 32772
* elfnn-riscv.c (riscv_elf_relocate_section): Fixed segfault caused by
the accidental removal of `h != NULL' when handling a call to an
undefined weak function.
Diff:
---
bfd/elfnn-riscv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index bca3a585f56..06e99401229 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2783,7 +2783,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
case R_RISCV_CALL_PLT:
/* Handle a call to an undefined weak function. This won't be
relaxed, so we have to handle it here. */
- if (h->root.type == bfd_link_hash_undefweak && !via_plt)
+ if (h != NULL && h->root.type == bfd_link_hash_undefweak && !via_plt)
{
/* We can use x0 as the base register. */
bfd_vma insn = bfd_getl32 (contents + rel->r_offset + 4);
More information about the Binutils-cvs
mailing list