[v2,3/3] RISC-V: Fix h->got union phase confusion for DT_RELR

Message ID 20261001152854.3367296-8-jremus@linux.ibm.com
State Committed
Headers
Series ld: Fix h->got union phase confusion for DT_RELR |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Jens Remus Oct. 1, 2026, 3:28 p.m. UTC
  record_relr_dyn_got_relocs is called after allocate_dynrelocs has
repurposed h->got from refcount to offset semantics.  This goes
along with a change in indication for no GOT entry allocated from
h->got.refcount <= 0 to h->got.offset == (bfd_vma)-1.

bfd/
	* elfnn-riscv.c (record_relr_dyn_got_relocs): Fix h->got
	union phase confusion.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 bfd/elfnn-riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 4c6800c90ed3..c7445c7dd98d 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1806,7 +1806,7 @@  record_relr_dyn_got_relocs (struct elf_link_hash_entry *h, void *inf)
     return true;
   if (h->type == STT_GNU_IFUNC && h->def_regular)
     return true;
-  if (h->got.refcount <= 0)
+  if (h->got.offset == (bfd_vma) -1)
     return true;
   if (riscv_elf_hash_entry (h)->tls_type
       & (GOT_TLS_GD | GOT_TLS_IE | GOT_TLSDESC))