[binutils-gdb] Re: LoongArch: Fix relaxation alignment with ld -r (PR 33236)

Alan Modra via Binutils-cvs <[email protected]> Tue, 7 Jul 2026 01:47:24 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41125b6971718e3164d9cf8fc78670ddb80403b4

commit 41125b6971718e3164d9cf8fc78670ddb80403b4
Author: Alan Modra <[email protected]>
Date:   Tue Jul 7 11:02:00 2026 +0930

    Re: LoongArch: Fix relaxation alignment with ld -r (PR 33236)
    
    Correct sh_size and sh_entsize to use external reloc size.
    loongarch32-elf  +FAIL: Linkonce sections with assembler generated notes
    loongarch32-elf  +FAIL: ld-loongarch-elf/relax-align-ld-r

Diff:
---
 bfd/elfnn-loongarch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index f4d8d32ff2f..11008133255 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -7096,8 +7096,8 @@ loongarch_add_align_relocs (asection *align_sec, bfd* align_bfd)
       if (rela_hdr == NULL)
        return false;
 
-      rela_hdr->sh_size = sizeof (Elf_Internal_Rela);
-      rela_hdr->sh_entsize = sizeof (Elf_Internal_Rela);
+      rela_hdr->sh_size = sizeof (ElfNN_External_Rela);
+      rela_hdr->sh_entsize = sizeof (ElfNN_External_Rela);
       rela_hdr->sh_type = SHT_RELA;
       rela_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
       elf_section_data (align_sec)->rela.hdr = rela_hdr;