[0/2] ld: Fix h->got union phase confusion for DT_RELR

Message ID 20261001151257.3242569-4-jremus@linux.ibm.com
Headers
Series ld: Fix h->got union phase confusion for DT_RELR |

Message

Jens Remus Oct. 1, 2026, 3:12 p.m. UTC
  This fixes a h->got union phase confusion for DT_RELR in aarch64 and
LoongArch in record_relr_dyn_got_relocs.

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.

I ran into this while working on porting DT_RELR support from aarch64
to s390 64-bit (s390x) including several aarch64 and x86-64 DT_RELR
tests.

x86-64 DT_RELR tests dt-relr-1* failed on s390 64-bit (s390), because
record_relr_dyn_got_relocs was checking h->got.refcount <= 0, although
h->got is already repurposed from refcount to offset semantics.  On
s390 the offset may be zero, which resulted in the __ehdr_start GOT slot
to neither have a .relr.dyn nor .rela.dyn entry.

Regards,
Jens

Jens Remus (2):
  aarch64: Fix h->got union phase confusion for DT_RELR
  LoongArch: Fix h->got union phase confusion for DT_RELR

 bfd/elfnn-aarch64.c   | 2 +-
 bfd/elfnn-loongarch.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)