Allow note sections to be discarded when they are linked to another discarded secction.

PR 26681
bfd	* elflink.c (bfd_elf_gc_sections): Do not arbitrarily keep note
	sections which are linked to another section.

ld	* testsuite/ld-elf/pr26681.s: New test.
	* testsuite/ld-elf/pr26681.d: New test driver.
	* testsuite/ld-elf/pr26681.l: New test output.
This commit is contained in:
H.J. Lu
2020-10-02 11:08:19 +01:00
committed by Nick Clifton
parent 048fde1ef4
commit 7026832e52
6 changed files with 33 additions and 1 deletions

View File

@@ -14102,7 +14102,8 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
|| (elf_section_data (o)->this_hdr.sh_type
== SHT_FINI_ARRAY)))
|| (elf_section_data (o)->this_hdr.sh_type == SHT_NOTE
&& elf_next_in_group (o) == NULL )))
&& elf_next_in_group (o) == NULL
&& elf_linked_to_section (o) == NULL)))
{
if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
return FALSE;