diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-03-07 08:28:29 -0800 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2024-04-02 17:29:58 +1030 |
commit | 33c58f484406bd9665e5bd15637600540157f612 (patch) | |
tree | c961a2759521e46e966f83f577ea3c83eee96a77 | |
parent | 3c6c32951e292a51ede70b8087bb0308d7dbc4fc (diff) | |
download | gdb-33c58f484406bd9665e5bd15637600540157f612.zip gdb-33c58f484406bd9665e5bd15637600540157f612.tar.gz gdb-33c58f484406bd9665e5bd15637600540157f612.tar.bz2 |
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.
-rw-r--r-- | bfd/elf-bfd.h | 4 | ||||
-rw-r--r-- | bfd/elflink.c | 6 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 22 | ||||
-rw-r--r-- | 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 7ad171d..29283f2 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2592,9 +2592,9 @@ extern char *_bfd_elfcore_strndup (bfd *, char *, size_t); 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_Rela *, bool); extern bool _bfd_elf_link_output_relocs diff --git a/bfd/elflink.c b/bfd/elflink.c index 37a61b7..e9cef47 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2649,7 +2649,7 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data) 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, 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 f2a1441..59444b0 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7298,11 +7298,23 @@ _bfd_mips_elf_eh_frame_address_size (bfd *abfd, const asection *sec) if (long64_p) return 8; - 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; + if (sec->reloc_count > 0) + { + /* Load the relocations for this section. */ + Elf_Internal_Rela *internal_relocs = + _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, true); + if (internal_relocs == NULL) + return 0; + + unsigned int size = 0; + if (ELF32_R_TYPE (internal_relocs[0].r_info) == R_MIPS_64) + size = 8; + + if (elf_section_data (sec)->relocs != internal_relocs) + free (internal_relocs); + + return size; + } return 0; } diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 50af78d..818238d 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-memory}} run_dump_test_eabi "eh-frame4" if {$linux_gnu} { set eh_frame5_test { |