From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 44CBA3858419; Tue, 2 Apr 2024 08:56:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44CBA3858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712048169; bh=gpB4v+sQP4nEMtM+nJMwsgpwoMwUfH7XShX939X7B9s=; h=From:To:Subject:Date:From; b=HRpMYjg5bMqMOzj4ezcLO0Uk15APEdwXYT3/t0vnyyo0ALxKuEJPqAJrmYkGiyyHM 115HZoEMcWfDWF9Jbm1NdTKtILk5IwdqyksqtNVUHm7sXWCT0UjrwUII9wP9UdwvT3 34Lf3RsyKS0kNszvfCWzvL+dGlgD0dnEzp5gGqPs= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] PR31458, FAIL: MIPS eh-frame 3 with --no-keep-memory X-Act-Checkin: binutils-gdb X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/master X-Git-Oldrev: 3c6c32951e292a51ede70b8087bb0308d7dbc4fc X-Git-Newrev: 33c58f484406bd9665e5bd15637600540157f612 Message-Id: <20240402085609.44CBA3858419@sourceware.org> Date: Tue, 2 Apr 2024 08:56:09 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D33c58f484406= bd9665e5bd15637600540157f612 commit 33c58f484406bd9665e5bd15637600540157f612 Author: H.J. Lu Date: Thu Mar 7 08:28:29 2024 -0800 PR31458, FAIL: MIPS eh-frame 3 with --no-keep-memory =20 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. Diff: --- bfd/elf-bfd.h | 4 ++-- bfd/elflink.c | 6 +++--- bfd/elfxx-mips.c | 22 +++++++++++++++++----- ld/testsuite/ld-mips-elf/mips-elf.exp | 1 + 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 7ad171d5000..29283f24895 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2592,9 +2592,9 @@ extern char *_bfd_elfcore_strndup (bfd *, char *, size_t); =20 extern Elf_Internal_Rela *_bfd_elf_link_read_relocs - (bfd *, asection *, void *, Elf_Internal_Rela *, bool); + (bfd *, const asection *, void *, Elf_Internal_Rela *, bool); extern Elf_Internal_Rela *_bfd_elf_link_info_read_relocs - (bfd *, struct bfd_link_info *, asection *, void *, Elf_Internal_Rela *, + (bfd *, struct bfd_link_info *, const asection *, void *, Elf_Internal_R= ela *, bool); =20 extern bool _bfd_elf_link_output_relocs diff --git a/bfd/elflink.c b/bfd/elflink.c index 37a61b7cd31..e9cef470333 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2649,7 +2649,7 @@ _bfd_elf_link_assign_sym_version (struct elf_link_has= h_entry *h, void *data) =20 static bool elf_link_read_relocs_from_section (bfd *abfd, - asection *sec, + const asection *sec, Elf_Internal_Shdr *shdr, void *external_relocs, Elf_Internal_Rela *internal_relocs) @@ -2746,7 +2746,7 @@ elf_link_read_relocs_from_section (bfd *abfd, Elf_Internal_Rela * _bfd_elf_link_info_read_relocs (bfd *abfd, struct bfd_link_info *info, - asection *o, + const asection *o, void *external_relocs, Elf_Internal_Rela *internal_relocs, bool keep_memory) @@ -2843,7 +2843,7 @@ _bfd_elf_link_info_read_relocs (bfd *abfd, =20 Elf_Internal_Rela * _bfd_elf_link_read_relocs (bfd *abfd, - asection *o, + const asection *o, void *external_relocs, Elf_Internal_Rela *internal_relocs, bool keep_memory) diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index f2a1441fdf7..59444b063a4 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7298,11 +7298,23 @@ _bfd_mips_elf_eh_frame_address_size (bfd *abfd, con= st asection *sec) if (long64_p) return 8; =20 - if (sec->reloc_count > 0 - && elf_section_data (sec)->relocs !=3D NULL - && (ELF32_R_TYPE (elf_section_data (sec)->relocs[0].r_info) - =3D=3D R_MIPS_64)) - return 8; + if (sec->reloc_count > 0) + { + /* Load the relocations for this section. */ + Elf_Internal_Rela *internal_relocs =3D + _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, true); + if (internal_relocs =3D=3D NULL) + return 0; + + unsigned int size =3D 0; + if (ELF32_R_TYPE (internal_relocs[0].r_info) =3D=3D R_MIPS_64) + size =3D 8; + + if (elf_section_data (sec)->relocs !=3D internal_relocs) + free (internal_relocs); + + return size; + } =20 return 0; } diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-e= lf/mips-elf.exp index 50af78d1430..818238d0d58 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -771,6 +771,7 @@ if {$linux_gnu} { run_dump_test_n64 "eh-frame2-n64" } run_dump_test_eabi "eh-frame3" +run_dump_test_eabi "eh-frame3" {{ld --no-keep-memory} {name --no-keep-memo= ry}} run_dump_test_eabi "eh-frame4" if {$linux_gnu} { set eh_frame5_test {