Report bfd_merge_sections error

PR 32260
bfd/
	* elfxx-target.h (bfd_elfNN_bfd_merge_sections): Default to
	bfd_generic_merge_sections when using the generic linker.
	* elflink.c (_bfd_elf_merge_sections): Return error from
	_bfd_merge_sections.  Abort on wrong hash table.
ld/
	* ldlang.c (lang_process): Report bfd_merge_sections error.
This commit is contained in:
Alan Modra 2024-10-20 17:13:31 +10:30
parent 17b145510f
commit 32dc367249
3 changed files with 12 additions and 10 deletions

View File

@ -8109,8 +8109,8 @@ _bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info)
bfd *ibfd;
asection *sec;
if (!is_elf_hash_table (info->hash))
return false;
if (ENABLE_CHECKING && !is_elf_hash_table (info->hash))
abort ();
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
if ((ibfd->flags & DYNAMIC) == 0
@ -8133,8 +8133,8 @@ _bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info)
}
if (elf_hash_table (info)->merge_info != NULL)
_bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info,
merge_sections_remove_hook);
return _bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info,
merge_sections_remove_hook);
return true;
}

View File

@ -187,11 +187,6 @@
#define bfd_elfNN_bfd_gc_sections bfd_elf_gc_sections
#endif
#ifndef bfd_elfNN_bfd_merge_sections
#define bfd_elfNN_bfd_merge_sections \
_bfd_elf_merge_sections
#endif
#ifndef bfd_elfNN_bfd_is_group_section
#define bfd_elfNN_bfd_is_group_section bfd_elf_is_group_section
#endif
@ -287,6 +282,9 @@
#ifndef bfd_elfNN_bfd_final_link
#define bfd_elfNN_bfd_final_link bfd_elf_final_link
#endif
#ifndef bfd_elfNN_bfd_merge_sections
#define bfd_elfNN_bfd_merge_sections _bfd_elf_merge_sections
#endif
#else /* ! defined (elf_backend_relocate_section) */
/* If no backend relocate_section routine, use the generic linker.
Note - this will prevent the port from being able to use some of
@ -310,6 +308,9 @@
#ifndef bfd_elfNN_bfd_final_link
#define bfd_elfNN_bfd_final_link _bfd_generic_final_link
#endif
#ifndef bfd_elfNN_bfd_merge_sections
#define bfd_elfNN_bfd_merge_sections bfd_generic_merge_sections
#endif
#endif /* ! defined (elf_backend_relocate_section) */
#ifndef bfd_elfNN_bfd_link_just_syms

View File

@ -8426,7 +8426,8 @@ lang_process (void)
sections, so that GCed sections are not merged, but before
assigning dynamic symbols, since removing whole input sections
is hard then. */
bfd_merge_sections (link_info.output_bfd, &link_info);
if (!bfd_merge_sections (link_info.output_bfd, &link_info))
einfo (_("%F%P: bfd_merge_sections failed: %E\n"));
/* Look for a text section and set the readonly attribute in it. */
found = bfd_get_section_by_name (link_info.output_bfd, ".text");