Bug 31458 - FAIL: MIPS eh-frame 3 with --no-keep-memory
Summary: FAIL: MIPS eh-frame 3 with --no-keep-memory
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.43
: P2 normal
Target Milestone: 2.43
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-07 16:06 UTC by H.J. Lu
Modified: 2024-04-02 08:57 UTC (History)
3 users (show)

See Also:
Host:
Target: mipstx39-elf
Build:
Last reconfirmed:


Attachments
A patch (1.65 KB, patch)
2024-03-07 16:29 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2024-03-07 16:06:29 UTC
When --no-keep-memory is enabled, mipstx39-elf reports:

FAIL: MIPS eh-frame 3

due to this code in
bfd/elfxx-mips.c:_bfd_mips_elf_eh_frame_address_size to fail:

      if (sec->reloc_count > 0
          && elf_section_data (sec)->relocs != NULL
          && (ELF32_R_TYPE (elf_section_data (sec)->relocs[0].r_info)
              == R_MIPS_64))
        return 8;

elf_section_data (sec)->relocs is NULL with --no-keep-memory.
Comment 1 H.J. Lu 2024-03-07 16:29:28 UTC
Created attachment 15390 [details]
A patch

Please feel free to take over this patch.
Comment 2 Sourceware Commits 2024-04-02 08:56:10 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=33c58f484406bd9665e5bd15637600540157f612

commit 33c58f484406bd9665e5bd15637600540157f612
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Mar 7 08:28:29 2024 -0800

    PR31458, FAIL: MIPS eh-frame 3 with --no-keep-memory
    
            PR 31458
    bfd/
            * elf-bfd.h (_bfd_elf_link_read_relocs),
            (_bfd_elf_link_info_read_relocs): Constify section.
            * elflink.c: Likewise.
            * elfxx-mips.c (_bfd_mips_elf_eh_frame_address_size): Read
            relocs again in case --no-keep-memory.
    ld/
            * testsuite/ld-mips-elf/mips-elf.exp: Run --no-keep-memory
            version of eh-frame3 test.
Comment 3 Alan Modra 2024-04-02 08:57:19 UTC
Patch with some tidies applied.