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.
This commit is contained in:
H.J. Lu 2024-03-07 08:28:29 -08:00 committed by Alan Modra
parent 3c6c32951e
commit 33c58f4844
4 changed files with 23 additions and 10 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;
}

View File

@ -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 {